CVE-2026-123886

Remote Code Execution
Affects
Spring Data Elasticsearch
in
Spring
No items found.
Versions
>=5.3.0 <=5.5.13, >=6.0.0 <=6.0.8, >=6.1.0 <=6.1.2

Patch Available.

Exclamation circle icon
Patch Available

This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.

Overview

Spring Data Elasticsearch is part of the Spring Data family and provides integration with the Elasticsearch search engine, including a POJO-centric model for working with Elasticsearch documents and a repository-style data access layer.

A remote code execution vulnerability (CVE-2026-123886) has been identified in the string-based @Query support of Spring Data Elasticsearch repositories, which allows attackers to execute arbitrary code in the application by passing a SpEL expression as an argument to a repository query method. Repeated requests can also exhaust memory through an unbounded expression cache.

Per OWASP: Expression Language (EL) Injection happens when attacker controlled data enters an EL interpreter.

This issue affects multiple versions of Spring Data Elasticsearch.

‍

Details

Module Info

Vulnerability Info

This High-severity vulnerability is found in the org.springframework.data:spring-data-elasticsearch package in multiple versions of Spring Data Elasticsearch.

Repository methods annotated with a string-based @Query can refer to their arguments through positional placeholders (?0, ?1, ...) and can embed SpEL template expressions (#{...}). QueryStringProcessor.createQuery builds the final query in two steps, in this order:

public String createQuery(ElasticsearchParametersParameterAccessor parameterAccessor) {
        String queryString = new QueryStringPlaceholderReplacer(conversionService)
                        .replacePlaceholders(query, parameterAccessor);

        QueryStringSpELEvaluator evaluator = new QueryStringSpELEvaluator(queryString, parameterAccessor, queryMethod,
                        evaluationContextProvider, conversionService);
        return evaluator.evaluate();
}

The positional placeholders are replaced with the method arguments first, and the resulting string, which now contains caller-supplied text, is then parsed as a SpEL template. QueryStringSpELEvaluator parses that string with ParserContext.TEMPLATE_EXPRESSION and evaluates every #{...} block it finds:

private static final Map<String, Expression> QUERY_EXPRESSIONS = new ConcurrentHashMap<>();

private Expression getQueryExpression(String queryString) {
        return QUERY_EXPRESSIONS.computeIfAbsent(queryString, f -> {
                Expression expr = PARSER.parseExpression(queryString, ParserContext.TEMPLATE_EXPRESSION);
                return expr instanceof LiteralExpression ? null : expr;
        });
}

Escaping applied to string arguments during placeholder replacement covers quotes, not the #{ delimiter, so an argument such as #{T(java.lang.Runtime).getRuntime().exec('...')} survives substitution and is evaluated as SpEL in the application's evaluation context. This happens even when the declared query uses no SpEL at all. Any application that passes untrusted input to a repository method declaring a @Query with positional placeholders lets a remote attacker execute arbitrary code.

The parsed expressions are also cached in a static, unbounded ConcurrentHashMap keyed by the fully substituted query string. Because each distinct argument value produces a distinct key, repeated requests with varying input grow the cache without limit and can exhaust the application's memory.

‍

Mitigation

Only recent versions of Spring Data Elasticsearch receive community support. Older lines are End-of-Life and will not receive public updates to address this issue.

If an upgrade is not possible, reject input containing #{ before passing it to @Query methods, or build such queries through CriteriaQuery or NativeQuery instead of string-based queries.

Users of the affected components should apply one of the following mitigations:

  • Upgrade to a currently supported version of Spring Data Elasticsearch.
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.

Credits

Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
High
ID
CVE-2026-123886
PROJECT Affected
Spring Data Elasticsearch
Versions Affected
>=5.3.0 <=5.5.13, >=6.0.0 <=6.0.8, >=6.1.0 <=6.1.2
NES Versions Affected
Published date
November 20, 2026
≈ Fix date
Category
Remote Code Execution
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for Spring
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.