Converting string to enum at the cost of 50 GB: let's analyze the CVE-2020-36620 vulnerability
The EnumStringValues NuGet package cached every unique input string, including those that failed to parse, in a static dictionary. An attacker could send many unique strings to cause unbounded memory growth and a denial of service.
pvs-studio.com
Published on pvs-studio.com
#CSharp #Security
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The library cached every input string, including failed parses, in a static dictionary without any size limit or eviction.
Impact
An attacker could cause a denial of service by exhausting the application's memory through repeated unique string inputs.
What the attacker needed
Application uses EnumStringValues 4.0.0; attacker can supply unique strings to the parsing function
The fix
The fix removed caching of input values; the cache is now pre-filled only with the enum's known string representations, and input strings are only looked up, not added.
How it was found
- The application receives a string from the user and calls the library's TryParseStringValueToEnum method.
- The library converts the string to lower case and, because caching is enabled by default, calls the cached parsing method.
- The cached method adds the string and its parse result (null if parsing failed) to a static dictionary keyed by enum type.
- Repeating this with many unique strings causes the dictionary to grow without bound, consuming memory.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A library that converts text into a fixed set of named values (an enum) kept a memory of every text it had seen, even when the text was not valid. If an attacker sent lots of different random texts, the memory kept growing until the application ran out of memory and stopped working.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.