Improper Control of Generation of Code ('Code Injection')
ID |
scala.inject.scala_inject_rule_elinjection |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
medium |
Remediation Effort |
medium |
Resource |
Inject |
Language |
Scala |
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.
Rationale
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.
The following code illustrates a vulnerable pattern detected by this rule:
// An EL expression built from the caller runs with the application's own bean graph in reach.
class ExpressionRunner {
def valueFrom(expression: String) = {
val faces = FacesContext.getCurrentInstance
val factory = faces.getApplication.getExpressionFactory
val context = faces.getELContext
// VULNERABLE: Improper Control of Generation of Code ('Code Injection')
val value = factory.createValueExpression(context, expression, classOf[Nothing])
value.getValue(context).asInstanceOf[Nothing]
}
}
Remediation
Follow secure coding practices and review the references below for detailed remediation guidance.
References
-
OWASP Top 10 2025 - A05 : Injection.