Make read_metadata a real boundary for secrets
What does this MR do and why?
Every Secrets Manager grant could list the names and metadata of all secrets, because Rails added list and scan to every policy. And create, update and delete failed without read_metadata, because they read the secret as the user first. This makes read_metadata a real boundary and lets those writes work without it.
Details
- Policies:
liston the metadata and detailed-metadata paths only withread_metadata(orread).scanis gone (Rails never used it). Theread_valueAPI policy keepsliston metadata (key names) but no longer lists detailed metadata. Paths with no capabilities stay in the policy so the list service still readsgranted_byand the expiry. OpenBao accepts them, and they grant nothing. - Reads before writes:
ReadMetadataServicetakeswrite_capability:. It reads as the user. Only when OpenBao denies that read andcapabilities-selfshows the user holds the capability on that secret does it re-read with the app client. The write still runs as the user. Rails abilities for these mutations start at Reporter, so the capability check is what stops a user with no grant from probing metadata. EffectiveCapabilitiesServicealready treats detailed-metadatalistasread_metadata, souserPermissions.readMetadatais now accurate.
References
Screenshots or screen recordings
No UI changes. Users without read_metadata now see the existing "no read access" state on the secrets page.
How to set up and validate locally
- As an Owner, grant a Reporter
createandread_valueon a project with Secrets Manager active. - As that Reporter, create a secret through the
projectSecretCreatemutation. It succeeds (it failed before). - As that Reporter, query
projectSecrets. It returns "resource not available" (it listed every secret before).
Testing
Not run locally: native gems don't build on this machine (macOS SDK linker error). Specs added for the policy shape, create, update and delete with a write grant plus read_value, the denied cases, and the read fallback. CI runs them.
Risk
- Existing grants in OpenBao keep
listandscanuntil edited. A follow-up will rewrite them. - After the fallback, a successful update or delete returns the secret's metadata to a writer without
read_metadatawho knows the name. Accepted: they can already overwrite that metadata. - Users with only write grants lose the secrets page. They can still use the API.
How to revert
Revert this MR. No migration, and policies written while it was live keep working because they only have fewer capabilities.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.