[Autofix] Parameterize CallableStatement in BenchmarkTest00996 to fix SQLi#4
Open
rafikmojr wants to merge 1 commit into
Open
[Autofix] Parameterize CallableStatement in BenchmarkTest00996 to fix SQLi#4rafikmojr wants to merge 1 commit into
rafikmojr wants to merge 1 commit into
Conversation
|
New Issues (2510)Checkmarx found the following issues in this Pull Request
Fixed Issues (2)Great job! The following issues were fixed in this Pull Request
Communicate with Checkmarx by submitting a PR comment with @Checkmarx followed by one of the supported commands. Learn about the supported commands here. |
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.



Autofix: Fixed 1 of 1 security risk(s)
✅ Fixed
SAST · View in Apiiro
Summary:
Replaced tainted SQL string concatenation in
BenchmarkTest00996.doPostwith a fixed{call verifyUserPassword(?,?)}CallableStatement that binds the cookie-derived value throughsetString, eliminating the CWE-89 sink.What Changed:
In
src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00996.java, the vulnerable lineString sql = "{call " + bar + "}";was replaced with a hardcoded procedure callString sql = "{call verifyUserPassword(?,?)}";. The user-controlledbar(sourced from theBenchmarkTest00996cookie) is now bound as a parameter viastatement.setString(1, bar)(withsetString(2, "")for the second argument), so untrusted input can no longer alter the SQL structure.Why This Fix:
The overlay's AI Triage verdict is TruePositive with the standard remediation being parameterized queries and placeholder binding. A pure string-concatenation CallableStatement cannot protect against injection because
prepareCallonly compiles the final string. The default cookie value in the same file (verifyUserPassword%28%27foo%27%2C%27bar%27%29) tells us the expected stored procedure name and arity, so hardcodingverifyUserPassword(?,?)preserves the intended behavior while binding tainted input via JDBC'ssetString— matching the overlay's recommended OWASP pattern and the existingPreparedStatement.setString(...)idiom already used throughout the Benchmark suite (e.g. BenchmarkTest00192).Files Changed:
src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00996.javaReviewer Notes:
verifyUserPassword(?, ?)stored procedure; the default cookie valueverifyUserPassword('foo','bar')indicates this was the original intended procedure and arity.expectedresults-1.2.csv) — reviewers comparing scanner output against the benchmark baseline should be aware.Potential Impact:
Low blast radius. The change is confined to a single intentionally vulnerable OWASP Benchmark servlet and does not touch shared helpers or the database schema. Runtime behavior only changes for the
BenchmarkTest00996endpoint: its CallableStatement now passes the cookie-derived value as the first argument to a fixedverifyUserPasswordstored procedure instead of executing whatever call string the attacker supplied, which is the intended security-hardening outcome but will shift this case's classification in Benchmark scoring.About Apiiro Autofix
This PR was automatically generated by Apiiro Autofix. Review all changes carefully before merging and run your test suite to verify no regressions.