Skip to content

[25626] Limit nesting depth in type deserialization - #356

Open
David-LP99 wants to merge 2 commits into
masterfrom
bugfix/25626
Open

David-LP99 wants to merge 2 commits into
masterfrom
bugfix/25626

Conversation

@David-LP99

@David-LP99 David-LP99 commented Nov 16, 2026 •

Copy link
Copy Markdown

Description

Deserializing a type that contains itself through external<T> (e.g. XTypes TypeIdentifier) recurses once per nesting level, and the number of levels is controlled by the input. A crafted buffer can nest enough levels to exhaust the stack.

Cdr::deserialize_type now tracks the nesting depth per thread and throws BadParamException beyond 100 levels, far above any realistic type. All generated code goes through deserialize_type, so existing generated types are protected without regeneration.

Adds regression test XCdrExternalTest.max_nesting_depth.

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: CI pass and failing tests are unrelated with the changes.

Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>
Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>
@David-LP99 David-LP99 added this to the v2.4.1 milestone Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant