CVE
CVE-2026-123886
CWE
CWE-917, CWE-400
Affected Surface
- Maven `org.springframework.data:spring-data-elasticsearch` 6.1.0 to 6.1.2 and 6.0.0 to 6.0.8; fixed in 6.1.3 and 6.0.9 (6.2.0 also contains the fix)
- Spring Boot applications using `spring-boot-starter-data-elasticsearch` on Boot 4.0.x before 4.0.10 or 4.1.x before 4.1.3
TL;DR
Spring Data repositories let you declare an Elasticsearch query as a JSON string on the method, with ?0, ?1 and so on standing in for the arguments. The same string can also contain SpEL templates (#{...}) that Spring evaluates when the method runs. In 6.0 and 6.1, QueryStringProcessor.createQuery() did those two steps in the wrong order. It pasted the caller’s arguments into the template first and then ran the SpEL evaluator over the result. Any #{...} inside an argument became part of the expression and ran, with a StandardEvaluationContext that allows T(java.lang.Runtime).
Spring’s advisory says an application is affected “if it passes untrusted input as an argument to a repository query method that declares a @Query with positional placeholders,” and that a remote attacker “can execute arbitrary code in the application.” The query doesn’t need any SpEL of its own. A search endpoint that passes a request parameter to findByTitle(String title) with @Query("{\"match\": {\"title\": \"?0\"}}") is the textbook case. The expression cache was also unbounded, so distinct expressions in repeated requests could exhaust memory.
Spring rated it 8.8 (AV:N/AC:L/PR:L, low privileges required) and credits waydeshi and Daehyun Kang. Fixed versions went to Maven Central on 19 November, and Spring Boot 4.0.10, 4.1.3 and 4.2.0 picked them up the same day. NVD published the CVE on 23 November. A public GitHub repository created that day reproduces the two code orderings in a Python lab, not against a real Spring application. There’s no EPSS score yet and no report of exploitation.
What to do now:
- Upgrade to Spring Data Elasticsearch 6.1.3 or 6.0.9, or to Spring Boot 4.1.3, 4.0.10 or 4.2.0.
- Don’t rely on Dependabot for this one. The GitHub Advisory Database entry (GHSA-c426-6j2c-pm64) is unreviewed and lists no package. Check the version yourself.
- If you can’t upgrade yet, reject
#{in any value passed to a@Querymethod, or move those queries toCriteriaQueryorNativeQuery.
Affected packages and projects
| Ecosystem | Package | Affected versions | Fixed version |
|---|---|---|---|
| Maven | org.springframework.data:spring-data-elasticsearch | 6.1.0 to 6.1.2 | 6.1.3 (19 November 2026) |
| Maven | org.springframework.data:spring-data-elasticsearch | 6.0.0 to 6.0.8 | 6.0.9 (19 November 2026) |
| Maven | org.springframework.boot:spring-boot-starter-data-elasticsearch | Boot 4.1.0 to 4.1.2, 4.0.0 to 4.0.9 | Boot 4.1.3 (Data BOM 2026.0.3), 4.0.10 (Data BOM 2025.1.9), 4.2.0 (Data BOM 2026.1.0 with Spring Data Elasticsearch 6.2.0) |
Spring’s advisory lists only the 6.0 and 6.1 lines. The vulnerable QueryStringProcessor class is older than 6.0, but Spring hasn’t said whether 5.x releases are affected, and they’re out of open-source support.
Technical analysis
The vulnerable code
This is createQuery() in QueryStringProcessor as it shipped in 6.1.2. query is the string from the @Query annotation, and parameterAccessor holds the caller’s arguments:
public String createQuery(ElasticsearchParametersParameterAccessor parameterAccessor) {
// 1. Replace ?0, ?1 ... with the method arguments
String queryString = new QueryStringPlaceholderReplacer(conversionService)
.replacePlaceholders(query, parameterAccessor);
// 2. Then parse and evaluate every #{...} in the combined string
QueryStringSpELEvaluator evaluator = new QueryStringSpELEvaluator(queryString, parameterAccessor, queryMethod,
evaluationContextProvider, conversionService);
return evaluator.evaluate();
}
QueryStringSpELEvaluator.evaluate() parses the string as a SpEL template and, if it finds an expression, evaluates it in the context from evaluationContextProvider. Spring Data’s default provider returns a StandardEvaluationContext, which resolves type references, so T(java.lang.Runtime) works. Parsed expressions were kept in private static final Map<String, Expression> QUERY_EXPRESSIONS = new ConcurrentHashMap<>(), keyed by the full query string and never evicted.
A repository like this one is affected:
public interface BookRepository extends ElasticsearchRepository<Book, String> {
@Query("{\"match\": {\"title\": {\"query\": \"?0\"}}}")
List<Book> findByTitle(String title);
}
// Controller passes the search box straight through
bookRepository.findByTitle(request.getParameter("q"));
A request with q=#{T(java.lang.Runtime).getRuntime().exec('id')} turns the query string into {"match": {"title": {"query": "#{T(java.lang.Runtime).getRuntime().exec('id')}"}}} after step 1, and step 2 runs id on the application host before anything reaches Elasticsearch. The JSON quoting around ?0 doesn’t help, because SpEL template parsing finds #{ anywhere in the string.
The fix
The fix swaps the two steps, so only the developer’s own @Query text is evaluated and the arguments go in afterwards as data. From 311bc4127136 on the 6.1.x branch (the 6.0.x and main commits are the same change, all titled “Refine query placeholder replacement.”):
public String createQuery(ElasticsearchParametersParameterAccessor parameterAccessor) {
- String queryString = new QueryStringPlaceholderReplacer(conversionService)
- .replacePlaceholders(query, parameterAccessor);
-
- QueryStringSpELEvaluator evaluator = new QueryStringSpELEvaluator(queryString, parameterAccessor, queryMethod,
+ QueryStringSpELEvaluator evaluator = new QueryStringSpELEvaluator(query, parameterAccessor, queryMethod,
evaluationContextProvider, conversionService);
- return evaluator.evaluate();
+ var evaluated = evaluator.evaluate();
+ // replace positional parameters after SpEL evaluation
+ String evaluatedAndReplaced = new QueryStringPlaceholderReplacer(conversionService)
+ .replacePlaceholders(evaluated, parameterAccessor);
+ return evaluatedAndReplaced;
}
QueryStringSpELEvaluator also replaces the unbounded map with a ConcurrentLruCache<String, Optional<Expression>> capped at 256 entries, which closes the memory exhaustion half of the advisory.
IOCs
No exploitation has been reported, so there are no attacker indicators. Signs of attempts:
#{,T(java.lang.Runtime),T(java.lang.ProcessBuilder),getRuntime().exec(ornew java.util.Scanner(in request parameters or JSON bodies sent to search endpoints, including URL-encoded forms such as%23%7BSpelEvaluationExceptionorSpelParseExceptionin application logs fromQueryStringSpELEvaluator- The Java process of a search service starting
sh,bash,curlorwget - Steady heap growth in a search service that receives many distinct query arguments (the unbounded expression cache)
Detection and remediation
Check the version on the runtime classpath:
# Maven
mvn -q dependency:tree -Dincludes=org.springframework.data:spring-data-elasticsearch
# Gradle
./gradlew dependencyInsight --dependency spring-data-elasticsearch --configuration runtimeClasspath
# Built Spring Boot jars
unzip -l app.jar | grep 'spring-data-elasticsearch-6\.'
Find repository methods that use positional placeholders in string queries:
rg -n -U --type java '@Query\(\s*"[^"]*\?[0-9]' src/
rg -n --type kotlin '@Query\(.*\?[0-9]' src/
Upgrade, or override the version through Spring Boot’s dependency management:
<properties>
<spring-data-bom.version>2026.0.3</spring-data-bom.version> <!-- Spring Data Elasticsearch 6.1.3 -->
</properties>
If you can’t upgrade, add a guard in front of the affected methods. Spring’s advisory suggests rejecting #{:
static String noSpel(String value) {
if (value != null && value.contains("#{")) {
throw new IllegalArgumentException("Invalid search input");
}
return value;
}
bookRepository.findByTitle(noSpel(request.getParameter("q")));
Or build the query with CriteriaQuery (new CriteriaQuery(Criteria.where("title").matches(q))) or NativeQuery, which don’t go through QueryStringProcessor.
If logs show successful payloads, rotate the credentials the application could read: the Elasticsearch user and API key in spring.elasticsearch.*, database and message broker credentials in application.properties or the environment, and cloud credentials available to the host or pod.
Timeline
- 2026-11-10: The fix lands on main (
2a5b65c311cf). - 2026-11-12: The 6.1.x backport (
311bc4127136) is committed. - 2026-11-19: Spring publishes CVE-2026-123886. Spring Data Elasticsearch 6.1.3, 6.0.9 and 6.2.0 reach Maven Central, followed by Spring Boot 4.0.10, 4.1.3 and 4.2.0.
- 2026-11-23: NVD publishes the CVE. The GitHub Advisory Database adds GHSA-c426-6j2c-pm64 without a package mapping. The
googlesky/CVE-2026-123886lab repository appears on GitHub. No EPSS score yet and no exploitation reported.
From research to remediation
Check whether this pattern exists in your codebase
Turn this research into a remediation workflow. Scan dependencies and package manifests for similar supply-chain risk, then prioritize fixes with reachability context.
References
- Spring Security Advisory: CVE-2026-123886, SpEL injection in Spring Data Elasticsearch string-based queries
- NVD: CVE-2026-123886
- GitHub Advisory Database: GHSA-c426-6j2c-pm64
- spring-data-elasticsearch commit 311bc4127136 (6.1.x): Refine query placeholder replacement
- spring-data-elasticsearch commit 2a5b65c311cf (main): Refine query placeholder replacement
- googlesky/CVE-2026-123886: research lab modelling the vulnerable and fixed orderings
- Maven Central: spring-data-elasticsearch