fix(msgpack): Recursion limit#6212
Open
jjbayer wants to merge 3 commits into
Open
Conversation
The msgpack attachment path (extract_attached_event) deserializes an Event with rmp_serde, which enforces no recursion limit (unlike serde_json's 128-level cap). A ~200 KB payload of nested arrays, well under the 1 MiB max_event_size, drives Value deserialization ~200k frames deep and overflows the stack. The proof re-execs the test binary in a child process and asserts it is killed by a stack overflow, since the overflow aborts the process and cannot be caught in-thread. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rmp_serde enforces a recursion limit, but its default (1024) is too high for Relay's deeply generic types such as Annotated<Value>: each recursive deserialization frame is several KB, so a maliciously nested msgpack payload exhausts the thread stack and aborts the process well before the built-in counter trips. The max_event_size check (1 MiB) does not help, since nesting depth is unbounded far below the byte limit. Cap nesting at 128 (the same depth serde_json enforces by default) on all user-facing msgpack deserialization paths: attached events, msgpack breadcrumbs, replay video events, and event-id extraction. Deeply nested payloads are now rejected with an error instead of crashing. Invert the proof-of-vulnerability test into a regression test that asserts graceful rejection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jjbayer
commented
Jul 10, 2026
Co-authored-by: Joris Bayer <jjbayer@gmail.com>
Dav1dde
approved these changes
Jul 10, 2026
| let payload = item.payload(); | ||
| let mut deserializer = rmp_serde::Deserializer::new(payload.as_ref()); | ||
| // rmp_serde's default limit (1024) is too high for our types. | ||
| deserializer.set_max_depth(crate::utils::MSGPACK_MAX_DEPTH); |
Member
There was a problem hiding this comment.
We could make a function in the utils which must be used to construct the Deserializer which will also always have the limit applied.
Then we can put rmp_serde on the shit list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Impose a recursion limit of 128 on message pack deserialization.
Closes INGEST-990.