Files
coder/codersdk
John T SkarbekandClaude Sonnet 5.5 c484ad2be4 fix: keep the provisioner key secret out of request paths and logs (#32532)
Linear: [PLE-94](https://linear.app/codercom/issue/PLE-94). One of three
independent PRs split out of the original masking change.

## Root cause
`codersdk.Client.GetProvisionerKey` sent the real provisioner key secret
in the URL path (`/api/v2/provisionerkeys/<key>`) as well as in the
`Coder-Provisioner-Daemon-Key` header. The path ends up in proxy/access
logs, the server request logger (`path`, `params_provisionerkey`) and
the SDK's `sdk request` debug log. The server ignores the path value:
the route uses `ExtractProvisionerDaemonAuthenticated` and
`fetchProvisionerKey` returns the header-authenticated key. Nothing
reads `{provisionerkey}` on that route (`ExtractProvisionerKeyParam` is
only mounted on the org-scoped route, where the value is a key name).

## Fix
- The SDK now sends a fixed placeholder segment,
`/api/v2/provisionerkeys/me`; the secret travels only in the header. Old
servers ignore the path, and old clients still work with new servers.
- `loggermw` masks the `provisionerkey` route param (keeping at most a 4
character prefix) in `params_*` and `path` as a backstop for old
clients. It only applies when the route pattern is the top-level
`/provisionerkeys/{provisionerkey}`; the org-scoped
`/organizations/{organization}/provisionerkeys/{provisionerkey}` carries
a key name and is left alone.
- Swagger annotation and generated docs now describe the path param as
an ignored placeholder (edited by hand, not via `make gen`).

Sibling PRs (independent, disjoint files):
- https://github.com/coder/coder/pull/32526
- https://github.com/coder/coder/pull/32533

## Follow-ups not included
- AI Gateway prompt, tool and thought content logged in
`aibridgedserver.go` (~511-613) and `aibridge/recorder/log_recorder.go`
- `rich_parameter_values` in `runner.go` (~443)
- Proxy `response_body` in `aibridgeproxyd.go` (~1102)
- Terraform `TF_LOG` output relayed to logs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 08:11:09 -05:00
..
…