Replies: 2 comments 6 replies
-
This is something server framework should handle, like Spring MVC. |
Beta Was this translation helpful? Give feedback.
-
My immediate concern with special handling of I am not necessarily against adding special handling for empty Objects, mostly because this has been requested for other reasons. But just pointing out that for specifically DoS attacks, protection is probably not very simple. |
Beta Was this translation helpful? Give feedback.
-
Hello, Should we not deserialize objects with all fields that are null?
{}
into an object with all fields as null{}
that is deserialized.{}
to be processed by Jackson, for example, sending a large POST request like[{},{},{}, ...]
to a project based on Spring MVC{}
to carry out DoS(denial-of-service) attacks.For example, in a scenario where an attacker simulates 10,000 concurrent requests, each carrying less than 1MB of data.
If the server processes these requests simultaneously, it may run out of heap space due to the large number of null value field objects created, ultimately leading to service unavailability.
The corresponding code for simulating this scenario is as follows:
I think a feasible approach is to refer to the practice of JsonInclude and add a JsonExclude annotation to exclude all fields that are null.
When all fields are null, consider aborting deserialization or throwing an exception.
For example, like this:
Beta Was this translation helpful? Give feedback.
All reactions