All Vulnerability Reports

CVE-2016-6652 Spring Data JPA Blind SQL Injection Vulnerability




Spring by Pivotal

Versions Affected

  • Spring Data JPA 1.10.2, 1.9.4
  • Other unsupported versions are also affected


Sort instances handed into user defined Spring Data repository query methods using manually declared JPQL queries are handed to the persistence provider as is and allow attackers to inject arbitrary JPQL into ORDER BY clauses which they might use to draw conclusions about non-exposed fields based on the query result's element order changing depending on the injected JPQL.

This especially comes into play if the Sort instances are created from untrustable sources, e.g. web request parameters.


Users of affected versions should apply the following mitigation:

  • Users are advised to upgrade to Spring Data JPA in version 1.10.4 (Hopper SR4) or 1.9.6 (Gosling SR6). These versions contain sanitizing of the Sort instances handed to the data access layer and only allow referring to domain object fields and aliases used in the JPQL backing the query method.
  • Should users still need to hand complex sort expressions to the data access layer, they can use the newly introduced JpaSort.unsafe(…) to reinstantiate the old behavior.


The vulnerability was reported responsibly by Niklas Särökaari from Silverskin Information Security and Joona Immonen, Arto Santala, Antti Virtanen, Michael Holopainen and Antti Ahola from Solita.



2016-September-30: Initial vulnerability report published