Expression Language Injection

User input is evaluated by an expression language such as Java EL, SpEL or OGNL, letting an attacker run expressions that reach the server's runtime and execute code.

SeverityCritical
CVSS 3.19.8 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H Open in the calculator
CVSS 4.09.3 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N Open in the calculator
CWECWE-917: Improper Neutralization of Special Elements used in an Expression Language Statement ('Expression Language Injection')
OWASP Top 10A05:2025 Injection
MITRE ATT&CKT1190 Exploit Public-Facing Application, T1059 Command and Scripting Interpreter
CategoryInjection

Description

Java web frameworks use expression languages to bind data and evaluate logic: the Jakarta Expression Language in JSP and JSF pages, the Spring Expression Language (SpEL), OGNL in Apache Struts, and MVEL in some rule and workflow engines. Expression language injection occurs when a value supplied by the user is evaluated as an expression, for example when it is passed to an expression parser, placed into a validation or error message that the framework interpolates, or processed twice by a tag that evaluates its attribute.

These languages can create objects and call methods, so an injected expression can usually reach the Java runtime and start operating system processes. An attacker can then run arbitrary code on the server with the privileges of the Java process, giving them the application's data, its configuration secrets and access to the host, and no user interaction is needed. Where the expression is evaluated in a restricted context, the impact may be limited to reading or changing application objects, which can still expose sensitive data or bypass security checks.

The weakness typically shows itself on a test when an expression such as ${7*7} or #{7*7} in a parameter or header is returned as 49, or when it causes an error from the expression parser. Burp Suite reports it as expression language injection. Several widely exploited vulnerabilities in Struts and Spring products were of this type, so it is found in outdated frameworks as well as in custom code, and public exploits exist for many framework-level instances.

Remediation

Do not evaluate user input as an expression:

  • Remove code that passes user input to an expression parser, such as SpEL's parseExpression(), OGNL evaluation or an EL processor, and pass input to fixed expressions as variables or plain values instead.
  • Do not include user input in messages that the framework interpolates, such as custom Bean Validation constraint messages; supply it as a message parameter instead.
  • Where SpEL must evaluate an expression involving untrusted data, use SimpleEvaluationContext, which excludes type references, constructors and bean references, rather than StandardEvaluationContext.
  • Keep the framework and its libraries up to date, as many expression language injection flaws have been in framework code rather than in the application itself.

As an interim measure, a web application firewall rule can block expression delimiters such as ${ and #{ on the affected parameters, but it can be bypassed. Confirm the fix by repeating the original expressions and checking that they are returned as literal text and cause no parser errors.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Web Applications Findings

Every Web Applications finding