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.

Configuration

This detector does not need any configuration.

References

© 2026 Xygeni. All rights reserved