Skip to content

Guard rfl::yaml::Reader against recursive aliases and out-of-bounds literal marks - #72

Open
clockblocker wants to merge 1 commit into
mainfrom
yaml-recursive-alias-guard
Open

clockblocker wants to merge 1 commit into
mainfrom
yaml-recursive-alias-guard

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Split out from #42 onto main as an independent safety/bugfix PR:

  • Tracks active ancestor YAML nodes via a thread-local RAII guard (ActiveNodeGuard in src/rfl/yaml/Reader.cpp) across read_object and read_array so cyclic YAML aliases return an rfl::Error instead of causing a stack-overflow DoS, while allowing non-cyclic (DAG) alias reuse and keeping const Reader thread-safe.
  • Bounds-checks YAML::Mark::pos before indexing yaml_str_ when trimming trailing newlines on literal block scalars.

Motivation

Without these guards, untrusted YAML input with a self-referential alias (e.g., &a [*a]) crashes rfl::yaml::Reader via stack overflow, and malformed/out-of-range YAML::Mark::pos values on literal block scalars can trigger an out-of-bounds read.

Verification

  • Built with Ninja (-O3 -Wall -Werror) and ran all YAML tests via ctest (including tests/yaml/test_recursive_alias.cpp).

…iteral marks

Track ancestor YAML nodes via a thread-local RAII guard (ActiveNodeGuard in
src/rfl/yaml/Reader.cpp) across read_object and read_array so cyclic YAML
aliases return an rfl::Error instead of overflowing the stack, while keeping
const Reader instances thread-safe and allowing non-cyclic (DAG) alias reuse.

Also bounds-check YAML::Mark::pos before indexing yaml_str_ when trimming
trailing newlines on literal block scalars.
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