public override void Bad(HttpRequest req, HttpResponse resp) { string data = CWE89_SQL_Injection__Web_Connect_tcp_ExecuteScalar_61b.BadSource(req, resp); try { using (SqlConnection dbConnection = IO.GetDBConnection()) { dbConnection.Open(); using (SqlCommand badSqlCommand = new SqlCommand(null, dbConnection)) { /* POTENTIAL FLAW: data concatenated into SQL statement used in ExecuteScalar(), which could result in SQL Injection */ badSqlCommand.CommandText = "select * from users where name='" + data + "'"; object firstCol = badSqlCommand.ExecuteScalar(); if (firstCol != null) { IO.WriteLine(firstCol.ToString()); /* Use ResultSet in some way */ } } } } catch (SqlException exceptSql) { IO.Logger.Log(NLog.LogLevel.Warn, "Error getting database connection", exceptSql); } }