Verify PKCS7 signature on Azure instance identity tokens

fix: verify PKCS7 signature on Azure instance identity tokens (#25286)
Verify PKCS7 signature on Azure instance identity tokens1a1f06-fix-verify-pkcs7-signature-on-azure-instance-cve-2026-46354fixverify pkcs7 signature azure instance identity

Committed by jdomeracki-coder

commit message
fix: verify PKCS7 signature on Azure instance identity tokens (#25286)

Migrates Azure instance identity verification from
`go.mozilla.org/pkcs7` and `github.com/fullsailor/pkcs7` to
`github.com/smallstep/pkcs7`, using `VerifyWithChainAtTime` to 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 `Options` struct is restructured to accept `Roots`, `Intermediates`,
and `CurrentTime` as explicit fields instead of embedding
`x509.VerifyOptions`. The test helper `NewAzureInstanceIdentity` now
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.
 
<details>
<summary>Implementation Plan</summary>
 
### Files Changed
 
| File | Summary |
|------|---------|
| `coderd/azureidentity/azureidentity.go` | Replace `signer.Verify()`
with `VerifyWithChainAtTime`; restructure `Options` struct; add
`ParseCertificates()` helper |
| `coderd/azureidentity/azureidentity_test.go` | Add `testCertChain`
builder, tampered-content and untrusted-cert tests; update existing
tests for new `Options` API |
| `coderd/coderd.go` | Change `AzureCertificates` field from
`x509.VerifyOptions` to `azureidentity.Options` |
| `coderd/workspaceresourceauth.go` | Pass `api.AzureCertificates`
directly instead of wrapping |
| `coderd/coderdtest/coderdtest.go` | Migrate to `smallstep/pkcs7`;
build 3-level cert chain in test helper |
| `go.mod` / `go.sum` | Add `github.com/smallstep/pkcs7`; remove
`fullsailor/pkcs7` and `go.mozilla.org/pkcs7` |
 
</details>

Editor assessment

This commit patches CVE-2026-46354. The subject states the security outcome, verifying the PKCS7 signature on Azure instance identity tokens, without a scope that would have named azureidentity. The body is strong: it explains the migration to smallstep/pkcs7, that VerifyWithChainAtTime checks signature and chain together, and that the old code validated certificates but never the signature over content, so tampered payloads passed. It also documents the Options restructuring, the realistic three-level test chain, and the two new negative tests, plus an Addresses line for the advisory. The trailing implementation-plan table is extra weight, and scope is missing.

Browse categories

More fix examples · Back to search