Repository navigation
fix(keys): gate key secrets on the caller's effective scopes - #14603
Conversation
The secret was only blanked for API keys without keys.write, so a console member whose role grants keys.read but not keys.write still received every key secret. Record the scopes the request was authorized with on the request and check those instead, which covers API keys and console sessions alike. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
The change centralizes secret-redaction decisions into the request's granted scope set instead of inspecting each key document per endpoint, with matching e2e coverage updates for both the Project and Organization key suites.
Reviewed commit: d533315 |
🟢 Tier S · Ready to merge
The API initialization hook now records the scopes that passed authorization on the request. Project and organization key get/list actions use those effective scopes to decide whether to return key secrets, and the E2E tests add checks for writer-visible and read-only responses.
📂 Walkthrough · 8
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What
Key
secretonGET /v1/project/keys[/:keyId]andGET /v1/organization/projects/:projectId/keys[/:keyId]is now blanked unless the request was authorized with the key write scope, whatever the caller type.#14600 only checked API keys. A console member whose role grants
keys.readwithoutkeys.write(CE roles always hold both, but other role sets don't) still got secrets.How
apiinit hook records the scopes it authorized the request with viaRequest::setScopes()(right after the scope check).$request->getScopes()in place of$apiKey->getScopes(). The project routes no longer injectapiKey.Tests
Organization/KeysBase::testGetKeySecretRequiresWriteScope: the suite's caller (console session or server key) still gets secrets from get and list, and the read-only key still gets''.Project/KeysBase::testKeysLifecycle: the writer gets the secret on get and list.CE has no console role with
keys.readbut notkeys.write, so the read-only console case gets its test in the Cloud PR.🤖 Generated with Claude Code