Files
coder/docs/admin/security
Nick VigilanteandLisa Fiander 9bbae0890e docs: add incident response page (#32402)
## Summary

Adds a generic incident response page for Coder deployment
administrators.
It's split out of #32356 (disaster recovery) so each topic gets its own
review.

## Changes

- New `docs/admin/security/incident-response.md` (how-to), under Admin >
Security:
- A table that matches each incident type to its narrowest containment.
A full cutoff is one option, for when the scope is unknown.
  - What each action blocks, and whether it ends open sessions.
- Containment steps for leaked tokens, compromised users, and
compromised owners, including break-glass password accounts.
Leaked tokens are expired by their ID prefix, which also covers session
tokens.
- Dashboard, CLI, and REST API paths for each containment step,
including a script that strips an owner's roles and suspends it.
- After a compromised owner, an audit log query and a table of how to
revoke each resource type it created.
- Responses to a compromised PostgreSQL database, control plane,
external provisioner, workspace proxy, or workspace.
- A section on the credentials that workspace builds receive (owner
session token, Git SSH key, OIDC and external auth tokens, template
variables, parameters), which component exposes each, and how to rotate
them, ending with a workspace restart.
- Steps to cut off access to every workspace (including a site-wide
suspend of non-owner users), then to investigate, restore access, and
prevent common incidents.
- Sidebar entry in `docs/admin/security/sidebar.yml`.

## Notes for reviewers

- Owners can't be suspended, and you can't change your own roles
(`coderd/users.go`, `putUserStatus` and `putUserRoles`). So the owner
steps have another owner remove the role with `coder users edit-roles`
first. With OIDC site-role sync on, Coder rejects the role change, so
the page points to the IdP.
- An owner can reset another owner's password. A reset through the
dashboard or `PUT /api/v2/users/{user}/password` runs
`DeleteAPIKeysByUserID` (`coderd/users.go`). `coder reset-password`
(`cli/resetpassword.go`) only updates the hash, so the page tells
readers to expire tokens separately after using it.
- OIDC site role sync runs only at sign-in (`coderd/userauth.go`,
`SyncRoles` in the OAuth login path). While `--oidc-user-role-field` is
set, Coder also rejects role edits for OIDC users (`putUserRoles`). So
removing Owner in the IdP doesn't contain a signed-in attacker. The page
has the operator unset the flag and restart first.
- `coder users edit-roles --yes` can't clear every site role: an empty
`--roles` triggers the interactive picker, which `--yes` rejects
(`cli/usereditroles.go`). The CLI tab keeps the other roles, and the
REST API tab clears all of them.
- `coder server create-admin-user` has no REST API equivalent, because
granting Owner through the API needs owner credentials.
- Not on the page: Coder rotates its signing keys (`crypto_keys`) every
30 days (`coderd/cryptokeys/rotate.go`) and has no command to rotate
them early. That matters after a database compromise when database
encryption is off.
- Agent tokens rotate on every build. The Terraform provider generates a
new token in both Create and Read (`terraform-provider-coder` v2.20.0,
`provider/agent.go`), so a persistent `coder_agent` also gets a new
token on each refresh.
`GetAuthenticatedWorkspaceAgentAndBuildByAuthToken` accepts only tokens
from the latest build, plus the previous start build while a stop or
delete is running. Tokens are a plaintext `uuid` column that database
encryption doesn't cover, so the database section says to restart every
workspace. I verified this in source, not with a live restart, because
the test workspace is the one running this agent.
- I documented break-glass recovery publicly instead of in a Pylon KB
article, because every command it uses already has a public reference
page. That's open to change.
- An owner can expire any user's key by ID, including password and OIDC
session keys: `GET /users/{user}/keys/{keyid}` and `PUT .../expire` look
the key up by ID and authorize against the key, not the path user
(`coderd/apikey.go`). `coder tokens remove <id>` uses that fallback
(`cli/tokens.go`). `tokens list --all` only returns `login_type=token`
keys.
- Provisioner jobs receive the owner session token, Git SSH private key,
OIDC access token, external auth tokens, template variables, parameters,
and Terraform state (`coderd/provisionerdserver/provisionerdserver.go`,
`acquireProtoJob`). A start build replaces the owner session token and a
stop build deletes it. Owners can't read or change another user's
secrets (`coderd/rbac/roles.go`), so the page asks users to rotate their
own.
- Prebuild claims reuse the agent tokens from build 1
(`RunningAgentAuthTokens`), so the page says to delete unclaimed
prebuilt workspaces to rotate them.
- Provisioner keys aren't an audited resource and have no creator field,
so the page says to delete keys by creation time.
- Two things are verified in the code only, not run: suspension doesn't
end open sessions, and stopping the control plane doesn't end direct
sessions right away (`tailnet/configmaps.go`, `lostTimeout`).
- The CLI stop-all pipeline isn't run against a live deployment. It's
Bash and Zsh only.
- There's no cross-link to the disaster recovery page yet, because that
page isn't on `main`. I'll add one in whichever PR merges second.

## Testing

- `make lint/emdash`, `make lint/docs-manifest`, and `make
lint/docs-html` pass.
- markdownlint and Vale on the new page: 0 findings.
- Every shell snippet parses in Bash and Zsh (`-n`), and the jq filters
were run against sample JSON in the API response shapes.
- Relative links and in-page anchors resolve.
- A temporary `coderdtest` test (not committed) confirmed: an owner can
look up and expire another user's session key by ID; `tokens list --all`
omits session keys; an owner can create a session key for another user
that no token list shows, and a dashboard or API password reset deletes
it; an owner can regenerate another user's Git SSH key.

<details>
<summary>Decision log</summary>

- The first draft was `cut-off-workspace-access.md` in #32356. Review
feedback asked for:
- a generic incident response page, because cutting off workspace access
isn't always the right response;
  - guidance for compromised Owner and break-glass accounts;
  - two wording fixes in the intro, which are applied.
- I restructured the page as: choose a response, know what each action
blocks, contain, cut off everything, investigate and restore, prevent.
- I moved the "situations" table into a final prevention list, so the
page opens with the response.
- Second review round asked for:
  - dashboard, CLI, and REST API paths for each step;
  - a non-interactive owner containment script;
  - the OIDC note at the start of its section;
  - a site-wide suspend for when the scope is unknown;
  - a Premium callout;
  - coverage of compromised architecture components.
- Third review round asked for:
- expiring leaked tokens by ID prefix, because `tokens list --all`
misses session tokens;
  - revoking what a compromised owner created, using the audit log;
- rotating the owner credentials and stored secrets that a compromised
provisioner, control plane, or database exposes, and restarting the
affected workspaces.
- I put the credential rotation in one shared section that each
component links to, with a table of which component exposes which
credential, instead of repeating the steps under each component.

</details>

---

_This PR was generated by Coder Agents on behalf of @nickvigilante._

---------

Co-authored-by: Lisa Fiander <lisa@coder.com>
2026-12-04 14:46:26 +00:00
..