Improper Neutralization of Special Elements in Data Query Logic

ID

scala.inject.scala_inject_rule_awsqueryinjection

Severity

high

Remediation Complexity

medium

Remediation Risk

medium

Remediation Effort

medium

Resource

Inject

Language

Scala

Description

Constructing SimpleDB queries containing user input can allow an attacker to view unauthorized records.

Rationale

Constructing SimpleDB queries containing user input can allow an attacker to view unauthorized records.

The following code illustrates a vulnerable pattern detected by this rule:

// SimpleDB's select expression is a query language, so a value spliced into it is injected
// exactly as it would be into SQL.
class BillingServlet extends HttpServlet {
  @throws[IOException]
  override def doGet(request: HttpServletRequest, response: HttpServletResponse): Unit = {
    try {
      val account = request.getParameter("account")
      val credentials = new BasicAWSCredentials("id", "secret")
      val simpleDb = new AmazonSimpleDBClient(credentials)
      val expression = "select * from invoices where account = '" + account

      // VULNERABLE: Improper Neutralization of Special Elements in Data Query Logic
      val page = simpleDb.select(new SelectRequest(expression))
      // VULNERABLE: Improper Neutralization of Special Elements in Data Query Logic
      val consistentPage = simpleDb.select(new SelectRequest(expression, false))
      val builder = new SelectRequest()
      // VULNERABLE: Improper Neutralization of Special Elements in Data Query Logic
      val builtPage = simpleDb.select(builder.withSelectExpression(expression))

      val fixed = "select * from invoices where account = '000123'"
      val fixedPage = simpleDb.select(new SelectRequest(fixed))
    } catch {
      case _: Throwable =>
    }
  }
}

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