Skip to content

Commit 3fed279

Browse files
authored
Merge pull request github#13093 from GeekMasher/csharp-ext
[CSharp] Additional data extensions for sink models
2 parents fe71207 + 0fcc1cb commit 3fed279

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Additional support for `command-injection`, `ldap-injection`, `log-injection`, and `url-redirection` sink kinds for Models as Data.

csharp/ql/lib/semmle/code/csharp/security/dataflow/CommandInjectionQuery.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import csharp
66
private import semmle.code.csharp.security.dataflow.flowsources.Remote
77
private import semmle.code.csharp.frameworks.system.Diagnostics
88
private import semmle.code.csharp.security.Sanitizers
9+
private import semmle.code.csharp.dataflow.ExternalFlow
910

1011
/**
1112
* A source specific to command injection vulnerabilities.
@@ -66,6 +67,11 @@ module CommandInjection = TaintTracking::Global<CommandInjectionConfig>;
6667
/** A source of remote user input. */
6768
class RemoteSource extends Source instanceof RemoteFlowSource { }
6869

70+
/** Command Injection sinks defined through Models as Data. */
71+
private class ExternalCommandInjectionExprSink extends Sink {
72+
ExternalCommandInjectionExprSink() { sinkNode(this, "command-injection") }
73+
}
74+
6975
/**
7076
* A sink in `System.Diagnostic.Process` or its related classes.
7177
*/

csharp/ql/lib/semmle/code/csharp/security/dataflow/LDAPInjectionQuery.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private import semmle.code.csharp.security.dataflow.flowsources.Remote
88
private import semmle.code.csharp.frameworks.system.DirectoryServices
99
private import semmle.code.csharp.frameworks.system.directoryservices.Protocols
1010
private import semmle.code.csharp.security.Sanitizers
11+
private import semmle.code.csharp.dataflow.ExternalFlow
1112

1213
/**
1314
* A data flow source for unvalidated user input that is used to construct LDAP queries.
@@ -68,6 +69,11 @@ module LdapInjection = TaintTracking::Global<LdapInjectionConfig>;
6869
/** A source of remote user input. */
6970
class RemoteSource extends Source instanceof RemoteFlowSource { }
7071

72+
/** LDAP sinks defined through Models as Data. */
73+
private class ExternalLdapExprSink extends Sink {
74+
ExternalLdapExprSink() { sinkNode(this, "ldap-injection") }
75+
}
76+
7177
/**
7278
* An argument that sets the `Path` property of a `DirectoryEntry` object that is a sink for LDAP
7379
* injection.

csharp/ql/lib/semmle/code/csharp/security/dataflow/LogForgingQuery.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private import semmle.code.csharp.frameworks.System
88
private import semmle.code.csharp.frameworks.system.text.RegularExpressions
99
private import semmle.code.csharp.security.Sanitizers
1010
private import semmle.code.csharp.security.dataflow.flowsinks.ExternalLocationSink
11+
private import semmle.code.csharp.dataflow.ExternalFlow
1112

1213
/**
1314
* A data flow source for untrusted user input used in log entries.
@@ -72,6 +73,11 @@ private class LogForgingLogMessageSink extends Sink, LogMessageSink { }
7273
*/
7374
private class LogForgingTraceMessageSink extends Sink, TraceMessageSink { }
7475

76+
/** Log Forging sinks defined through Models as Data. */
77+
private class ExternalLoggingExprSink extends Sink {
78+
ExternalLoggingExprSink() { sinkNode(this, "log-injection") }
79+
}
80+
7581
/**
7682
* A call to String replace or remove that is considered to sanitize replaced string.
7783
*/

csharp/ql/lib/semmle/code/csharp/security/dataflow/UrlRedirectQuery.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ private import semmle.code.csharp.frameworks.system.Web
99
private import semmle.code.csharp.frameworks.system.web.Mvc
1010
private import semmle.code.csharp.security.Sanitizers
1111
private import semmle.code.csharp.frameworks.microsoft.AspNetCore
12+
private import semmle.code.csharp.dataflow.ExternalFlow
1213

1314
/**
1415
* A data flow source for unvalidated URL redirect vulnerabilities.
@@ -70,6 +71,11 @@ module UrlRedirect = TaintTracking::Global<UrlRedirectConfig>;
7071
/** A source of remote user input. */
7172
class RemoteSource extends Source instanceof RemoteFlowSource { }
7273

74+
/** URL Redirection sinks defined through Models as Data. */
75+
private class ExternalUrlRedirectExprSink extends Sink {
76+
ExternalUrlRedirectExprSink() { sinkNode(this, "url-redirection") }
77+
}
78+
7379
/**
7480
* A URL argument to a call to `HttpResponse.Redirect()` or `Controller.Redirect()`, that is a
7581
* sink for URL redirects.

0 commit comments

Comments
 (0)