You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(id-core): canonical CBOR encoders accept values their decoders reject #11315
The canonical CBOR encoders do not enforce the nesting-depth limit enforced by their decoders. Rust's encode_into recurses through arrays and map values without a depth parameter or guard (pkgs/id/crates/id-core/src/canonical_cbor.rs:132-179), while Reader::value_inner rejects depth greater than MAX_NESTING_DEPTH (64, :194-199, :270-273). The TypeScript mirror has the same mismatch: encodeInto recurses without a limit (pkgs/id/hosted-worker/src/canonical-cbor.ts:79-127), but Reader.valueInner rejects over-depth values (:184-185).
Consequently, a caller-built value with 65 nested arrays can be encoded successfully, but decoding those bytes returns TooDeeplyNested. Still deeper caller-built values recurse without a bound during encoding and can exhaust the stack. This breaks the encoder/decoder round-trip contract and leaves the producer path without the decoder's stack-safety bound.
Requested change
Apply the same depth policy to both encoders and return the existing typed TooDeeplyNested error when a value exceeds it. Add Rust and TypeScript tests for the boundary and over-limit nesting, including parity between the implementations.
Related work
Closed #2121 addresses unbounded nesting in a different ID tuple decoder. It does not cover these canonical CBOR encoders. No open issue or PR specifically tracking this encoder/decoder mismatch was found in the dedupe search.
Activity
developing-today commentedon Nov 17, 2026
CODE-4110