Skip to content

MOD-18588 - change cbor recurse limit - #24

Merged
TalBarYakar merged 2 commits into
masterfrom
tal.ba/feat/change_cbor_recurse_limit
Oct 7, 2026
Merged

TalBarYakar merged 2 commits into
masterfrom
tal.ba/feat/change_cbor_recurse_limit

Conversation

@TalBarYakar

@TalBarYakar TalBarYakar commented Oct 6, 2026 •

Copy link
Copy Markdown

Note

Medium Risk
Changes how deeply nested CBOR is accepted or rejected during decode, which can affect untrusted input handling and any code that relied on the old parser-only behavior.

Overview
CBOR decoding now applies a consistent depth cap at both the ciborium parse step and the IValue conversion step. decode still enforces the existing MAX_DEPTH (128), but routes through a new decode_with_depth_limit API that can turn that enforcement off.

The parser switches from from_reader to from_reader_with_recursion_limit, using MAX_DEPTH when limiting is on and mapping RecursionLimitExceeded to CborDecodeError::DepthLimitExceeded. cbor_to_ivalue only rejects on depth when limit_depth is true, so callers can decode legitimately deep trees when they opt out. decode_with_depth_limit is re-exported from the crate root; a unit test covers nested arrays that fail under default decode but succeed with limits disabled.

Reviewed by Cursor Bugbot for commit 678535e. Bugbot is set up for automated code reviews on this repo. Configure here.

@TalBarYakar TalBarYakar self-assigned this Oct 6, 2026

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 65aac9b. Configure here.

Comment thread src/cbor.rs Resolved
Comment thread src/cbor.rs
let recursion_limit = if limit_depth {
MAX_DEPTH as usize
} else {
usize::MAX

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

?
cant it be an option?
if from_reader_with_recursion_limit must recive usize call it only when you have limit_depth=true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

no
when the flag is turn off we don't want to enforce the default 256 depth , but we want to have MAX_UNIT

@TalBarYakar
TalBarYakar merged commit edef94d into master Oct 7, 2026
6 checks passed
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