<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=rauar" rel="nofollow">Alex Rau</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7842?redirect=false" rel="nofollow">SPR-7842</a></strong> and commented</p>
<p dir="auto">DataBinder which is used by WebRequestDataBinder and ServletRequestDataBinder grows automatically collections when "autoGrowNestedPaths" is on (AFAIK this is the default for the DataBinder).</p>
<p dir="auto">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 &lt; N will be initialized with default objects of the collection's type.</p>
<p dir="auto">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.</p>
<p dir="auto">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.</p>
<p dir="auto">I think there are several things to follow-up:</p>
<ol dir="auto">
<li>
<p dir="auto">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.</p>
</li>
<li>
<p dir="auto">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.</p>
</li>
<li>
<p dir="auto">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.</p>
</li>
</ol>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398112536" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13022" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13022/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13022">#13022</a> Can make an OutOfMemoryException by sending a modified form list property with an high index (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398097010" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/10702" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/10702/hovercard" href="https://github.com/spring-projects/spring-framework/issues/10702">#10702</a> Data Binder: Auto-grow collections as needed to support nested property binding</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398156797" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14862" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14862/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14862">#14862</a> Limit auto grow collection size when using SpEL</li>
</ul>
<p dir="auto">7 votes, 7 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=colin.sampaleanu" rel="nofollow">Colin Sampaleanu</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1319?redirect=false" rel="nofollow">SPR-1319</a></strong> and commented</p>
<p dir="auto">If you try to use one bean factory post-processor it can't actually modify the definion of a 2nd post-processor, even if that one has yet to run. This is because the appcontext as a one time process builds up two lists (ordered and non-ordered) of all the post-processors, and actually creates the objects then. Any modified bean definition past that point will be irrelevant.</p>
<p dir="auto">I'm not sure this can be resolved without some painful code, but I'm putting the issue here so it can be either marked 'won't resolve' or 'working as intended', or actually fixed, and people can find it when searching.</p>
<p dir="auto">Here's a snippet of config that shows the problem. In this case, one PropertyPlaceHolderConfigurer modifies the 2nd:</p>
<p dir="auto">&lt;bean id="fixProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;<br>
&lt;property name="location" value="classpath:remote-sync-client.properties"/&gt;<br>
&lt;property name="ignoreUnresolvablePlaceholders" value="true"&gt;&lt;/property&gt;<br>
&lt;/bean&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;variableProperties&quot; class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot; depends-on=&quot;fixProperties&quot;&gt;
	&lt;property name=&quot;location&quot; value=&quot;file:${remote.sync.data.dir}/client.config&quot;/&gt;
&lt;/bean&gt;

&lt;bean id=&quot;pathProperties&quot; class=&quot;org.springframework.beans.factory.config.PropertiesFactoryBean&quot; depends-on=&quot;variableProperties&quot;&gt;
	&lt;property name=&quot;location&quot; value=&quot;file:${remote.sync.data.dir}/path.config&quot;/&gt;
&lt;/bean&gt;

&lt;bean id=&quot;clientConfiguration&quot; class=&quot;com.tirawireless.remotesync.client.impl.ClientConfiguration&quot; depends-on=&quot;pathProperties&quot;&gt;
	&lt;property name=&quot;id&quot; value=&quot;${client.id}&quot;&gt;&lt;/property&gt;
	&lt;property name=&quot;password&quot; value=&quot;${client.password}&quot;&gt;&lt;/property&gt;
	&lt;property name=&quot;serverHost&quot; value=&quot;${remote.sync.server.host}&quot;&gt;&lt;/property&gt;
	&lt;property name=&quot;serverPort&quot; value=&quot;${remote.sync.server.port}&quot;&gt;&lt;/property&gt;
	&lt;property name=&quot;dataDirectory&quot; value=&quot;${remote.sync.data.dir}&quot;&gt;&lt;/property&gt;    	
	&lt;property name=&quot;syncDirectories&quot;&gt;
		&lt;ref local=&quot;pathProperties&quot;/&gt;
	&lt;/property&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean id="variableProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" depends-on="fixProperties"&gt;
	&lt;property name="location" value="file:${remote.sync.data.dir}/client.config"/&gt;
&lt;/bean&gt;

&lt;bean id="pathProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean" depends-on="variableProperties"&gt;
	&lt;property name="location" value="file:${remote.sync.data.dir}/path.config"/&gt;
&lt;/bean&gt;

&lt;bean id="clientConfiguration" class="com.tirawireless.remotesync.client.impl.ClientConfiguration" depends-on="pathProperties"&gt;
	&lt;property name="id" value="${client.id}"&gt;&lt;/property&gt;
	&lt;property name="password" value="${client.password}"&gt;&lt;/property&gt;
	&lt;property name="serverHost" value="${remote.sync.server.host}"&gt;&lt;/property&gt;
	&lt;property name="serverPort" value="${remote.sync.server.port}"&gt;&lt;/property&gt;
	&lt;property name="dataDirectory" value="${remote.sync.data.dir}"&gt;&lt;/property&gt;    	
	&lt;property name="syncDirectories"&gt;
		&lt;ref local="pathProperties"/&gt;
	&lt;/property&gt;
&lt;/bean&gt;
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.2.4</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398057957" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/5782" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/5782/hovercard" href="https://github.com/spring-projects/spring-framework/issues/5782">#5782</a> AbstractApplicationContext shouldn't eagerly instantiate all BeanFactoryPostProcessors (<em><strong>"duplicates"</strong></em>)</li>
</ul>