Skip to content

Commit 004d40e

Browse files
committed
Allow MaD barriers using sink kinds
1 parent 8257475 commit 004d40e

File tree

7 files changed

+42
-6
lines changed

7 files changed

+42
-6
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ class RoslynCSharpScriptSink extends Sink {
9595
}
9696
}
9797

98-
/** Code injection sinks defined through CSV models. */
98+
/** A code injection sink defined through Models as Data. */
9999
private class ExternalCodeInjectionExprSink extends Sink {
100100
ExternalCodeInjectionExprSink() { sinkNode(this, "code-injection") }
101101
}
102+
103+
/** A sanitizer for code injection defined through Models as Data. */
104+
private class ExternalCodeInjectionSanitizer extends Sanitizer {
105+
ExternalCodeInjectionSanitizer() { barrierNode(this, "code-injection") }
106+
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource
6161
/** A source supported by the current threat model. */
6262
class ThreatModelSource extends Source instanceof ActiveThreatModelSource { }
6363

64-
/** Command Injection sinks defined through Models as Data. */
64+
/** A Command Injection sink defined through Models as Data. */
6565
private class ExternalCommandInjectionExprSink extends Sink {
6666
ExternalCommandInjectionExprSink() { sinkNode(this, "command-injection") }
6767
}
6868

69+
/** A sanitizer for command injection defined through Models as Data. */
70+
private class ExternalCommandInjectionSanitizer extends Sanitizer {
71+
ExternalCommandInjectionSanitizer() { barrierNode(this, "command-injection") }
72+
}
73+
6974
/**
7075
* A sink in `System.Diagnostic.Process` or its related classes.
7176
*/

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource
6464
/** A source supported by the current threat model. */
6565
class ThreatModelSource extends Source instanceof ActiveThreatModelSource { }
6666

67-
/** LDAP sinks defined through Models as Data. */
67+
/** An LDAP sink defined through Models as Data. */
6868
private class ExternalLdapExprSink extends Sink {
6969
ExternalLdapExprSink() { sinkNode(this, "ldap-injection") }
7070
}
7171

72+
/** A sanitizer for LDAP injection defined through Models as Data. */
73+
private class ExternalLdapInjectionSanitizer extends Sanitizer {
74+
ExternalLdapInjectionSanitizer() { barrierNode(this, "ldap-injection") }
75+
}
76+
7277
/**
7378
* An argument that sets the `Path` property of a `DirectoryEntry` object that is a sink for LDAP
7479
* injection.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ private class LogForgingLogMessageSink extends Sink, LogMessageSink { }
6161
*/
6262
private class LogForgingTraceMessageSink extends Sink, TraceMessageSink { }
6363

64-
/** Log Forging sinks defined through Models as Data. */
64+
/** A Log Forging sink defined through Models as Data. */
6565
private class ExternalLoggingExprSink extends Sink {
6666
ExternalLoggingExprSink() { sinkNode(this, "log-injection") }
6767
}
6868

69+
/** A sanitizer for log forging defined through Models as Data. */
70+
private class ExternalLogForgingSanitizer extends Sanitizer {
71+
ExternalLogForgingSanitizer() { barrierNode(this, "log-injection") }
72+
}
73+
6974
/**
7075
* A call to String replace or remove that is considered to sanitize replaced string.
7176
*/

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ class SqlInjectionExprSink extends Sink {
7474
SqlInjectionExprSink() { exists(SqlExpr s | this.getExpr() = s.getSql()) }
7575
}
7676

77-
/** SQL sinks defined through CSV models. */
77+
/** An SQL sink defined through CSV models. */
7878
private class ExternalSqlInjectionExprSink extends Sink {
7979
ExternalSqlInjectionExprSink() { sinkNode(this, "sql-injection") }
8080
}
8181

82+
/** A sanitizer for SQL injection defined through Models as Data. */
83+
private class ExternalSqlInjectionSanitizer extends Sanitizer {
84+
ExternalSqlInjectionSanitizer() { barrierNode(this, "sql-injection") }
85+
}
86+
8287
private class SimpleTypeSanitizer extends Sanitizer, SimpleTypeSanitizedExpr { }
8388

8489
private class GuidSanitizer extends Sanitizer, GuidSanitizedExpr { }

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,16 @@ deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource
5656
/** A source supported by the current threat model. */
5757
class ThreatModelSource extends Source instanceof ActiveThreatModelSource { }
5858

59-
/** URL Redirection sinks defined through Models as Data. */
59+
/** A URL Redirection sink defined through Models as Data. */
6060
private class ExternalUrlRedirectExprSink extends Sink {
6161
ExternalUrlRedirectExprSink() { sinkNode(this, "url-redirection") }
6262
}
6363

64+
/** A sanitizer for URL redirection defined through Models as Data. */
65+
private class ExternalUrlRedirectSanitizer extends Sanitizer {
66+
ExternalUrlRedirectSanitizer() { barrierNode(this, "url-redirection") }
67+
}
68+
6469
/**
6570
* A URL argument to a call to `HttpResponse.Redirect()` or `Controller.Redirect()`, that is a
6671
* sink for URL redirects.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import csharp
77
private import XSSSinks
88
private import semmle.code.csharp.security.Sanitizers
99
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
10+
private import semmle.code.csharp.dataflow.internal.ExternalFlow
1011

1112
/**
1213
* Holds if there is tainted flow from `source` to `sink` that may lead to a
@@ -169,6 +170,11 @@ private class SimpleTypeSanitizer extends Sanitizer, SimpleTypeSanitizedExpr { }
169170

170171
private class GuidSanitizer extends Sanitizer, GuidSanitizedExpr { }
171172

173+
/** A sanitizer for XSS defined through Models as Data. */
174+
private class ExternalXssSanitizer extends Sanitizer {
175+
ExternalXssSanitizer() { barrierNode(this, ["html-injection", "js-injection"]) }
176+
}
177+
172178
/** A call to an HTML encoder. */
173179
private class HtmlEncodeSanitizer extends Sanitizer {
174180
HtmlEncodeSanitizer() { this.getExpr() instanceof HtmlSanitizedExpr }

0 commit comments

Comments
 (0)