Skip to content

fix: add maximum nesting depth to CBOR decoder#340

Merged
jterapin merged 2 commits into
decaffrom
fix-cbor-codec
May 28, 2026
Merged

fix: add maximum nesting depth to CBOR decoder#340
jterapin merged 2 commits into
decaffrom
fix-cbor-codec

Conversation

@jterapin

Copy link
Copy Markdown
Contributor

Summary

  • Adds a depth counter to decode_item that raises ParseError when
    nesting exceeds 128 levels
  • Without this, a crafted payload of nested CBOR containers causes unbounded recursion, raising SystemStackError which escapes our rescue StandardError handler and crashes the process
  • ParseError inherits from StandardError, so it is caught cleanly

Context

Taken care of as part of oncall. Value of 128 chosen to match other Smithy-based SDKs (e.g. smithy-rs max_depth). No AWS service currently uses rpcv2Cbor, so practical exposure is zero today so this is a proactive fix before any service adopts it.

@jterapin jterapin merged commit b0b29d3 into decaf May 28, 2026
21 checks passed
@jterapin jterapin deleted the fix-cbor-codec branch May 28, 2026 16:38
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