Repository navigation
fix(httpapi): refuse config-to-secret for values that embed a reference - #1782
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
The guard only rejected values starting with ${keyring: or ${env:. A
${file:...} reference, or a composite such as "Bearer ${keyring:gh}",
was stored in the keyring as literal text and the field was rewritten
to ${keyring:<name>}. Resolution is single-pass, so the upstream then
received the unresolved reference text as its credential.
Use secret.IsSecretRef so any value containing a reference is refused.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
POST /api/v1/servers/{id}/config-to-secretrefuses to convert a value that is already a reference, but the check isstrings.HasPrefix(value, "${keyring:") || strings.HasPrefix(value, "${env:"). Two kinds of values get past it:${file:/path}reference (the provider added in feat(secret): ${file:/absolute/path} references (Spec 111 FR-030) #1717);"Authorization": "Bearer ${keyring:github-token}"(docs/features/keyring-integration.md).For these values the handler stores the literal text in the keyring and rewrites the field to
${keyring:<secret_name>}. Secret expansion runs once, so on the next connect the upstream gets the unresolved text, for exampleBearer ${keyring:github-token}or${file:/run/secrets/github-token}, as its credential.The API masks both values on the read path because
IsConfigReferenceonly passes through an exact${keyring:..}or${env:..}value. The UI therefore shows them as plain secrets and offers Convert-to-secret.Trigger
POST /api/v1/servers/<name>/config-to-secretwith{"scope":"header","key":"Authorization","secret_name":"gh2"}succeeds. After that, the header sent upstream is the literalBearer ${keyring:github-token}.Fix
Use
secret.IsSecretRef(value), which matches any${type:name}reference anywhere in the value. The handler then returns the existing 400 "already a reference" error for these values.Test
Two cases added to
TestHandleConvertConfigToSecret_ValidationErrors: an env value${file:/run/secrets/github-token}and a headerBearer ${keyring:github-token}. Both must be rejected with 400 before the resolver is called.Commands run
CGO_ENABLED=0 go test -count=1 ./internal/httpapi: okserver.goreverted, both new cases fail (expected: 400, actual: 500). The handler gets past validation and reaches the resolver, which the mock leaves nil.go vet ./internal/httpapi,gofmt -l internal/httpapi/: clean