Move ExtKeyUsageAny setting outside intermediates check in TPM cert verified#234
Merged
Conversation
betuls
reviewed
Jun 26, 2026
betuls
left a comment
Contributor
There was a problem hiding this comment.
LGTM but please make the suggested text changes.
…erifier Moves the x509.ExtKeyUsageAny setting in VerifyOptions outside the intermediates check in VerifyAndParsePemCert, ensuring it applies unconditionally to avoid breaking enrollment for single-certificate inputs. BUG=522385740 TAG=agy CONV=47e03344-e537-4294-a332-8792b7bba5f4
betuls
approved these changes
Jul 7, 2026
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.
Moves the x509.ExtKeyUsageAny setting in VerifyOptions outside the intermediates check in VerifyAndParsePemCert, ensuring it applies unconditionally to avoid breaking enrollment for single-certificate inputs.
Temp fix for vulnerability:
The VerifyAndParsePemCert function in service/biz/tpm_cert_verifier.go unconditionally overrides certVerificationOpts.KeyUsages to ExtKeyUsageAny when the device-supplied PEM input contains more than one certificate block (line 297). A device participating in TPM enrollment can include an additional PEM block to trigger this code path, causing certificate verification to accept certificates issued for any purpose (e.g., code signing, email protection) rather than enforcing the default ExtKeyUsageServerAuth restriction. This could allow an unauthorized device holding a cross-purpose certificate from a trusted CA to pass identity verification and complete TPM enrollment.
Root Cause
The KeyUsages override to ExtKeyUsageAny is coupled to the intermediate certificate pool construction inside the len(certs) > 1 conditional block at line 297. These are two independent operations — adding intermediates for chain validation and setting the ExtKeyUsage policy — but they are tied to the same attacker-controlled toggle (number of PEM blocks in the device response), creating an inconsistent validation policy based on untrusted input.