Skip to content

fix: reject non-canonical ASN.1 INTEGER encodings#52

Merged
leopoldjoy merged 2 commits into
mainfrom
security/canonical-cert-integers
Jul 7, 2026
Merged

fix: reject non-canonical ASN.1 INTEGER encodings#52
leopoldjoy merged 2 commits into
mainfrom
security/canonical-cert-integers

Conversation

@leopoldjoy

Copy link
Copy Markdown
Contributor

Summary

  • centralize positive INTEGER parsing for uintAt and uint384At
  • reject empty INTEGERs, unnecessary leading zeroes, negative values, and overlong values after sign-byte stripping
  • preserve required DER sign padding and short P-384 scalar handling

Security value

This removes alternate encodings of the same ECDSA r/s or ASN.1 integer value, reducing certificate byte malleability and parser disagreement with DER-strict tooling.

Tests

  • forge fmt --check src test
  • forge test --match-contract 'Asn1DecodeTest|CertManagerTest' -vvv

Note

Latest main already fails test_DeployableContractsFitEIP170 locally with CertManager runtime bytes 24,708 > 24,576, so full-suite verification remains blocked by that pre-existing size issue.

leopoldjoy and others added 2 commits June 26, 2026 12:45
Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
@leopoldjoy leopoldjoy merged commit ac0c243 into main Jul 7, 2026
8 checks passed
@leopoldjoy leopoldjoy deleted the security/canonical-cert-integers branch July 7, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants