Skip to content

Expression injection (OGNL)

Description

A 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 example(userInput: String) = {
  com.opensymphony.xwork2.util.TextParseUtil.translateVariables(userInput)
}

Secure Code

scala
def example(userInput: String) = {
  val sanitizedInput = userInput.replaceAll("[^a-zA-Z0-9]","")
  com.opensymphony.xwork2.util.TextParseUtil.translateVariables(sanitizedInput)
}

Remediation

Validate and sanitize user input to prevent unfiltered values from being used in the expression evaluation.

Rule Details

FieldValue
IDCODE-0049
CategoryInjection
SeverityMEDIUM
CWECWE-917
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagsinjection, ognl, struts
OWASPN/A