Java Sql Injection Untrusted Input
Description
Detects SQL injection vulnerabilities in Java applications using Spring JDBC (JdbcTemplate). This security flaw occurs when untrusted user input is directly concatenated or embedded into SQL queries without proper parameterization or sanitization, allowing potential database manipulation or unauthorized access.
Detection Strategy
• Check if the Spring JDBC library (org.springframework.jdbc.core.JdbcTemplate) is imported in the source code
• Look for database query execution methods like 'execute', 'executeQuery', or 'update' from JdbcTemplate
• Analyze if the query parameters contain unsanitized user input or string concatenation with untrusted data
• Report a vulnerability if database queries are constructed using direct string concatenation or unsafe parameter handling
Vulnerable code example
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
@RestController
public class UserController {
private JdbcTemplate jdbcTemplate;
@GetMapping("/users")...✅ Secure code example
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
@RestController
public class UserController {
private JdbcTemplate jdbcTemplate;
@GetMapping("/users")...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.