-
Notifications
You must be signed in to change notification settings - Fork 56
fix(dpp): bound document value validation depth #4115
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: v4.1-dev
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -797,7 +797,14 @@ impl StateTransition { | |
| bytes: &[u8], | ||
| platform_version: &PlatformVersion, | ||
| ) -> Result<Self, ProtocolError> { | ||
| let state_transition = StateTransition::deserialize_from_bytes(bytes)?; | ||
| let max_value_depth = platform_version | ||
| .system_limits | ||
| .max_document_value_depth | ||
| .map(usize::from); | ||
| let state_transition = | ||
| platform_value::with_value_decode_depth_limit(max_value_depth, || { | ||
| StateTransition::deserialize_from_bytes(bytes) | ||
| })?; | ||
|
Comment on lines
+800
to
+807
Collaborator
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. 🔴 Blocking: Keep all over-depth documents on the same consensus path The decoder applies source: ['codex'] |
||
| #[cfg(all(feature = "state-transitions", feature = "validation"))] | ||
| { | ||
| let active_version_range = state_transition.active_version_range(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Enforce the depth limit during decoding
This validation runs after attacker-controlled document values have already undergone recursive processing. An actual document-batch state transition containing 4,000 single-element arrays encoded to 8,149 bytes, below the 20,480-byte transition limit, and aborted with a stack overflow inside
StateTransition::deserialize_from_bytes.Valuederives recursiveDecode, so the transition never reaches this deterministicValueError. Values that survive decoding are also recursively cloned while create/replace actions are built and again whenself.data().into()prepares validation. Enforce the depth budget in a custom or iterative decoder, then check borrowed transition data before action transformation performs recursive clones.source: ['codex']