Fix EKU parsing for five-octet Azure OID arcs - #33
Open
nurfed1 wants to merge 2 commits into
Open
Conversation
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.
Problem
Azure Artifact Signing certificates include profile-specific EKUs alongside
id-kp-codeSigning. Some arcs in the Azure identity EKUs are greater than2^28 - 1, so their valid base-128 DER representation requires five octets. The values still fit inu32; they are not oversized OID arcs.For example, the affected certificates contain identity EKUs such as:
1.3.6.1.4.1.311.97.1.2.548345392.570456524.348779735.6284937691.3.6.1.4.1.311.97.872172236.817999856.585183201.971782747The portable trust path currently decodes the complete EKU sequence through
x509-cert 0.2.5/der 0.7/const-oid 0.9.6. Thatconst-oidversion calculates the maximum encoded arc length as the byte width ofu32(four), rather than the five base-128 octets needed to represent allu32values. As a result, decoding fails on the unrelated Azure identity EKU before psign can observe the ordinary code-signing EKU.RustCrypto fixed the underlying arc-length calculation in RustCrypto/formats#1592.
Change
This changes only the strict code-signing EKU presence check in the portable CMS fallback. Instead of materializing every EKU as a fixed-width
ObjectIdentifier, it:SEQUENCE, rejecting trailing data;OBJECT IDENTIFIER;id-kp-codeSigning.The parser continues validating entries after finding
id-kp-codeSigning, so a matching entry cannot hide a malformed later entry.This does not disable or weaken strict signing-certificate validation. In particular, it avoids requiring
--allow-loose-signing-cert, which bypasses the EKU requirement rather than addressing the decode failure. Trust-anchor selection, chain validation, and the required code-signing EKU are unchanged.Why this is a compatibility bridge
The long-term fix is to move psign's RustCrypto CMS/X.509 dependency graph to versions using the corrected
const-oidimplementation. That cannot currently be done as an isolated direct dependency bump:authenticode-rs's directconst-oiddependency, but thecms 0.2/x509-cert 0.2path still retainsconst-oid 0.9.x509-certalone leaves incompatiblex509-cert 0.2and0.3certificate types becausecms 0.2still uses the older stack.cms,der,spki,x509-cert, andauthenticode-rsmigration currently involves prerelease APIs.This scoped parser is therefore intended as a temporary compatibility fix. It can be removed in favor of the normal
ExtendedKeyUsagedecoder once that dependency stack can be upgraded together.Tests and validation
Unit tests cover:
id-kp-codeSigning;u32, which are safe to skip because they are never materialized;Validation performed:
cargo fmt --all -- --checkci-unix.yml, with-D warningscargo test --workspace --lib --bins --locked