Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package org.owasp.webgoat.lessons.sqlinjection.introduction;

import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -61,14 +62,15 @@ public AttackResult completed(@RequestParam String action_string) {

protected AttackResult injectableQueryAvailability(String action) {
StringBuilder output = new StringBuilder();
String query = "SELECT * FROM access_log WHERE action LIKE '%" + action + "%'";
String query = "SELECT * FROM access_log WHERE action LIKE ?";

try (Connection connection = dataSource.getConnection()) {
try {
Statement statement =
connection.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet results = statement.executeQuery(query);
PreparedStatement statement =
connection.prepareStatement(
query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
statement.setString(1, "%" + action + "%");
ResultSet results = statement.executeQuery();

if (results.getStatement() != null) {
results.first();
Expand Down