-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Security issue: Parsing malicious or large YAML documents can consume excessive amounts of CPU or memory. #461
Comments
This issue is likely resolved, and decoding no longer unnecessarily consumes memory or CPU. However, when encoding large values, resource consumption will increase proportionally to the size of those values. |
I tested the program above, and it makes the CPU fans hit the roof on my beefy MacBook Pro M1 with 32GB ram. I eventually had to kill the process. |
@bep I think that it is not being consumed during decoding but rather when writing out the value after decoding. This should occur not only during encoding but even with a simple |
@goccy OK, I didn't read your comment correctly. You are right that the decoding part doesn't "blow up", but for this library to be useful for end user input, there need to be some kind of decoder protection against input like the above. |
@bep The decoder has already done the job correctly. The alias is all references, so the object in memory is not large. It just requires a lot of memory when writing it out. Also, this example does not consume the stack, but guards are already in place to prevent stack overflow. |
Improper input validation allows to parse malicious YAML payloads, causing the server to consume excessive CPU or memory, potentially crashing and becoming unavailable.
How to reproduce
The following .yaml file will be unmarshalled into several GB.
Expected behavior
Some checks should be implemented to prevent excessive memory usage.
See Add large document benchmarks, tune alias heuristic, add max depth limits #515 and go-yaml/yaml/blob/v3/decode.go.
Version Variables
Additional context
CVE-2022-3064
GHSA-6q6q-88xp-6f2r
The text was updated successfully, but these errors were encountered: