mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
28 lines
846 B
C#
28 lines
846 B
C#
using System;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Test
|
|
{
|
|
|
|
class SecondOrderSqlInjection
|
|
{
|
|
|
|
public void processRequest()
|
|
{
|
|
using (SqlConnection connection = new SqlConnection(""))
|
|
{
|
|
connection.Open();
|
|
SqlCommand customerCommand = new SqlCommand("SELECT * FROM customers", connection);
|
|
SqlDataReader customerReader = customerCommand.ExecuteReader();
|
|
|
|
while (customerReader.Read())
|
|
{
|
|
// BAD: Read from database, write it straight to another query
|
|
SqlCommand secondCustomerCommand = new SqlCommand("SELECT * FROM customers WHERE customerName=" + customerReader.GetString(1), connection);
|
|
}
|
|
customerReader.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|