Skip to content

Ensure correct certificate is used for TSA auth checks (GHSA-xm5m-wgh2-rrg3)#1330

Open
Hayden-IO wants to merge 1 commit intomainfrom
vulnfix
Open

Ensure correct certificate is used for TSA auth checks (GHSA-xm5m-wgh2-rrg3)#1330
Hayden-IO wants to merge 1 commit intomainfrom
vulnfix

Conversation

@Hayden-IO
Copy link
Copy Markdown
Contributor

@Hayden-IO Hayden-IO commented Apr 8, 2026

verifyTSRWithChain and verifyLeafCert both need to find the signer (TSA) certificate from the PKCS7 certificate bag. Currently, if the bag has been injected with another leaf certificate, verifyLeafCert may use the wrong certificate to do authorization checks on.

  • Make verifyTSRWithChain return the correct signer certificate
  • modify verifyLeafCert so it uses the signer certificate chosen by verifyTSRWithChain
  • Refactor so that verifyTSRWithChain does two checks that were previously done later -- this guarantees that verifyTSRWithChain always returns the correct certificate or errors:
    • ensure that at an embedded certificate is found or one is provided as option (or both)
    • if a certificate is provided as option and there is an embedded certificate, ensure the two match

* Add test with TSR with injected cert

The added certificate is not part of the cert chain

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>

* Prevent verification with cert outside the cert chain

Currently VerifyLeafCert and verifyTSRWithChain may disagree
on which cert is the real leaf certificate (TSA certificate):
VerifyLeafCert should use the leaf certificate identified by
verifyTSRWithChain.

* Return the signer cert from verifyTSRWithChain() so
  verifyLeafCert() can just use the correct cert
* Make sure verifyTSRWithChain() ensures that we have signer cert
  (either embedded or provided as option)
* Make sure verifyTSRWithChain() verifies that embedded and
  provided cert match if both are present
* Modify verifyLeafCert() so it only operates on given leaf cert

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>

* Remove unused function

verifyEmbeddedLeafCert is now not needed: the check is already
done in verifyTSRWithChain.

Remove the related test, add test cases to cover the same
situatation in verifyTSRWithChain.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>

---------

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
@Hayden-IO Hayden-IO requested a review from a team as a code owner April 8, 2026 16:23
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.

2 participants