fix: verify PKCS7 signature on Azure instance identity tokens#25286
Merged
Conversation
3c8d98e to
c435ad1
Compare
spikecurtis
approved these changes
May 13, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Migrates Azure instance identity verification from
go.mozilla.org/pkcs7andgithub.com/fullsailor/pkcs7togithub.com/smallstep/pkcs7, usingVerifyWithChainAtTimeto validate both the PKCS7 signature and the certificate chain in one call. The previous code only verified the signer certificate against a set of intermediates/roots but did not verify that the PKCS7 signature itself covered the content, meaning tampered payloads could be accepted.The
Optionsstruct is restructured to acceptRoots,Intermediates, andCurrentTimeas explicit fields instead of embeddingx509.VerifyOptions. The test helperNewAzureInstanceIdentitynow builds a realistic 3-level certificate chain (Root CA -> Intermediate CA -> Signing Cert) matching real Azure trust hierarchy. New tests (TestValidate_TamperedContent,TestValidate_UntrustedCertWithValidSignature) confirm tampered and untrusted envelopes are rejected.Addresses GHSA-6x44-w3xg-hqqf.
Note
This PR was authored by Coder Agents.
Implementation Plan
Files Changed
coderd/azureidentity/azureidentity.gosigner.Verify()withVerifyWithChainAtTime; restructureOptionsstruct; addParseCertificates()helpercoderd/azureidentity/azureidentity_test.gotestCertChainbuilder, tampered-content and untrusted-cert tests; update existing tests for newOptionsAPIcoderd/coderd.goAzureCertificatesfield fromx509.VerifyOptionstoazureidentity.Optionscoderd/workspaceresourceauth.goapi.AzureCertificatesdirectly instead of wrappingcoderd/coderdtest/coderdtest.gosmallstep/pkcs7; build 3-level cert chain in test helpergo.mod/go.sumgithub.com/smallstep/pkcs7; removefullsailor/pkcs7andgo.mozilla.org/pkcs7