Problem/Motivation
The mint and OTP endpoints resolve the target file before they check whether the calling credential may mint the field that gates it. A named secret limited to one set of fields therefore gets three different answers:
- 404 "File not found." when the file UUID does not exist.
- 422 when the file exists and is not gated.
- 403 "This credential is not allowed to mint that file." when the file exists and is gated by a field outside the secret's scope.
A front end that holds only the secret for public collateral can use the difference to learn that a UUID belongs to a file gated by another class, for example a personnel document. File UUIDs are not guessable and the caller must hold a valid secret, so this is hardening and not an access bypass: no grant is issued and the refusal is audited.
Steps to reproduce
- Configure two named secrets, each allowed to mint a different gated field.
- With the first secret, call the mint endpoint for a file gated by the second secret's field. The response is 403.
- With the first secret, call the mint endpoint for a random UUID. The response is 404.
Proposed resolution
When a named secret is refused for field scope, return the same status and body as for a file that does not exist. Keep the mint_denied audit event with reason secret_scope and the warning log, so operators can still see the refusal. Apply the same rule to the OTP endpoint, which has the same check. A legacy unscoped secret is unaffected because it has no field scope.
Remaining tasks
- Failing tests first: out-of-scope existing file and missing file return identical responses for mint and OTP; the audit event is still written.
- Change the two controllers.
- Document the response change in the changelog. A client that branches on 403 from these endpoints needs to treat 404 as the refusal.
API changes
The mint and OTP endpoints return 404 instead of 403 for a field-scope refusal.
Comments
Comment #2
jmcerdaFixed on 1.x (commit 924ec51). The mint and OTP request endpoints now check a named secret's field scope before disclosing anything about the file, and a scope refusal returns the same 404 as an unknown file. The warning log and the mint_denied audit event with reason secret_scope are kept. ScopedSecretsTest asserts the two responses are identical, with and without the field named.
This changes a response status from 403 to 404, so it will ship in the next minor release. docs/API.md describes the new behaviour.
Not changed here: an unpublished media host still answers 409 before scope is known, and the OTP verify endpoint has no scope check. Either can get its own issue if needed.