-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ALEPH-2018004 - DOS vulnerability is still exploitable #3010
Comments
Scratch my former comment (which i deleted). Makes sense to classify this also as a potential exploit for DOS if the attacker finds ways for the affected app/service to on-board deeply nested data that the app/service is then going to json-serialize down the road... |
Deserializing in a web api means deserializing what JSON you’re given. Protection is needed in that direction to prevent JSON from impacting the availability of your app. Serializing outbound JSON is controlled by the app because your app code controls the object being serialized. You should take steps not to give the serializer a bad type. Throwing a StackoverflowException by itself isn’t a vulnerability. The exploit was that an external attacker could trigger it by sending a web api JSON. |
An infrastructure library that throws StackoverflowException exception (which cannot be caught and terminate the process) is a potential risk to applications that use it. |
The bug is the user didn't validate the depth of the input: the expression tree.
|
I disagree with this approach.
DataContractJsonSerializer Its an old library and it is not part of System.Text.Json. |
Somebody reported this issue to the .NET security team. Our official stance is that this issue does not constitute a security vulnerability because no trust boundary has been crossed. The shape of the object to be serialized originates entirely within the trusted caller (the web app itself). While it's true that the web app might take influences from external sources, the fact remains that the web app itself is fully accountable for controlling the shape of the input object, and the web app bears ultimate responsibility for validating the shape of that object before using it if it has been influenced by external sources. That makes this a caller (web app business logic) concern, not a callee (Newtonsoft) concern. This is distinct from #2462 (deserialization), where the input is expected to have come from the other side of a trust boundary. This critical distinction means that these two issues shouldn't really be compared with one another. |
StackOverflowException is fatal and uncatchable – This is not just an error that can be handled at the application level; it leads to an immediate crash, making it a serious Denial of Service (DoS) risk. Lack of safeguards in serialization could be weaponized – If an attacker influences how nested data is stored within the system, they could cause the application to crash every time that data is serialized. Note that deeply nested structures might be legitimate (e.g., expression trees, hierarchical data, graphs). As I wrote above, you cannot assume that developers will be aware of the function's recursive nature and to the consequences of serializing deeply nested structures. |
The fix that was applied for the DOS vulnerability in Newtonsoft.Json 13.0.1 (#2462) does not really solve the problem.
It fixes only one potential way to create an highly nested object that will throw a StackOverflowException (Deserialize a given serialized object).
But what if the system contains nested objects like file system structure or groups that can contain sub-groups?
An attacker can create highly nested object in the system, and then whenever this object will be serialized, it will initiate a fatal StuckOverflowException.
Expected behavior
The recursion depth should be limited by default also for the Serialization functions (like JsonSerializer.Serialize(..)).
Actually, all the recursive functions should be limited by default to prevent potential DOS attacks.
Actual behavior
Recursion depth is not limited by default in the Serialization functions.
Sample code that demopnstrates the issue
The text was updated successfully, but these errors were encountered: