# A Host check doesn't stop CSRF on a localhost dashboard

my status page runs on `localhost:4480` and was read-only. when I gave it buttons that run commands, the `Host` check it already had stopped being enough. a page on any website can make your browser POST to `localhost:4480`, and that request carries a valid `Host`.

what a POST to `/api/actions/<id>` needs now:

- the `Host` check, still, against DNS rebinding
- an `Origin` of `http://localhost:4480`
- an `X-Sysdash-Token` header. the token is new on every server start and goes into the page as it's served

a cross-origin request with a custom header needs a CORS preflight first, and the server never answers preflights (501), so the browser never sends the real request. checked with curl: missing or foreign Origin, missing or wrong token, and a rebinding Host all get 403.

the page polls `/api/actions` with a `boot` id. when the id changes, the page reloads, so a tab left open across a restart picks up the new token instead of failing.

what a button can run is limited too. `actions.toml` lists the commands, and the server reads it but never writes it. each one runs as argv with no shell, stdin closed, in its own process group, so a timeout kills its children. deletes, kills and prunes aren't buttons. they stay in the terminal.

---

see also: [a monitoring key that can only run one script](/articles/monitoring-key-one-script)
