UI delivery: plan, summary and docs (CSP origins, --csp-connect-extra, nginx-unprivileged)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3347fffe8e
commit
b61989bd22
13 files changed
+203
-9
No files matched your search
@@ -122,3 +122,25 @@ sudo apt install nginx
|
||||
```bash
|
||||
setsebool -P httpd_can_network_connect 1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Security headers and CSP (site written by `install.sh`)
|
||||
|
||||
The site that `install.sh` / `update.sh` write (`deploy/native/nginx/ovpmon.conf.template`, first line has the marker "managed by ovpmon") sends `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, `Cache-Control: no-store` and a Content-Security-Policy:
|
||||
|
||||
```
|
||||
default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:;
|
||||
connect-src 'self' <extra origins>; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'
|
||||
```
|
||||
|
||||
The headers are declared on the `server` level only: an `add_header` inside a `location` would drop all of them. `style-src 'unsafe-inline'` is needed by Bootstrap and Chart.js.
|
||||
|
||||
The default `connect-src` allows the page origin only. If `config.json` points the UI to an API on another host, add its origin:
|
||||
|
||||
```bash
|
||||
deploy/native/update.sh --csp-connect-extra "https://api.example.com http://10.0.0.5:5001" # several origins: separated by spaces
|
||||
deploy/native/update.sh --csp-connect-extra "" # remove them
|
||||
```
|
||||
|
||||
`install.sh` accepts the same option. The value is kept in `/etc/ovpmon/deploy.state` (`OVPMON_CSP_CONNECT_EXTRA`) and applied again by every update. Only `https://host[:port]` and `http://host[:port]` are accepted (the value ends up in a response header). An existing site without the marker line is not changed by `update.sh`: add the CSP there by hand. The API on the other origin must also allow this UI origin (`OVPMON_CORS_ORIGINS`).
|
||||
@@ -13,7 +13,7 @@ deploy/native/update.sh --no-pull # sources already in p
|
||||
deploy/native/update.sh --rollback # manual rollback to the newest backup
|
||||
```
|
||||
|
||||
Run it from the checkout that holds the new version (the script uses the templates of that checkout). `--prefix` and the HTTPS port come from `/etc/ovpmon/deploy.state`. The update needs access to PyPI for the new virtualenvs.
|
||||
Run it from the checkout that holds the new version (the script uses the templates of that checkout). `--prefix`, the HTTPS port and the extra CSP origins (`OVPMON_CSP_CONNECT_EXTRA`) come from `/etc/ovpmon/deploy.state`; `--csp-connect-extra "https://api.example.com"` changes the origins (`""` removes them) and re-renders the nginx site. A site that is not managed by the scripts (marker line removed) is left untouched. The update needs access to PyPI for the new virtualenvs.
|
||||
|
||||
Each phase is logged separately:
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ Options:
|
||||
| `--node-download` | with `--build-ui`: use a temporary official Node 20 (checksum verified, glibc only) |
|
||||
| `--no-ui` | install a placeholder page on purpose; without any UI source and without this option the install stops |
|
||||
| `--https-port N` | HTTPS port of the web UI (default `8088`) |
|
||||
| `--csp-connect-extra ORIGINS` | extra origins the UI may call (CSP `connect-src`), for an API on another host: `https://host[:port]` or `http://host[:port]` separated by spaces, in quotes; default none (same origin only). Stored in `/etc/ovpmon/deploy.state` as `OVPMON_CSP_CONNECT_EXTRA`; anything else is refused |
|
||||
| `--host-name NAME` | DNS name or IP for the certificate and the CORS origin (default: the detected address of the default route) |
|
||||
| `--admin-user NAME` | login of the first administrator (default `admin`) |
|
||||
| `--force` | continue on an untested OS version |
|
||||
|
||||
@@ -64,6 +64,18 @@ With the unprivileged profiler the API only stages `server.conf`; **the helper c
|
||||
|
||||
OpenRC runs `/sbin/rc-service <unit> <action>`, systemd runs `systemctl <action> <unit>` (fixed argument list, fixed `PATH`). Unknown keys or invalid values make the helper refuse.
|
||||
|
||||
## Deployment state (`/etc/ovpmon/deploy.state`)
|
||||
|
||||
`KEY=VALUE` lines written by `install.sh` and `update.sh`; `update.sh` reads them back.
|
||||
|
||||
| Key | Meaning |
|
||||
|---|---|
|
||||
| `OVPMON_PREFIX` | install directory |
|
||||
| `OVPMON_HTTPS_PORT` | HTTPS port of the nginx site |
|
||||
| `OVPMON_CSP_CONNECT_EXTRA` | extra origins of the CSP `connect-src` in the nginx site (`install.sh` / `update.sh --csp-connect-extra`); empty = same origin only. Validated: `https://host[:port]` or `http://host[:port]` separated by spaces |
|
||||
| `OVPMON_OS`, `OVPMON_VERSION`, `OVPMON_INSTALLED_AT`, `OVPMON_LAST_UPDATE` | information |
|
||||
| `FIREWALL_*` | settings of `firewall.sh`, see [Firewall](Firewall.md) |
|
||||
|
||||
## Security notes
|
||||
|
||||
- Services run as `ovpmon` (no login shell); code and virtualenvs are root-owned and read-only for them. systemd units add `PrivateTmp`, `ProtectHome`, `ProtectSystem=full`, kernel and cgroup protection; `ovpmon-api` and `ovpmon-gatherer` also set `NoNewPrivileges`. `ovpmon-profiler` must **not** (it calls the setuid `doas`), must not use seccomp-based options either (`ProtectKernelTunables`, `ProtectKernelModules`, `RestrictRealtime`, `LockPersonality`, `SystemCallFilter`, ...): for an unprivileged unit systemd then sets NoNewPrivileges implicitly and `doas` fails with "not installed setuid" (check: `grep NoNewPrivs /proc/<main pid>/status` must show 0). It keeps `/etc/openvpn` writable, because the helper runs inside the profiler's mount namespace.
|
||||
|
||||
Reference in new issue
Block a user