-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Alex Rau opened SPR-7842 and commented
DataBinder which is used by WebRequestDataBinder and ServletRequestDataBinder grows automatically collections when "autoGrowNestedPaths" is on (AFAIK this is the default for the DataBinder).
The behaviour of DataBinder when "autoGrowNestedPaths" is that a property with a given index N will result in growing a collection to size N if the collection is not large enough. Collection elements with index < N will be initialized with default objects of the collection's type.
Based on WebRequestDataBinder it's therefore easily possible to DoS a web application if it's allowed to bind against a collection property and the client POSTs a single property using a very large index.
Sending a single request containing a parameter for a collection property with index 99999999 caused an OOM on a JVM on MacOsX with default memory settings (64MB?). The list type in this case contained 7 String properties and 2 Longs.
I think there are several things to follow-up:
-
It would be safer to set autoGrowNestedPaths to false by default. Use of DataBinder and autoGrowNestedPaths then would be more restrictive by default and require explicit action to enable autoGrowing.
-
The creation of "default" values in BeanWrapperImpl should be more flexible. A strategy for creating default values would allow clients to define how such default values should be created. In the case of WebRequestDataBinder creating empty (null) collection elements instead of default objects is certainly safer to fill the gaps in the collection - especially for exposed applications to the public. Furthermore this does not expose unwanted restrictions like a maximum allowed index limitation etc.
-
Presumably this could be solved with CustomPropertyEditors. However the majority of developers probably tries to stick with what is available out-of-the box and as the DataBinding in general for "standard" use-cases works fine dealing with the described issue is not obvious and could lead to wide-spread holes.
Affects: 3.0.5
Issue Links:
- Can make an OutOfMemoryException by sending a modified form list property with an high index [SPR-8375] #13022 Can make an OutOfMemoryException by sending a modified form list property with an high index ("is duplicated by")
- Data Binder: Auto-grow collections as needed to support nested property binding [SPR-6033] #10702 Data Binder: Auto-grow collections as needed to support nested property binding
- Limit auto grow collection size when using SpEL [SPR-10229] #14862 Limit auto grow collection size when using SpEL
7 votes, 7 watchers