mirror of
https://github.com/hohn/codeql-intro-csharp.git
synced 2025-12-16 10:43:05 +01:00
SQL Injection Code Sample Run
This commit is contained in:
committed by
=Michael Hohn
parent
75ed1f7b00
commit
a2466b0a2d
21
SqlInjection-sink.ql
Normal file
21
SqlInjection-sink.ql
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @name SQLI Vulnerability
|
||||
* @description Using untrusted strings in a sql query allows sql injection attacks.
|
||||
* @kind problem
|
||||
* @id workshop/sqlivulnerable
|
||||
* @problem.severity warning
|
||||
*/
|
||||
|
||||
import csharp
|
||||
|
||||
/*
|
||||
* 2. Identify the /sink/ part of the
|
||||
* : var command = new SqliteCommand(query, connection))
|
||||
* expression, the =query= argument.
|
||||
*/
|
||||
|
||||
from ObjectCreation oc, Expr queryArg
|
||||
where
|
||||
oc.getObjectType().getName() = "SqliteCommand" and
|
||||
oc.getArgument(0) = queryArg
|
||||
select queryArg, "Sink identified: " + queryArg.toString()
|
||||
Reference in New Issue
Block a user