Files
coder/coderd/database/dbauthz
Ethan 924e84d59a fix: gate chat instruction reads on deployment_config:read (#32928)
Closes WI-101

`GET /api/v2/chats/config/system-prompt` and `GET
/api/v2/chats/config/plan-mode-instructions` both checked
`deployment_config:update`, so a token that only needs to read them,
e.g. for a `terraform plan`, also had to be able to write them, along
with every other setting behind that permission. The check was `read`
when #23616 first added it, and was switched to `update` in that same PR
to match the gate on the settings form.

To fix, we'll check `deployment_config:read` on both, as the other
admin-only reads under `/chats/config` already do. The `PUT`s still need
`update`. Both settings are now gated on `read` in `dbauthz` as well.
Plan mode instructions already had a check there, which moves from
`update`. As chatd only holds `read`, it had been borrowing the system
identity for that read, and now reads them as itself. The system prompt
had none, as chat creation read it as the chat's creator, so chatd now
reads it itself too, like it does for organization instructions. As each
`PUT` reads the old value for its audit entry, both now answer 403 for a
token without `read`.

Auditor is the only built-in role with `read` but not `update`, so
auditors now get a read-only view of the deployment instructions on the
Instructions page. The sidebar link to that page is shown for `read`
too.

A token scoped to `deployment_config:update` without
`deployment_config:read` can no longer read or write either setting.
Tokens have only been able to request these scopes since #32653, which
isn't in a release yet.
2026-12-02 15:54:14 +00:00
..