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

Fix emitter states handling when write_indicator fails #290

Closed
wants to merge 1 commit into from

Conversation

perlpunk
Copy link
Member

@perlpunk perlpunk commented Apr 8, 2024

There are cases where yaml_emitter_write_indicator fails. In that case POP is called on emitter->indents but not on emitter->states, which results in a leftover event in the stack, and later POP is called on an empty emitter->indents stack.

This commit does not fix the case of the failing yaml_emitter_write_indicator. This is still investigated.

This will mitigate CVE-2024-3205

@perlpunk
Copy link
Member Author

perlpunk commented Apr 8, 2024

apparently some tests are failing, so there are cases where this is wrong... looking...

edit: fixed syntax issue

@zhuofeng6
Copy link

That's great. i think it is a more general fix for this. So can we merge it?

Copy link

@Martchus Martchus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the code but as far as I can see this makes sense.

@perlpunk
Copy link
Member Author

perlpunk commented Apr 9, 2024

Probably the emitter->state = POP(emitter, emitter->states); can be done directly after the POP on indents, instead of 3 times in different places.
I don't know why @xitology put it in that order. I can't imagine a case where it would be correct to only pop from indents.

There are cases where yaml_emitter_write_indicator fails.
In that case POP is called on emitter->indents but not on emitter->states,
which results in a leftover event in the stack, and later POP is called
on an empty emitter->indents stack.

This commit does not fix the case of the failing yaml_emitter_write_indicator.
This is still investigated.
@perlpunk
Copy link
Member Author

perlpunk commented Apr 9, 2024

I moved the POP now directly after the indents POP statement. That should have the same effect.

@perlpunk perlpunk requested a review from ingydotnet April 9, 2024 13:00
@ingydotnet
Copy link
Member

I'm currently extremely busy but I'll try to review this soon.

@zhuofeng6
Copy link

This is a high score cve, which has a great impact on the libyaml community. If possible, it is necessary to merge this pr as soon as possible. This is my humble opinion

@frenzymadness
Copy link

The CVSS score for this vulnerability says that the attack complexity is low and the attract vector is the network (which means almost anybody can use this vulnerability to attack a system via a network). From the discussions here, I have a very different feeling. Even the maintainers of the software itself have a hard time exploiting/reproducing the vulnerability. It's either easy to reproduce or the score and therefore the severity of the vulnerability is wrong.

@perlpunk
Copy link
Member Author

Note that the reproducers I found use the canonical mode, which is probably rarely used. But I think it could be possible to produce the same effect without canonical mode, and possibly someone already knows the necessary input for that.

@perlpunk
Copy link
Member Author

Please see my update that I don't consider it a vulnerability: #258 (comment)

@zhuofeng6
Copy link

zhuofeng6 commented Apr 17, 2024

I agree with you. I don't think this is a cve either. but now does this PR still need to be merged?

@perlpunk
Copy link
Member Author

perlpunk commented Apr 17, 2024

I think the PR an improvement, but I would rather try to check in yaml_emitter_close if the emitter is in an error state. probably I can just check if an error was set.
just very busy in the middle of two conferences, and it's not urgent IMHO

@perlpunk
Copy link
Member Author

I will create a different PR when I have time

@perlpunk perlpunk closed this Apr 18, 2024
@perlpunk perlpunk deleted the fix-emitter-state branch May 20, 2024 23:27
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.

5 participants