Medium severity CWE-89 vulnerability in src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00603.java:69#52
Merged
davewichers merged 2 commits intomainfrom Jan 15, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vulnerability Information
AppSecAI Vulnerability ID: 69654fbdfc355c4beda09b18
Vulnerability: SQL Injection
CWE Classification: CWE-89
Severity: Medium
File:
src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00603.javaDetection Rule: java.lang.security.audit.sqli.tainted-sql-from-http-request.tainted-sql-from-http-request
Description: Detected input from a HTTPServletRequest going into a SQL sink or statement. This could lead to SQL injection if variables in the SQL statement are not properly sanitized. Use parameterized SQL queries or properly sanitize user input instead.
Triage Analysis
Status: Confirmed vulnerability
Security Assessment:
Severity: High
Confidence: 95%
Analysis
Classic SQL injection via string concatenation. User-controlled HTTP parameter name flows through thing.doSomething() directly into SQL statement construction at line 67. The code extracts parameter names from the request (lines 49-62), passes the name to thing.doSomething(), and concatenates the result into SQL without parameterized queries. The security guideline about SeparateClassRequest.getTheValue() doesn't apply here - this code uses ThingInterface.doSomething() with no evidence of sanitization. Exploitable by sending requests with malicious parameter names like 'test' OR '1'='1'.
Recommended Remediation
Replace string concatenation with PreparedStatement parameterized queries: PreparedStatement pstmt = connection.prepareStatement("SELECT * from USERS where USERNAME='foo' and PASSWORD=?"); pstmt.setString(1, bar); ResultSet rs = pstmt.executeQuery();
Remediation Details
Fix Description:
The SQL injection vulnerability has been fixed. Here's what was changed:
Fix Summary
The code concatenated user input directly into a SQL query string, allowing attackers to inject malicious SQL commands. Fixed by replacing string concatenation with a parameterized query using
PreparedStatement, which treats user input as data rather than executable SQL.Changes made:
"SELECT * from USERS where USERNAME='foo' and PASSWORD='" + bar + "'"to"SELECT * from USERS where USERNAME='foo' and PASSWORD=?"(using parameter placeholder)StatementtoPreparedStatementstatement.setString(1, bar)to safely bind the user input as a parameterstatement.execute(sql, ...)tostatement.execute()since PreparedStatement already contains the SQLThe parameterized query ensures that the
barvariable is treated as a literal string value, not as SQL code. This prevents SQL injection attacks where malicious input like' OR '1'='1could manipulate the query logic. The fix maintains complete API compatibility and functional equivalence while eliminating the security vulnerability.Changes Made:
This PR was generated automatically to address a security vulnerability.
Please review the changes carefully before merging.