Skip to content

Expression Language Injection

Description

An expression is built with a dynamic value. The source of the value(s) should be verified to avoid that unfiltered values fall into this risky code evaluation.

Examples

Insecure Code

scala
def vulnerableMethod(userInput: String) = { val expr = javax.el.ExpressionFactory.newInstance().createValueExpression(userInput, classOf[String]) }

Secure Code

scala
def secureMethod(userInput: String) = { val sanitizedInput = userInput.replaceAll("[^a-zA-Z0-9]", ""); val expr = javax.el.ExpressionFactory.newInstance().createValueExpression(sanitizedInput, classOf[String]) }

Remediation

Validate and sanitize user input before passing it to the createValueExpression or createMethodExpression methods.

Rule Details

FieldValue
IDCODE-0045
CategoryInjection
SeverityHIGH
CWECWE-94
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagscode injection, expression language
OWASPN/A