Skip to content

Commit 05b45da

Browse files
authored
Merge pull request github#6556 from hvitved/csharp/insecure-sql-conn-flow
C#: Use data flow instead of taint tracking in `InsecureSQLConnection.ql`
2 parents 7dbdfeb + 7e1efbd commit 05b45da

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

csharp/ql/src/Security Features/CWE-327/InsecureSQLConnection.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import csharp
1414
import DataFlow::PathGraph
1515

1616
/**
17-
* A `DataFlow::Configuration` for tracking `Strings passed to SqlConnectionStringBuilder` instances.
17+
* A data flow configuration for tracking strings passed to `SqlConnection[StringBuilder]` instances.
1818
*/
19-
class TaintTrackingConfiguration extends TaintTracking::Configuration {
19+
class TaintTrackingConfiguration extends DataFlow::Configuration {
2020
TaintTrackingConfiguration() { this = "TaintTrackingConfiguration" }
2121

2222
override predicate isSource(DataFlow::Node source) {

csharp/ql/test/query-tests/Security Features/CWE-327/InsecureSQLConnection/InsecureSQLConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public void StringInBuilderProperty()
3434

3535
public void TriggerThis()
3636
{
37-
// BAD, Encrypt not specified [NOT DETECTED]
37+
// BAD, Encrypt not specified
3838
SqlConnection conn = new SqlConnection("Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;");
3939
}
4040

4141
void Test4()
4242
{
4343
string connectString =
4444
"Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd";
45-
// BAD, Encrypt not specified [NOT DETECTED]
45+
// BAD, Encrypt not specified
4646
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
4747
var conn = new SqlConnection(builder.ConnectionString);
4848
}
@@ -51,7 +51,7 @@ void Test5()
5151
{
5252
string connectString =
5353
"Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false";
54-
// BAD, Encrypt set to false [NOT DETECTED]
54+
// BAD, Encrypt set to false
5555
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
5656
var conn = new SqlConnection(builder.ConnectionString);
5757
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
edges
2+
| InsecureSQLConnection.cs:44:17:44:64 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd" : String | InsecureSQLConnection.cs:46:81:46:93 | access to local variable connectString |
3+
| InsecureSQLConnection.cs:53:17:53:78 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false" : String | InsecureSQLConnection.cs:55:81:55:93 | access to local variable connectString |
4+
nodes
5+
| InsecureSQLConnection.cs:38:52:38:128 | "Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;" | semmle.label | "Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;" |
6+
| InsecureSQLConnection.cs:44:17:44:64 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd" : String | semmle.label | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd" : String |
7+
| InsecureSQLConnection.cs:46:81:46:93 | access to local variable connectString | semmle.label | access to local variable connectString |
8+
| InsecureSQLConnection.cs:53:17:53:78 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false" : String | semmle.label | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false" : String |
9+
| InsecureSQLConnection.cs:55:81:55:93 | access to local variable connectString | semmle.label | access to local variable connectString |
10+
#select
11+
| InsecureSQLConnection.cs:38:52:38:128 | "Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;" | InsecureSQLConnection.cs:38:52:38:128 | "Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;" | InsecureSQLConnection.cs:38:52:38:128 | "Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;" | $@ flows to here and does not specify `Encrypt=True`. | InsecureSQLConnection.cs:38:52:38:128 | "Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;" | Connection string |
12+
| InsecureSQLConnection.cs:46:81:46:93 | access to local variable connectString | InsecureSQLConnection.cs:44:17:44:64 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd" : String | InsecureSQLConnection.cs:46:81:46:93 | access to local variable connectString | $@ flows to here and does not specify `Encrypt=True`. | InsecureSQLConnection.cs:44:17:44:64 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd" | Connection string |
13+
| InsecureSQLConnection.cs:55:81:55:93 | access to local variable connectString | InsecureSQLConnection.cs:53:17:53:78 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false" : String | InsecureSQLConnection.cs:55:81:55:93 | access to local variable connectString | $@ flows to here and does not specify `Encrypt=True`. | InsecureSQLConnection.cs:53:17:53:78 | "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false" | Connection string |
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Security Features/CWE-091/XMLInjection.ql
1+
Security Features/CWE-327/InsecureSQLConnection.ql

0 commit comments

Comments
 (0)