mirror of
https://github.com/github/codeql.git
synced 2026-07-20 02:38:23 +02:00
Merge pull request #15419 from github/egregius313/csharp/dataflow/threat-modeling/refactor-to-threatmodelflowsource
C#: Refactor C# queries to use `ThreatModelFlowSource` instead of `RemoteFlowSource`
This commit is contained in:
@@ -49,6 +49,8 @@ module EntityFramework {
|
||||
StoredFlowSource() {
|
||||
this.asExpr() = any(PropertyRead read | read.getTarget() instanceof MappedProperty)
|
||||
}
|
||||
|
||||
override string getSourceType() { result = "ORM mapped property" }
|
||||
}
|
||||
|
||||
private class EFClass extends Class {
|
||||
|
||||
@@ -91,6 +91,8 @@ module NHibernate {
|
||||
StoredFlowSource() {
|
||||
this.asExpr() = any(PropertyRead read | read.getTarget() instanceof MappedProperty)
|
||||
}
|
||||
|
||||
override string getSourceType() { result = "ORM mapped property" }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/** Definitions for the Insecure Direct Object Reference query */
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
deprecated import semmle.code.csharp.dataflow.flowsources.Remote
|
||||
import ActionMethods
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,7 @@ private predicate needsChecks(ActionMethod m) { m.isEdit() and not m.isAdmin() }
|
||||
* that may indicate that it's used as the ID for some resource
|
||||
*/
|
||||
private predicate hasIdParameter(ActionMethod m) {
|
||||
exists(RemoteFlowSource src | src.getEnclosingCallable() = m |
|
||||
exists(ThreatModelFlowSource src | src.getEnclosingCallable() = m |
|
||||
src.asParameter().getName().toLowerCase().matches(["%id", "%idx"])
|
||||
or
|
||||
// handle cases like `Request.QueryString["Id"]`
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Local
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.codedom.Compiler
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
private import semmle.code.csharp.dataflow.internal.ExternalFlow
|
||||
@@ -55,11 +54,24 @@ private module CodeInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module CodeInjection = TaintTracking::Global<CodeInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source of local user input. */
|
||||
class LocalSource extends Source instanceof LocalFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of local user input.
|
||||
*/
|
||||
deprecated class LocalSource extends DataFlow::Node instanceof LocalFlowSource { }
|
||||
|
||||
private class AddLocalSource extends Source instanceof LocalFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
private class SimpleTypeSanitizer extends Sanitizer, SimpleTypeSanitizedExpr { }
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.Diagnostics
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
private import semmle.code.csharp.dataflow.internal.ExternalFlow
|
||||
@@ -64,8 +64,15 @@ module CommandInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module CommandInjection = TaintTracking::Global<CommandInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** Command Injection sinks defined through Models as Data. */
|
||||
private class ExternalCommandInjectionExprSink extends Sink {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import csharp
|
||||
private import semmle.code.csharp.controlflow.Guards
|
||||
private import semmle.code.csharp.controlflow.BasicBlocks
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.System
|
||||
private import semmle.code.csharp.frameworks.system.Net
|
||||
private import semmle.code.csharp.security.SensitiveActions
|
||||
@@ -60,8 +60,15 @@ private module ConditionalBypassConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module ConditionalBypass = TaintTracking::Global<ConditionalBypassConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** The result of a reverse dns may be user-controlled. */
|
||||
class ReverseDnsSource extends Source {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.security.dataflow.flowsinks.ExternalLocationSink
|
||||
private import semmle.code.csharp.security.PrivateData
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.commons.QualifiedName
|
||||
private import semmle.code.csharp.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.System
|
||||
private import semmle.code.csharp.dataflow.FlowSummary
|
||||
|
||||
@@ -92,19 +92,19 @@ class ExternalApiDataNode extends DataFlow::Node {
|
||||
deprecated class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration {
|
||||
UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof ThreatModelFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
/** A configuration for tracking flow from `ThreatModelFlowSource`s to `ExternalApiDataNode`s. */
|
||||
private module RemoteSourceToExternalApiConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
predicate isSource(DataFlow::Node source) { source instanceof ThreatModelFlowSource }
|
||||
|
||||
predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
|
||||
}
|
||||
|
||||
/** A module for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
/** A module for tracking flow from `ThreatModelFlowSource`s to `ExternalApiDataNode`s. */
|
||||
module RemoteSourceToExternalApi = TaintTracking::Global<RemoteSourceToExternalApiConfig>;
|
||||
|
||||
/** A node representing untrusted data being passed to an external API. */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.DirectoryServices
|
||||
private import semmle.code.csharp.frameworks.system.directoryservices.Protocols
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
@@ -66,8 +66,15 @@ module LdapInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module LdapInjection = TaintTracking::Global<LdapInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreadModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** LDAP sinks defined through Models as Data. */
|
||||
private class ExternalLdapExprSink extends Sink {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.System
|
||||
private import semmle.code.csharp.frameworks.system.text.RegularExpressions
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
@@ -57,7 +57,7 @@ private module LogForgingConfig implements DataFlow::ConfigSig {
|
||||
module LogForging = TaintTracking::Global<LogForgingConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
private class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
private class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
private class HtmlSanitizer extends Sanitizer {
|
||||
HtmlSanitizer() { this.asExpr() instanceof HtmlSanitizedExpr }
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.Xml
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
|
||||
@@ -62,8 +62,17 @@ private module MissingXmlValidationConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module MissingXmlValidation = TaintTracking::Global<MissingXmlValidationConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelFlowSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/**
|
||||
* A source supported by the current threat model.
|
||||
*/
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* The input argument to a call to `XmlReader.Create` where the input will not be validated against
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.dataflow.DataFlow2
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.text.RegularExpressions
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
|
||||
@@ -55,8 +55,15 @@ private module ReDoSConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module ReDoS = TaintTracking::Global<ReDoSConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* An expression that represents a regular expression with potential exponential behavior.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.text.RegularExpressions
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
|
||||
@@ -54,8 +54,15 @@ private module RegexInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module RegexInjection = TaintTracking::Global<RegexInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* A `pattern` argument to a construction of a `Regex`.
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Local
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.Data
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
|
||||
@@ -54,11 +53,24 @@ private module ResourceInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module ResourceInjection = TaintTracking::Global<ResourceInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source of local user input. */
|
||||
class LocalSource extends Source instanceof LocalFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of local user input.
|
||||
*/
|
||||
deprecated class LocalSource extends DataFlow::Node instanceof LocalFlowSource { }
|
||||
|
||||
private class AddLocalSource extends Source instanceof LocalFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** An argument to the `ConnectionString` property on a data connection class. */
|
||||
class SqlConnectionStringSink extends Sink {
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Local
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.Sql
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
private import semmle.code.csharp.dataflow.internal.ExternalFlow
|
||||
@@ -65,11 +64,24 @@ module SqlInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module SqlInjection = TaintTracking::Global<SqlInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source of local user input. */
|
||||
class LocalSource extends Source instanceof LocalFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of local user input.
|
||||
*/
|
||||
deprecated class LocalSource extends DataFlow::Node instanceof LocalFlowSource { }
|
||||
|
||||
private class AddLocalSource extends Source instanceof LocalFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** An SQL expression passed to an API call that executes SQL. */
|
||||
class SqlInjectionExprSink extends Sink {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.controlflow.Guards
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.IO
|
||||
private import semmle.code.csharp.frameworks.system.Web
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
@@ -56,8 +56,15 @@ private module TaintedPathConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module TaintedPath = TaintTracking::Global<TaintedPathConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* A path argument to a `File` method call.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import csharp
|
||||
private import semmle.code.csharp.serialization.Deserializers
|
||||
private import semmle.code.csharp.dataflow.TaintTracking2
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
|
||||
/**
|
||||
* A data flow source for unsafe deserialization vulnerabilities.
|
||||
@@ -48,7 +48,7 @@ abstract private class ConstructorOrStaticMethodSink extends Sink { }
|
||||
*/
|
||||
abstract class Sanitizer extends DataFlow::Node { }
|
||||
|
||||
private class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
private class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `TaintToObjectMethodTracking` instead.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.controlflow.Guards
|
||||
private import semmle.code.csharp.frameworks.Format
|
||||
private import semmle.code.csharp.frameworks.system.Web
|
||||
@@ -58,8 +58,15 @@ private module UrlRedirectConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module UrlRedirect = TaintTracking::Global<UrlRedirectConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** URL Redirection sinks defined through Models as Data. */
|
||||
private class ExternalUrlRedirectExprSink extends Sink {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.System
|
||||
private import semmle.code.csharp.frameworks.system.text.RegularExpressions
|
||||
private import semmle.code.csharp.security.xml.InsecureXMLQuery as InsecureXml
|
||||
@@ -14,7 +14,7 @@ private import semmle.code.csharp.security.Sanitizers
|
||||
*/
|
||||
abstract class Source extends DataFlow::Node { }
|
||||
|
||||
private class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
private class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* A data flow sink for untrusted user input used in XML processing.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.frameworks.system.xml.XPath
|
||||
private import semmle.code.csharp.frameworks.system.Xml
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
@@ -64,8 +64,15 @@ module XpathInjectionConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module XpathInjection = TaintTracking::Global<XpathInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/** The `xpath` argument to an `XPathExpression.Compile(..)` call. */
|
||||
class XPathExpressionCompileSink extends Sink {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import csharp
|
||||
private import XSSSinks
|
||||
private import semmle.code.csharp.security.Sanitizers
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
private import semmle.code.csharp.dataflow.DataFlow2
|
||||
private import semmle.code.csharp.dataflow.TaintTracking2
|
||||
|
||||
@@ -179,8 +179,8 @@ module XssTrackingConfig implements DataFlow::ConfigSig {
|
||||
|
||||
module XssTracking = TaintTracking::Global<XssTrackingConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
private class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/** A source supported by the current threat model. */
|
||||
private class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
private class SimpleTypeSanitizer extends Sanitizer, SimpleTypeSanitizedExpr { }
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ abstract class SourceNode extends DataFlow::Node {
|
||||
* Gets a string that represents the source kind with respect to threat modeling.
|
||||
*/
|
||||
abstract string getThreatModel();
|
||||
|
||||
/** Gets a string that describes the type of this flow source. */
|
||||
abstract string getSourceType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,7 @@ private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
|
||||
/** A data flow source of local data. */
|
||||
abstract class LocalFlowSource extends SourceNode {
|
||||
/** Gets a string that describes the type of this local flow source. */
|
||||
abstract string getSourceType();
|
||||
override string getSourceType() { result = "local flow source" }
|
||||
|
||||
override string getThreatModel() { result = "local" }
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ private import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
|
||||
/** A data flow source of remote user input. */
|
||||
abstract class RemoteFlowSource extends SourceNode {
|
||||
/** Gets a string that describes the type of this remote flow source. */
|
||||
abstract string getSourceType();
|
||||
override string getSourceType() { result = "remote flow source" }
|
||||
|
||||
override string getThreatModel() { result = "remote" }
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ abstract class StoredFlowSource extends SourceNode {
|
||||
*/
|
||||
abstract class DatabaseInputSource extends StoredFlowSource {
|
||||
override string getThreatModel() { result = "database" }
|
||||
|
||||
override string getSourceType() { result = "database input" }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +78,6 @@ class FileStreamStoredFlowSource extends StoredFlowSource {
|
||||
FileStreamStoredFlowSource() { sourceNode(this, "file") }
|
||||
|
||||
override string getThreatModel() { result = "file" }
|
||||
|
||||
override string getSourceType() { result = "file stream" }
|
||||
}
|
||||
|
||||
@@ -14,14 +14,9 @@
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.SqlInjectionQuery
|
||||
import SqlInjection::PathGraph
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Local
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
|
||||
string getSourceType(DataFlow::Node node) {
|
||||
result = node.(RemoteFlowSource).getSourceType()
|
||||
or
|
||||
result = node.(LocalFlowSource).getSourceType()
|
||||
}
|
||||
string getSourceType(DataFlow::Node node) { result = node.(SourceNode).getSourceType() }
|
||||
|
||||
from SqlInjection::PathNode source, SqlInjection::PathNode sink
|
||||
where SqlInjection::flowPath(source, sink)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
import semmle.code.csharp.frameworks.system.Xml
|
||||
import XmlInjection::PathGraph
|
||||
|
||||
@@ -20,7 +20,7 @@ import XmlInjection::PathGraph
|
||||
* A taint-tracking configuration for untrusted user input used in XML.
|
||||
*/
|
||||
module XmlInjectionConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
predicate isSource(DataFlow::Node source) { source instanceof ThreatModelFlowSource }
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(MethodCall mc |
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
import semmle.code.csharp.commons.Util
|
||||
import AssemblyPathInjection::PathGraph
|
||||
|
||||
@@ -22,7 +22,7 @@ import AssemblyPathInjection::PathGraph
|
||||
*/
|
||||
module AssemblyPathInjectionConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source instanceof RemoteFlowSource or
|
||||
source instanceof ThreatModelFlowSource or
|
||||
source.asExpr() = any(MainMethod main).getParameter(0).getAnAccess()
|
||||
}
|
||||
|
||||
|
||||
@@ -12,16 +12,13 @@
|
||||
*/
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Local
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
import semmle.code.csharp.frameworks.Format
|
||||
import FormatString::PathGraph
|
||||
|
||||
module FormatStringConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source instanceof RemoteFlowSource
|
||||
or
|
||||
source instanceof LocalFlowSource
|
||||
source instanceof ThreatModelFlowSource or source instanceof LocalFlowSource
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
@@ -31,11 +28,7 @@ module FormatStringConfig implements DataFlow::ConfigSig {
|
||||
|
||||
module FormatString = TaintTracking::Global<FormatStringConfig>;
|
||||
|
||||
string getSourceType(DataFlow::Node node) {
|
||||
result = node.(RemoteFlowSource).getSourceType()
|
||||
or
|
||||
result = node.(LocalFlowSource).getSourceType()
|
||||
}
|
||||
string getSourceType(DataFlow::Node node) { result = node.(SourceNode).getSourceType() }
|
||||
|
||||
from FormatString::PathNode source, FormatString::PathNode sink
|
||||
where FormatString::flowPath(source, sink)
|
||||
|
||||
4
csharp/ql/src/change-notes/2024-02-06-threat-models.md
Normal file
4
csharp/ql/src/change-notes/2024-02-06-threat-models.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Most data flow queries that track flow from *remote* flow sources now use the current *threat model* configuration instead. This doesn't lead to any changes in the produced alerts (as the default configuration is *remote* flow sources) unless the threat model configuration is changed. The changed queries are `cs/code-injection`, `cs/command-line-injection`, `cs/user-controlled-bypass`, `cs/count-untrusted-data-external-api`, `cs/untrusted-data-to-external-api`, `cs/ldap-injection`, `cs/log-forging`, `cs/xml/missing-validation`, `cs/redos`, `cs/regex-injection`, `cs/resource-injection`, `cs/sql-injection`, `cs/path-injection`, `cs/unsafe-deserialization-untrusted-input`, `cs/web/unvalidated-url-redirection`, `cs/xml/insecure-dtd-handling`, `cs/xml/xpath-injection`, `cs/web/xss`, and `cs/uncontrolled-format-string`.
|
||||
@@ -1,7 +1,7 @@
|
||||
import csharp
|
||||
import semmle.code.csharp.frameworks.system.Net
|
||||
import semmle.code.csharp.frameworks.System
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
import semmle.code.csharp.security.Sanitizers
|
||||
|
||||
//If this leaves experimental this should probably go in semmle.code.csharp.frameworks.system.Net
|
||||
@@ -68,8 +68,15 @@ private module TaintedWebClientConfig implements DataFlow::ConfigSig {
|
||||
*/
|
||||
module TaintedWebClient = TaintTracking::Global<TaintedWebClientConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
/**
|
||||
* DEPRECATED: Use `ThreatModelSource` instead.
|
||||
*
|
||||
* A source of remote user input.
|
||||
*/
|
||||
deprecated class RemoteSource extends DataFlow::Node instanceof RemoteFlowSource { }
|
||||
|
||||
/** A source supported by the current threat model. */
|
||||
class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* A path argument to a `WebClient` method call that has an address argument.
|
||||
|
||||
@@ -5,7 +5,7 @@ module RequestForgery {
|
||||
import semmle.code.csharp.frameworks.System
|
||||
import semmle.code.csharp.frameworks.system.Web
|
||||
import semmle.code.csharp.frameworks.Format
|
||||
import semmle.code.csharp.security.dataflow.flowsources.Remote
|
||||
import semmle.code.csharp.security.dataflow.flowsources.FlowSources
|
||||
|
||||
/**
|
||||
* A data flow source for server side request forgery vulnerabilities.
|
||||
@@ -91,10 +91,9 @@ module RequestForgery {
|
||||
module RequestForgeryFlow = DataFlow::Global<RequestForgeryFlowConfig>;
|
||||
|
||||
/**
|
||||
* A remote data flow source taken as a source
|
||||
* for Server Side Request Forgery(SSRF) Vulnerabilities.
|
||||
* A dataflow source for Server Side Request Forgery(SSRF) Vulnerabilities.
|
||||
*/
|
||||
private class RemoteFlowSourceAsSource extends Source instanceof RemoteFlowSource { }
|
||||
private class ThreatModelSource extends Source instanceof ThreatModelFlowSource { }
|
||||
|
||||
/**
|
||||
* An url argument to a `HttpRequestMessage` constructor call
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
extensions:
|
||||
|
||||
- addsTo:
|
||||
pack: codeql/threat-models
|
||||
extensible: threatModelConfiguration
|
||||
data:
|
||||
- ["local", true, 0]
|
||||
Reference in New Issue
Block a user