Skip to content

Conversation

@pixee-demo
Copy link

@pixee-demo pixee-demo bot commented May 1, 2025

Pixee Fix ID: 808a1a5f-4f10-455b-9be8-0cfa7c3edc01


Remediation

This change fixes "SQL Injection" (id = java/Sqli) identified by Snyk.

Details

This change refactors SQL statements to be parameterized, rather than built by hand.

Without parameterization, developers must remember to escape inputs using the rules for that database. It's usually buggy, at the least -- and sometimes vulnerable.

Our changes look something like this:

- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE name = '" + user + "'");
+ PreparedStatement stmt = connection.prepareStatement("SELECT * FROM users WHERE name = ?");
+ stmt.setString(1, user);
+ ResultSet rs = stmt.executeQuery();
More reading

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant