Skip to content

Reject COSE_Key decode into a mismatched wolfCrypt key object - #64

Merged
mattia-moffa merged 2 commits into
wolfSSL:mainfrom
aidangarske:fix-cosekey-decode-type-confusion
Jul 28, 2026
Merged

Reject COSE_Key decode into a mismatched wolfCrypt key object#64
mattia-moffa merged 2 commits into
wolfSSL:mainfrom
aidangarske:fix-cosekey-decode-type-confusion

Conversation

@aidangarske

@aidangarske aidangarske commented Jul 27, 2026

Copy link
Copy Markdown
Member

Description

  • wc_CoseKey_Decode() picked the wolfCrypt importer from the peer's CBOR, not from the key the caller attached.
  • WOLFCOSE_KEY stores that key in an untagged union, so the key. != NULL guards could not tell an ed25519_key from an ed448_key or an ecc_key.
  • A peer sending crv=Ed448 to an attached 112 byte ed25519_key ran the Ed448 importer and wrote past the object. kty=EC2 aimed the 4208 byte ecc_key importer at it. This runs before any signature check.
  • Adds WOLFCOSE_KEY.attachedType, set by the wc_CoseKey_Set*() functions, and matches every importer on it instead of the union member.
  • A decoded kty/crv that does not match the attached type now returns WOLFCOSE_E_COSE_KEY_TYPE before any import runs.
  • Verified against the reporter's PoCs with ASan, all now rejected. Full suite, force-failure, cmdline 30/30, and the NO_EDDSA, NO_ED448, and LEAN configs pass.
  • Reported by Omoikane Labs for ZD22200
  • also fixes static analysis error we have been seeing with wolfssl

Copilot AI review requested due to automatic review settings July 27, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@aidangarske aidangarske reopened this Jul 27, 2026
@aidangarske
aidangarske force-pushed the fix-cosekey-decode-type-confusion branch from ee0af0b to 035cb24 Compare July 27, 2026 20:02
@aidangarske
aidangarske force-pushed the fix-cosekey-decode-type-confusion branch from 035cb24 to 872a4cc Compare July 27, 2026 20:03
@mattia-moffa
mattia-moffa merged commit ff28105 into wolfSSL:main Jul 28, 2026
76 checks passed
@aidangarske
aidangarske deleted the fix-cosekey-decode-type-confusion branch July 28, 2026 22:06
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.

3 participants