Skip to content

fix: verify PKCS7 signature on Azure instance identity tokens#25286

Merged
jdomeracki-coder merged 1 commit into
mainfrom
security/ghsa-6x44-w3xg-hqqf
May 13, 2026
Merged

fix: verify PKCS7 signature on Azure instance identity tokens#25286
jdomeracki-coder merged 1 commit into
mainfrom
security/ghsa-6x44-w3xg-hqqf

Conversation

@jdomeracki-coder
Copy link
Copy Markdown
Contributor

@jdomeracki-coder jdomeracki-coder commented May 13, 2026

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.

Implementation Plan

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

@jdomeracki-coder jdomeracki-coder changed the title fix(coderd/azureidentity): verify PKCS7 signature on Azure instance identity tokens fix(coderd): verify PKCS7 signature on Azure instance identity tokens May 13, 2026
@jdomeracki-coder jdomeracki-coder changed the title fix(coderd): verify PKCS7 signature on Azure instance identity tokens fix: verify PKCS7 signature on Azure instance identity tokens May 13, 2026
@jdomeracki-coder jdomeracki-coder force-pushed the security/ghsa-6x44-w3xg-hqqf branch from 3c8d98e to c435ad1 Compare May 13, 2026 14:00
@jdomeracki-coder jdomeracki-coder marked this pull request as ready for review May 13, 2026 14:04
@jdomeracki-coder jdomeracki-coder enabled auto-merge (squash) May 13, 2026 14:12
@jdomeracki-coder jdomeracki-coder merged commit 1a1f06a into main May 13, 2026
31 checks passed
@jdomeracki-coder jdomeracki-coder deleted the security/ghsa-6x44-w3xg-hqqf branch May 13, 2026 14:14
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants