Context
We are evaluating cbor@6.5.1 for verifying signed RFC 8949 deterministic
CBOR received from an untrusted network. The current package is useful as a
general codec, but application validation after ordinary Dart object
construction cannot recover duplicate map keys and does not bound hostile
input before allocation.
Would you be open to an opt-in strict decoder mode? Existing permissive behavior
could remain the default.
Requested controls
A strict options object would ideally support:
- reject duplicate map keys before map construction;
- require RFC 8949 Section 4.2.1 bytewise-lexicographic map-key order;
- require preferred/shortest integer, length, and simple-value encodings;
- reject indefinite-length items;
- optionally reject tags, floats, null, and undefined;
- eagerly reject invalid UTF-8 without replacement characters;
- require exactly one fully consumed top-level item; and
- enforce finite limits for input bytes, nesting depth, map entries, array
entries, text/byte-string bytes, and total decoded items before excessive
allocation or recursion.
On failure, it would help to return no partial decoded value and expose one
documented exception type with a stable reason category and byte offset. Useful
categories could include malformed, nonPreferred, duplicateKey,
mapOrder, disallowedType, invalidUtf8, trailingData, and
resourceLimit.
Important ordering detail
The deterministic profile is RFC 8949 Section 4.2.1, not the Section 4.2.3
length-first alternative. A regression could require the mixed-key order 10,
100, -1, whose deterministic encodings begin 0a, 1864, 20.
Why decoder-level support matters
Deterministically re-encoding and comparing bytes is still useful, but it
cannot detect duplicate keys after a Dart map has already collapsed them.
Similarly, application-level collection checks happen too late to prevent
parser allocation. These properties therefore need tokenizer/decoder support.
Is this direction compatible with the package's design? We can adapt to the
maintainer's preferred API shape and provide focused valid/invalid fixtures for
discussion.
Context
We are evaluating
cbor@6.5.1for verifying signed RFC 8949 deterministicCBOR received from an untrusted network. The current package is useful as a
general codec, but application validation after ordinary Dart object
construction cannot recover duplicate map keys and does not bound hostile
input before allocation.
Would you be open to an opt-in strict decoder mode? Existing permissive behavior
could remain the default.
Requested controls
A strict options object would ideally support:
entries, text/byte-string bytes, and total decoded items before excessive
allocation or recursion.
On failure, it would help to return no partial decoded value and expose one
documented exception type with a stable reason category and byte offset. Useful
categories could include
malformed,nonPreferred,duplicateKey,mapOrder,disallowedType,invalidUtf8,trailingData, andresourceLimit.Important ordering detail
The deterministic profile is RFC 8949 Section 4.2.1, not the Section 4.2.3
length-first alternative. A regression could require the mixed-key order
10,100,-1, whose deterministic encodings begin0a,1864,20.Why decoder-level support matters
Deterministically re-encoding and comparing bytes is still useful, but it
cannot detect duplicate keys after a Dart map has already collapsed them.
Similarly, application-level collection checks happen too late to prevent
parser allocation. These properties therefore need tokenizer/decoder support.
Is this direction compatible with the package's design? We can adapt to the
maintainer's preferred API shape and provide focused valid/invalid fixtures for
discussion.