Repository navigation
id(tuple): cap nested tuple decode depth at 64 - #4083
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🤖 Agent note · parked
|
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #2121
tuple::decoderecursed on every NESTED tag with no depth limit. The decoder is reached for peer-written iroh-docs entry keys (tag alpha/omega keys), so a crafted ~100 KB key with ~50k nested tags aborted the process with a stack overflow instead of returning an error.Change (
pkgs/id/crates/id-core/src/tuple.rs— the module moved here in the id-core crate split; the unbounded recursion was identical)pub const MAX_TUPLE_NESTING_DEPTH: usize = 64, matching the peer-CBORRECURSION_LIMIT = 64inchain.rs.decode_one; a nested element beyond the cap returns an ordinaryanyhowerror before recursing further. Alpha/omega tag-key decoders get this automatically since they calltuple::decode.TupleEncoderstays infallible and can encode deeper thandecodeaccepts — no breaking change to its public signature in this fix.Tests (new, in-module)
test_decode_at_nesting_limit_roundtrips— exactly 64 nested tuples decode and walk down to the innermost value.test_decode_one_over_nesting_limit_errors— 65 nested tuples returnErr.test_decode_hostile_depth_errors_on_small_stack— 50k NESTED bytes decode on a 2 MiB-stack thread and returnErrinstead of aborting.Existing tuple/tag tests run in CI on this PR (CI-first verification; no local build run — laptop load was >50 during this shift and local fleet builds are banned by policy in favour of Actions).
Queue: task 5100 (repo-health-code-pilot), lane F.
Need help on this PR? Tag
@codesmith-botwith what you need.