Skip to content

Limit CBOR depth#7838

Merged
maxtropets merged 2 commits intomicrosoft:mainfrom
maxtropets:f/fix-undefined-cbor-deepness
Apr 27, 2026
Merged

Limit CBOR depth#7838
maxtropets merged 2 commits intomicrosoft:mainfrom
maxtropets:f/fix-undefined-cbor-deepness

Conversation

@maxtropets
Copy link
Copy Markdown
Collaborator

@maxtropets maxtropets commented Apr 27, 2026

Parsing CBOR of undefined depth or roughly 10k+ can overflow. This PRs adds a safety barrier to only parse reasonably deep CBORs, while still allows to go deeper with a newly added function parameter.

@maxtropets maxtropets self-assigned this Apr 27, 2026
Copilot AI review requested due to automatic review settings April 27, 2026 10:09
@maxtropets maxtropets requested a review from a team as a code owner April 27, 2026 10:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable nesting-depth limit to the internal CBOR parser/serializer to prevent stack overflow from adversarially (or accidentally) deeply-nested CBOR, with coverage in the CBOR unit tests.

Changes:

  • Add max_depth parameter (default 16) to ccf::cbor::parse and ccf::cbor::serialize.
  • Enforce depth checks during CBOR decode (consume*) and encode (to_raw_*) recursion, throwing on exceed.
  • Add unit tests validating parse/serialize behavior at and beyond configured depth limits.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/crypto/cbor.h Extends CBOR parse/serialize API with a max_depth parameter (default 16).
src/crypto/cbor.cpp Implements max-depth enforcement in recursive decode/encode helpers.
src/crypto/test/cbor.cpp Adds tests for max-depth behavior in parsing and serialization.

@maxtropets maxtropets enabled auto-merge (squash) April 27, 2026 10:21
@maxtropets maxtropets changed the title Limit CBOR deepness Limit CBOR deptyh Apr 27, 2026
@maxtropets maxtropets changed the title Limit CBOR deptyh Limit CBOR depth Apr 27, 2026
@maxtropets maxtropets merged commit acbde65 into microsoft:main Apr 27, 2026
19 checks passed
@cjen1-msft cjen1-msft mentioned this pull request Apr 27, 2026
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