-
Notifications
You must be signed in to change notification settings - Fork 0
feat(interop): pin untrusted-decode bounds as a cross-SDK invariant (LAB-2503) #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bb8feb8
a4bda44
277db51
2d56cce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,9 +264,9 @@ bytes are therefore | |
|
|
||
| - A conforming reader MUST decompress every pinned vector's `compressed_data` | ||
| to its pinned input, **and MUST enforce [Retrieve Flow](#retrieve-flow) steps | ||
| 4, 5 and 9 while doing so.** Read-side conformance is not "the vectors pass": | ||
| 2, 4, 5 and 9 while doing so.** Read-side conformance is not "the vectors pass": | ||
| every pinned vector is well-formed and declares a truthful `original_size`, so | ||
| they evidence **none** of those bounds, and a reader that omits all three | ||
| they evidence **none** of those bounds, and a reader that omits all four | ||
| decompresses all of them successfully. The vectors prove decode | ||
| interoperability; the bounds in [Security Limits](#security-limits) are a | ||
| separate, non-negotiable obligation that no fixture can demonstrate. | ||
|
|
@@ -376,8 +376,13 @@ let checksum: [u8; 8] = xxh3_64(&original_data).to_be_bytes(); | |
| > Additionally, a decoder MUST validate any declared MessagePack `bin`/array | ||
| > length header against the remaining input bytes **before** allocating for it — | ||
| > a 5-byte `bin32` header can otherwise declare a 4 GiB allocation from a | ||
| > ~30-byte envelope. (Slice-based decoders such as `rmp-serde` satisfy this | ||
| > inherently; readers that pre-allocate from length fields must check.) | ||
| > ~30-byte envelope. No decoder satisfies this inherently — even slice-based | ||
| > ones pre-allocate collections from declared lengths. The envelope bytes *and* | ||
| > the payload inside them | ||
| > are both untrusted MessagePack — decode each under the depth and allocation | ||
| > rules in [interop-mode.md → Decode bounds](interop-mode.md#decode-bounds), | ||
| > pinned by `test-vectors/decode-bounds.json`, running the structural pre-scan | ||
| > before materialising `StorageEnvelope`. | ||
|
|
||
| | Limit | Value | Purpose | | ||
| | :--- | ---: | :--- | | ||
|
|
@@ -439,7 +444,8 @@ Input: raw_data (bytes), format (string, default "msgpack") | |
| Input: envelope_bytes | ||
|
|
||
| 1. Validate: envelope_bytes.length <= 512 MiB | ||
| 2. Deserialize: envelope = msgpack_decode(envelope_bytes) as StorageEnvelope | ||
| 2. Deserialize: pre-scan envelope_bytes (decode bounds, see Security Limits), then | ||
| envelope = msgpack_decode(envelope_bytes) as StorageEnvelope | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Violates team rule 'Avoid unsafe type assertions': Detect cases of unsafe type assertions. These do not perform runtime checks and can lead to unexpected runtime errors. Recommend using proper type guards instead. Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| // accept BOTH element[0] encodings: bin AND array-of-ints | ||
| 3. Validate: envelope.compressed_data.length <= 512 MiB | ||
| 4. Validate: envelope.original_size <= 512 MiB | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.