Skip to content
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

Tree::resolve() leaves some references in place in certain cases #400

Open
cbirkhold opened this issue Jan 27, 2024 · 1 comment
Open

Tree::resolve() leaves some references in place in certain cases #400

cbirkhold opened this issue Jan 27, 2024 · 1 comment

Comments

@cbirkhold
Copy link

Consider the following document:

a: &a
  x: 1
b: &b
  ref: *a
c:
  ref: *b

Tree:resolve() will result in:

a:
  x: 1
b:
  ref:
    x: 1
c:
  ref:
    ref: &a
      x: 1

Which is correct safe for the unintended remaining '&a' reference. This happens whenever referenced nodes contains further references. As the reference instantiation process creates copies of the entire referenced sub-tree, including any references, there are now references that are not part of the list of anchors and references created at the start of resolve() and which is used to remove them at the end of resolve() - leaving out the 'newly created' references.

Workaround: call resolve() again (this will collect the additional 'newly created' references and delete them).

@biojppm
Copy link
Owner

biojppm commented May 11, 2024

Thanks for reporting. References are notably unsafe; implementing an iterative resolve opens an attack vector to nasty attacks such as https://en.wikipedia.org/wiki/Billion_laughs_attack .

I am envisioning adding a parameter specifying the max number of resolve levels (defaulting to 1, ie equivalent to the current behavior). With this, the user will be responsible for picking the appropriate risk level.

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

No branches or pull requests

2 participants