Julian Wälde and Alexander Klink reported that the String.hashCode() hash function is not sufficiently collision resistant. hashCode() value is used in the implementations of HashMap and Hashtable classes:
A specially-crafted set of keys could trigger hash function collisions, which can degrade performance of HashMap or Hashtable by changing hash table operations complexity from an expected/average O(1) to the worst case O(n). Reporters were able to find colliding strings efficiently using equivalent substrings and meet in the middle techniques.
This problem can be used to start a denial of service attack against Java applications that use untrusted inputs as HashMap or Hashtable keys. An example of such application is web application server (such as tomcat, see bug #750521) that may fill hash tables with data from HTTP request (such as GET or POST parameters). A remote attack could use that to make JVM use excessive amount of CPU time by sending a POST request with large amount of parameters which hash to the same value.
This problem is similar to the issue that was previously reported for and fixed
in e.g. perl:
Red Hat would like to thank oCERT for reporting this issue. oCERT acknowledges Julian Wälde and Alexander Klink as the original reporters.
This issue was presented on 28C3:
Details were posted to full-disclosure:
n.runs advisory (copy of the full-disclosure post):
28C3 slides and recording:
Another good write-up of the issue:
Upstream does not believe this issue should be addressed in Java language itself, and rather needs to be addressed in affected applications. 28C3 slides quote following Oracle Security Team statement:
As for Java itself, it does not seem like there is anything that would
require a change in Java hashmap implementation.
Hence there's currently no plan to address this issue in Java JREs. The issue is going to be addressed in application servers such as Tomcat and JBossWeb (bug #750521), and Glassfish (Oracle bug S0104869).
(In reply to comment #12)
> Upstream does not believe this issue should be addressed in Java language
> itself, and rather needs to be addressed in affected applications. 28C3
> slides quote following Oracle Security Team statement:
> As for Java itself, it does not seem like there is anything that would
> require a change in Java hashmap implementation.
> Hence there's currently no plan to address this issue in Java JREs.
It seems there is actually going to be a fix for this in Java 7 and Java 8:
This flaw affects various versions of Java as shipped with Red Hat products. A patch is available for Java 7 and Java 8, but not for previous versions of Java shipped with Red Hat products. Although no patch is available for previous versions of Java as shipped with Red Hat products, the impact of this flaw has been addressed in several components that utilize Java HashMap in such a way that may expose a denial of service flaw.
Other related reference: