-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SQLIController.cs #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,40 @@ | |
using System.IO; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Data.SQLite; | ||
using System.Data.SQLite; | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Http.Extensions; | ||
|
||
|
||
namespace RandomQuotes.Controllers | ||
{ | ||
public class SQLIController : Controller | ||
{ | ||
// testing normal: /sqli?name=Andrew | ||
// testing exploit: /sqli?name=1%27%20or%20%271%27==%271 | ||
// testing exploit: /sqli?name=Octopus%27%20or%20%271%27==%271 | ||
[HttpGet("sqli")] | ||
public IActionResult Get(string name) | ||
{ | ||
SQLiteConnection conn = new SQLiteConnection("Data Source=Chinook_Sqlite.sqlite"); | ||
conn.Open(); | ||
|
||
SQLiteCommand cmd = new SQLiteCommand(conn); | ||
cmd.CommandText = "select * from Employee where FirstName == '" + name + "';"; | ||
string clause = ""; | ||
List<string> list = new List<string>(); | ||
if (name.StartsWith("Octopus")) | ||
{ | ||
list.Add("FirstName == '" + name + "';"); | ||
} | ||
else | ||
{ | ||
list.Add("FirstName == 'Andrew';"); | ||
} | ||
|
||
SQLiteConnection conn2 = new SQLiteConnection("Data Source=Chinook_Sqlite.sqlite"); | ||
conn2.Open(); | ||
|
||
SQLiteDataReader reader = cmd.ExecuteReader(); | ||
SQLiteCommand cmd2 = new SQLiteCommand(conn2); | ||
string whereClause = "where " + string.Join(" OR ", list); | ||
|
||
cmd2.CommandText = "select * from Employee " + whereClause; | ||
Check warning on line 37 in RandomQuotes/Controllers/SQLIController.cs GitHub Actions / AppScan CodeSweep #3Potential SQL injection is detected
Raw output
Check warning on line 37 in RandomQuotes/Controllers/SQLIController.cs GitHub Actions / AppScan CodeSweep #2Potentially hazardous SQL query detected in Xamarin code
Raw output
|
||
|
||
Console.WriteLine(cmd2.CommandText); | ||
Check warning on line 38 in RandomQuotes/Controllers/SQLIController.cs GitHub Actions / AppScan CodeSweep #1Console logging
Raw output
|
||
SQLiteDataReader reader = cmd2.ExecuteReader(); | ||
|
||
|
||
List<string> res = new List<string>(); | ||
|
@@ -40,4 +55,4 @@ | |
return Ok(res); | ||
} | ||
} | ||
} | ||
} |
Check failure
Code scanning / CodeQL
SQL query built from user-controlled sources