Repository navigation
fix: No recursion depth limit in decode_internal / resolve_internal / serde deserializer - #642
Merged
martin-g merged 4 commits intoAug 26, 2026
Conversation
martin-g
force-pushed
the
recursion-depth-check-decoding-deserializing
branch
from
August 25, 2026 12:50
658b8a3 to
0fe84cd
Compare
Kriskras99
requested changes
Aug 26, 2026
| /// data: a recursive schema lets an attacker drive one recursion level with roughly one wire byte. | ||
| /// | ||
| /// See [`max_decode_recursion_depth`] to change this limit. | ||
| pub const DEFAULT_MAX_DECODE_RECURSION_DEPTH: usize = 32; |
Contributor
There was a problem hiding this comment.
At 62 the decode::tests::avro_rs_642_resolve_recursion_depth_is_bounded test overflows.
At 558(!) the recursion_depth_deser::avro_rs_642_recursion_depth_is_bounded test overflows.
So I think there might be some optimisation room left for the decode implementation (not for this PR obviously).
Contributor
There was a problem hiding this comment.
This should also increment the recursion depth as it does not use new
Member
Author
There was a problem hiding this comment.
Done!
Thanks for catching this!
Comment on lines
+102
to
+106
| config.recursion_depth += 1; | ||
| let maximum = decode_recursion_limit(); | ||
| if config.recursion_depth > maximum { | ||
| return Err(Details::DecodeRecursionLimit { maximum }.into()); | ||
| } |
Contributor
There was a problem hiding this comment.
I think it would be better to split this off into an implementation on Config, otherwise this would need to be duplicated in with_different_schema
martin-g
force-pushed
the
recursion-depth-check-decoding-deserializing
branch
from
August 26, 2026 09:55
0fe84cd to
a965dd4
Compare
… serde deserializer A recursive schema can lead to stack overflow (i.e. an abort) in OCF decoding, Value resolving and Schema deserialization. Add `util::max_decode_recursion_depth(usize)` to be able to control the recursipn depth Reported-by: Security scans
Co-authored-by: Kriskras99 <[email protected]>
Co-authored-by: Kriskras99 <[email protected]>
martin-g
force-pushed
the
recursion-depth-check-decoding-deserializing
branch
from
August 26, 2026 11:13
7d282f0 to
48d1fbc
Compare
Kriskras99
approved these changes
Aug 26, 2026
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.
A recursive schema can lead to stack overflow (i.e. an abort) in OCF decoding, Value resolving and Schema deserialization. Add
util::max_decode_recursion_depth(usize)to be able to control the recursipn depthReported-by: Security scans