Skip to content

fix(provider): validate peer chain before invoking SpiffeIdVerifier#449

Open
bcleenders wants to merge 1 commit into
spiffe:mainfrom
bcleenders:fix/verifier-ordering-main
Open

fix(provider): validate peer chain before invoking SpiffeIdVerifier#449
bcleenders wants to merge 1 commit into
spiffe:mainfrom
bcleenders:fix/verifier-ordering-main

Conversation

@bcleenders

Copy link
Copy Markdown

SpiffeTrustManager invoked the SpiffeIdVerifier before any cryptographic validation.
The callback received an unvalidated, attacker-supplied chain despite the verifier's API spec calling it verifiedChain.

Validate the chain against the trust bundle first and only then invoke the verifier.

This matches go-spiffe, where the Authorizer only receives chains returned by x509svid.ParseAndVerify (ParseAndVerify first checks the certificates, afterwards Authorizer checks if the SPIFFE ID is authorized).

Observable change: for a chain that is both untrusted and carries an unacceptable SPIFFE ID, the reported error is now the chain validation failure, rather than the verifier error.

There is a small conflict on imports with #433 , so if you poke me after that one is merged, I'm happy to rebase.

`SpiffeTrustManager` invoked the `SpiffeIdVerifier` before any
cryptographic validation.
The callback received an unvalidated, attacker-supplied chain despite the verifier's [API spec calling it `verifiedChain`](https://github.com/spiffe/java-spiffe/blob/55200fc8e6b01f9da5951c379e4f4187d7f920b7/java-spiffe-provider/src/main/java/io/spiffe/provider/SpiffeIdVerifier.java#L13).

Validate the chain against the trust bundle first and only then invoke the verifier.

This matches go-spiffe, where [the `Authorizer` only receives chains returned by `x509svid.ParseAndVerify`](https://github.com/spiffe/go-spiffe/blob/v2.8.1/spiffetls/tlsconfig/config.go#L193-L201) (`ParseAndVerify` first checks the certificates, afterwards `Authorizer` checks if the SPIFFE ID is authorized).

Observable change: for a chain that is both untrusted and carries an unacceptable SPIFFE ID, the reported error is now the chain validation failure, rather than the verifier error.

There is a small conflict on imports with spiffe#433 , so if you poke me after that one is merged, I'm happy to rebase.

Signed-off-by: bcleenders <[email protected]>
@bcleenders
bcleenders force-pushed the fix/verifier-ordering-main branch from 077a494 to f61791b Compare July 22, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant