Reject leaf certificates with root-path SPIFFE IDs in Verify - #405
Open
bcleenders wants to merge 2 commits into
Open
Reject leaf certificates with root-path SPIFFE IDs in Verify#405bcleenders wants to merge 2 commits into
bcleenders wants to merge 2 commits into
Conversation
bcleenders
force-pushed
the
require-non-root-path-in-spiffe-id
branch
2 times, most recently
from
July 23, 2026 11:17
e3a3aff to
173d1d4
Compare
[X509-SVID 5.2 Leaf Validation](https://github.com/spiffe/spiffe/blob/main/standards/X509-SVID.md#52-leaf-validation) requires certificates to have a non-root path component: > The validator [...] MUST ensure that the SPIFFE ID has a non-root path component. This test demonstrates that currently the Validator does not check this. I'll send a second commit that fixes this, but sending this as first commit to demonstrate the failure. Signed-off-by: bcleenders <bcleenders@spotify.com>
bcleenders
force-pushed
the
require-non-root-path-in-spiffe-id
branch
from
July 23, 2026 11:26
173d1d4 to
ae204ce
Compare
Author
|
I don't see test failures in CI, but locally I get: $ go test ./...
[...]
--- FAIL: TestVerify (0.00s)
--- FAIL: TestVerify/bad_leaf_no_non-root_path_SPIFFE_ID (0.00s)
verify_test.go:141:
Error Trace: /Users/bcleenders/src/github/spiffe/go-spiffe/svid/x509svid/verify_test.go:141
Error: An error is expected but got nil.
Test: TestVerify/bad_leaf_no_non-root_path_SPIFFE_ID
FAIL
FAIL github.com/spiffe/go-spiffe/v2/svid/x509svid 0.553s |
Verify had its own inline leaf validation that was an incomplete copy of validateLeafCertificate. Replacing it with a call to the shared function so both `Parse` and `Verify` enforce the same checks, including the non-root path requirement from X509-SVID 5.2. Signed-off-by: bcleenders <bcleenders@spotify.com>
bcleenders
marked this pull request as ready for review
July 23, 2026 11:33
bcleenders
requested review from
MarcosDY,
amartinezfayo,
azdagron and
evan2645
as code owners
July 23, 2026 11:33
bcleenders
commented
Jul 23, 2026
| chain: leaf1NoURI, | ||
| bundle: bundle1, | ||
| err: "x509svid: could not get leaf SPIFFE ID: certificate contains no URI SAN", | ||
| err: "x509svid: cannot get leaf certificate SPIFFE ID: certificate contains no URI SAN", |
Author
There was a problem hiding this comment.
Updating the error messages, to align with validateLeafCertificate.
Author
|
@amartinezfayo could you take a look? |
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.
Verify(and by extensionParseAndVerify) accepted leaf certificates whose SPIFFE ID had no path component (e.g.spiffe://example.org). X509-SVID spec section 5.2 requires that the leaf SPIFFE ID has a non-root path:This check already existed in
validateLeafCertificate, which is used byParse/ParseRaw/Load, butVerifyhad its own inline leaf checks that were an incomplete copy. The duplication also meantVerifywas missing thedigitalSignaturekey usage requirement.To avoid future inconsistencies between the two paths, this PR uses the same
validateLeafCertificatefunction as theParsepath uses.Related: #375
Spec reference: https://github.com/spiffe/spiffe/blob/main/standards/X509-SVID.md#52-leaf-validation