Skip to content

SQL Injection Vulnerability

Description

The method identified is susceptible to injection. The input should be validated and properly escaped. This vulnerability can lead to unauthorized access to sensitive data and potentially allow an attacker to execute arbitrary SQL commands.

Examples

Insecure Code

scala
val query = "SELECT * FROM users WHERE name = '" + userName + "'"

Secure Code

scala
val query = "SELECT * FROM users WHERE name = ?"; val pstmt = connection.prepareStatement(query); pstmt.setString(1, userName)

Remediation

Validate and escape user input to prevent SQL injection. Consider using prepared statements or parameterized queries.

Rule Details

FieldValue
IDCODE-0043
CategoryInjection
SeverityHIGH
CWECWE-89
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagssql, injection
OWASPN/A