Scala Tainted Sql Injection
Description
Detects potential SQL injection vulnerabilities in Scala code where untrusted input data could be concatenated into SQL queries. This vulnerability occurs when user-controlled data is directly incorporated into SQL statements without proper sanitization, allowing potential manipulation of the query structure.
Detection Strategy
• Code must import java.sql package
• SQL execution methods like executeQuery, execute or prepareStatement are called
• The SQL query string (first argument) contains string concatenation with variables
• The concatenated variables are not properly sanitized or escaped
Vulnerable code example
import java.sql.DriverManager
object SqlInjectionExample {
def unsafeQuery(name: String) = {
val conn = DriverManager.getConnection("jdbc:mysql://localhost:8080")
val stmt = conn.createStatement()
// Vulnerable: Direct string concatenation allows SQL injection
val sql = "SELECT * FROM users WHERE name = " + name + ";"...✅ Secure code example
import java.sql.DriverManager
object SqlInjectionExample {
def safeQuery(name: String) = {
val conn = DriverManager.getConnection("jdbc:mysql://localhost:8080")
// SAFE: Using prepared statement with parameterized query
val pstmt = conn.prepareStatement("SELECT * FROM users WHERE name = ?")
pstmt.setString(1, name)...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.