mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Use flowFrom.
This commit is contained in:
@@ -263,7 +263,7 @@ module FromSensitiveFlow = TaintTracking::Global<FromSensitiveConfig>;
|
|||||||
* A taint flow configuration for flow from a sensitive expression to an encryption operation.
|
* A taint flow configuration for flow from a sensitive expression to an encryption operation.
|
||||||
*/
|
*/
|
||||||
module ToEncryptionConfig implements DataFlow::ConfigSig {
|
module ToEncryptionConfig implements DataFlow::ConfigSig {
|
||||||
predicate isSource(DataFlow::Node source) { FromSensitiveFlow::flow(source, _) }
|
predicate isSource(DataFlow::Node source) { FromSensitiveFlow::flowFrom(source) }
|
||||||
|
|
||||||
predicate isSink(DataFlow::Node sink) { isSinkEncrypt(sink, _) }
|
predicate isSink(DataFlow::Node sink) { isSinkEncrypt(sink, _) }
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ where
|
|||||||
FromSensitiveFlow::flowPath(source, sink) and
|
FromSensitiveFlow::flowPath(source, sink) and
|
||||||
isSinkSendRecv(sink.getNode(), networkSendRecv) and
|
isSinkSendRecv(sink.getNode(), networkSendRecv) and
|
||||||
// no flow from sensitive -> evidence of encryption
|
// no flow from sensitive -> evidence of encryption
|
||||||
not ToEncryptionFlow::flow(source.getNode(), _) and
|
not ToEncryptionFlow::flowFrom(source.getNode()) and
|
||||||
not FromEncryptionFlow::flowTo(sink.getNode()) and
|
not FromEncryptionFlow::flowTo(sink.getNode()) and
|
||||||
// construct result
|
// construct result
|
||||||
if networkSendRecv instanceof NetworkSend
|
if networkSendRecv instanceof NetworkSend
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ module PointerArithmeticToDerefFlow = DataFlow::Global<PointerArithmeticToDerefC
|
|||||||
|
|
||||||
predicate pointerArithOverflow(PointerArithmeticInstruction pai, int delta) {
|
predicate pointerArithOverflow(PointerArithmeticInstruction pai, int delta) {
|
||||||
pointerArithOverflow0(pai, delta) and
|
pointerArithOverflow0(pai, delta) and
|
||||||
PointerArithmeticToDerefFlow::flow(DataFlow::instructionNode(pai), _)
|
PointerArithmeticToDerefFlow::flowFrom(DataFlow::instructionNode(pai))
|
||||||
}
|
}
|
||||||
|
|
||||||
bindingset[v]
|
bindingset[v]
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class IDbCommandConstructionSqlExpr extends SqlExpr, ObjectCreation {
|
|||||||
class DapperCommandDefinitionMethodCallSqlExpr extends SqlExpr, ObjectCreation {
|
class DapperCommandDefinitionMethodCallSqlExpr extends SqlExpr, ObjectCreation {
|
||||||
DapperCommandDefinitionMethodCallSqlExpr() {
|
DapperCommandDefinitionMethodCallSqlExpr() {
|
||||||
this.getObjectType() instanceof Dapper::CommandDefinitionStruct and
|
this.getObjectType() instanceof Dapper::CommandDefinitionStruct and
|
||||||
DapperCommandDefinitionMethodCallSql::flow(DataFlow::exprNode(this), _)
|
DapperCommandDefinitionMethodCallSql::flowFromExpr(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override Expr getSql() { result = this.getArgumentForName("commandText") }
|
override Expr getSql() { result = this.getArgumentForName("commandText") }
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ predicate insecureCookieOptionsCreation(ObjectCreation oc) {
|
|||||||
// `Secure` property in `CookieOptions` passed to IResponseCookies.Append(...) wasn't set
|
// `Secure` property in `CookieOptions` passed to IResponseCookies.Append(...) wasn't set
|
||||||
oc.getType() instanceof MicrosoftAspNetCoreHttpCookieOptions and
|
oc.getType() instanceof MicrosoftAspNetCoreHttpCookieOptions and
|
||||||
secureFalseOrNotSet(oc) and
|
secureFalseOrNotSet(oc) and
|
||||||
exists(DataFlow::Node creation |
|
CookieOptionsTracking::flowFromExpr(oc)
|
||||||
CookieOptionsTracking::flow(creation, _) and
|
|
||||||
creation.asExpr() = oc
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
predicate insecureCookieAppend(Expr sink) {
|
predicate insecureCookieAppend(Expr sink) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module MissingJwtSignatureCheck {
|
|||||||
module Config implements DataFlow::ConfigSig {
|
module Config implements DataFlow::ConfigSig {
|
||||||
predicate isSource(DataFlow::Node source) {
|
predicate isSource(DataFlow::Node source) {
|
||||||
source instanceof Source and
|
source instanceof Source and
|
||||||
not SafeParse::flow(source, _)
|
not SafeParse::flowFrom(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
|
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module UnsafeUnzipSymlink {
|
|||||||
* Holds if `node` is an archive header field read that flows to a `path/filepath.EvalSymlinks` call.
|
* Holds if `node` is an archive header field read that flows to a `path/filepath.EvalSymlinks` call.
|
||||||
*/
|
*/
|
||||||
private predicate symlinksEvald(DataFlow::Node node) {
|
private predicate symlinksEvald(DataFlow::Node node) {
|
||||||
EvalSymlinksFlow::flow(getASimilarReadNode(node), _)
|
EvalSymlinksFlow::flowFrom(getASimilarReadNode(node))
|
||||||
}
|
}
|
||||||
|
|
||||||
private module Config implements DataFlow::ConfigSig {
|
private module Config implements DataFlow::ConfigSig {
|
||||||
|
|||||||
@@ -81,5 +81,5 @@ module Config implements DataFlow::ConfigSig {
|
|||||||
module Flow = DataFlow::Global<Config>;
|
module Flow = DataFlow::Global<Config>;
|
||||||
|
|
||||||
from DataFlow::Node source, string msg
|
from DataFlow::Node source, string msg
|
||||||
where Flow::flow(source, _) and Config::isSourceString(source, msg)
|
where Flow::flowFrom(source) and Config::isSourceString(source, msg)
|
||||||
select source, msg
|
select source, msg
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ module FlowToPrintFlow = DataFlow::Global<FlowToPrintConfig>;
|
|||||||
|
|
||||||
/** Holds if the provided `CallNode`'s result flows to an argument of a printer call. */
|
/** Holds if the provided `CallNode`'s result flows to an argument of a printer call. */
|
||||||
predicate resultFlowsToPrinter(DataFlow::CallNode authCodeUrlCall) {
|
predicate resultFlowsToPrinter(DataFlow::CallNode authCodeUrlCall) {
|
||||||
FlowToPrintFlow::flow(authCodeUrlCall.getResult(), _)
|
FlowToPrintFlow::flowFrom(authCodeUrlCall.getResult())
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a data-flow node that reads the value of `os.Stdin`. */
|
/** Get a data-flow node that reads the value of `os.Stdin`. */
|
||||||
|
|||||||
@@ -70,5 +70,6 @@ module PamStartToAuthenticateFlow = TaintTracking::Global<PamStartToAuthenticate
|
|||||||
from DataFlow::Node source, DataFlow::Node sink
|
from DataFlow::Node source, DataFlow::Node sink
|
||||||
where
|
where
|
||||||
not isInTestFile(source.asExpr()) and
|
not isInTestFile(source.asExpr()) and
|
||||||
(PamStartToAuthenticateFlow::flow(source, sink) and not PamStartToAcctMgmtFlow::flow(source, _))
|
PamStartToAuthenticateFlow::flow(source, sink) and
|
||||||
|
not PamStartToAcctMgmtFlow::flowFrom(source)
|
||||||
select source, "This Pam transaction may not be secure."
|
select source, "This Pam transaction may not be secure."
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module JwtParseWithConstantKeyConfig implements DataFlow::ConfigSig {
|
|||||||
or
|
or
|
||||||
n = fd.(FuncDecl).getFunction().getARead()
|
n = fd.(FuncDecl).getFunction().getARead()
|
||||||
|
|
|
|
||||||
GolangJwtKeyFunc::flow(n, _) and
|
GolangJwtKeyFunc::flowFrom(n) and
|
||||||
sink = rn and
|
sink = rn and
|
||||||
rn.getRoot() = fd and
|
rn.getRoot() = fd and
|
||||||
rn.getIndex() = 0
|
rn.getIndex() = 0
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ private module TypeLiteralToParseAsFlowConfig implements DataFlow::ConfigSig {
|
|||||||
|
|
||||||
private module TypeLiteralToParseAsFlow = DataFlow::Global<TypeLiteralToParseAsFlowConfig>;
|
private module TypeLiteralToParseAsFlow = DataFlow::Global<TypeLiteralToParseAsFlowConfig>;
|
||||||
|
|
||||||
private TypeLiteral getSourceWithFlowToParseAs() {
|
private TypeLiteral getSourceWithFlowToParseAs() { TypeLiteralToParseAsFlow::flowFromExpr(result) }
|
||||||
TypeLiteralToParseAsFlow::flow(DataFlow::exprNode(result), _)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A field that is deserialized by `HttpResponse.parseAs`. */
|
/** A field that is deserialized by `HttpResponse.parseAs`. */
|
||||||
class HttpResponseParseAsDeserializableField extends DeserializableField {
|
class HttpResponseParseAsDeserializableField extends DeserializableField {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ private module TypeLiteralToJacksonDatabindFlow =
|
|||||||
DataFlow::Global<TypeLiteralToJacksonDatabindFlowConfig>;
|
DataFlow::Global<TypeLiteralToJacksonDatabindFlowConfig>;
|
||||||
|
|
||||||
private TypeLiteral getSourceWithFlowToJacksonDatabind() {
|
private TypeLiteral getSourceWithFlowToJacksonDatabind() {
|
||||||
TypeLiteralToJacksonDatabindFlow::flow(DataFlow::exprNode(result), _)
|
TypeLiteralToJacksonDatabindFlow::flowFromExpr(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A type whose values are explicitly deserialized in a call to a Jackson method. */
|
/** A type whose values are explicitly deserialized in a call to a Jackson method. */
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ private module RegexFlowConfig implements DataFlow::ConfigSig {
|
|||||||
private module RegexFlow = DataFlow::Global<RegexFlowConfig>;
|
private module RegexFlow = DataFlow::Global<RegexFlowConfig>;
|
||||||
|
|
||||||
private predicate usedAsRegexImpl(StringLiteral regex, string mode, boolean match_full_string) {
|
private predicate usedAsRegexImpl(StringLiteral regex, string mode, boolean match_full_string) {
|
||||||
RegexFlow::flow(DataFlow::exprNode(regex), _) and
|
RegexFlow::flowFromExpr(regex) and
|
||||||
mode = "None" and // TODO: proper mode detection
|
mode = "None" and // TODO: proper mode detection
|
||||||
(if matchesFullString(regex) then match_full_string = true else match_full_string = false)
|
(if matchesFullString(regex) then match_full_string = true else match_full_string = false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ private module VerifiedIntentFlow = DataFlow::Global<VerifiedIntentConfig>;
|
|||||||
/** An `onReceive` method that doesn't verify the action of the intent it receives. */
|
/** An `onReceive` method that doesn't verify the action of the intent it receives. */
|
||||||
private class UnverifiedOnReceiveMethod extends OnReceiveMethod {
|
private class UnverifiedOnReceiveMethod extends OnReceiveMethod {
|
||||||
UnverifiedOnReceiveMethod() {
|
UnverifiedOnReceiveMethod() {
|
||||||
not VerifiedIntentFlow::flow(DataFlow::parameterNode(this.getIntentParameter()), _) and
|
not VerifiedIntentFlow::flowFrom(DataFlow::parameterNode(this.getIntentParameter())) and
|
||||||
// Empty methods do not need to be verified since they do not perform any actions.
|
// Empty methods do not need to be verified since they do not perform any actions.
|
||||||
this.getBody().getNumStmt() > 0
|
this.getBody().getNumStmt() > 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ where
|
|||||||
// implicit: no setAllowContentAccess(false)
|
// implicit: no setAllowContentAccess(false)
|
||||||
exists(WebViewSource source |
|
exists(WebViewSource source |
|
||||||
source.asExpr() = e and
|
source.asExpr() = e and
|
||||||
not WebViewDisallowContentAccessFlow::flow(source, _)
|
not WebViewDisallowContentAccessFlow::flowFrom(source)
|
||||||
)
|
)
|
||||||
select e,
|
select e,
|
||||||
"Sensitive information may be exposed via a malicious link due to access to content:// links being allowed in this WebView."
|
"Sensitive information may be exposed via a malicious link due to access to content:// links being allowed in this WebView."
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ private module JxBrowserFlow = DataFlow::Global<JxBrowserFlowConfig>;
|
|||||||
|
|
||||||
deprecated query predicate problems(DataFlow::Node src, string message) {
|
deprecated query predicate problems(DataFlow::Node src, string message) {
|
||||||
JxBrowserFlowConfig::isSource(src) and
|
JxBrowserFlowConfig::isSource(src) and
|
||||||
not JxBrowserFlow::flow(src, _) and
|
not JxBrowserFlow::flowFrom(src) and
|
||||||
not isSafeJxBrowserVersion() and
|
not isSafeJxBrowserVersion() and
|
||||||
message = "This JxBrowser instance may not check HTTPS certificates."
|
message = "This JxBrowser instance may not check HTTPS certificates."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ private Expr getAccessControlAllowOriginHeaderName() {
|
|||||||
* A taint-tracking configuration for flow from a source node to CorsProbableCheckAccess methods.
|
* A taint-tracking configuration for flow from a source node to CorsProbableCheckAccess methods.
|
||||||
*/
|
*/
|
||||||
module CorsSourceReachesCheckConfig implements DataFlow::ConfigSig {
|
module CorsSourceReachesCheckConfig implements DataFlow::ConfigSig {
|
||||||
predicate isSource(DataFlow::Node source) { CorsOriginFlow::flow(source, _) }
|
predicate isSource(DataFlow::Node source) { CorsOriginFlow::flowFrom(source) }
|
||||||
|
|
||||||
predicate isSink(DataFlow::Node sink) {
|
predicate isSink(DataFlow::Node sink) {
|
||||||
sink.asExpr() = any(CorsProbableCheckAccess check).getAnArgument()
|
sink.asExpr() = any(CorsProbableCheckAccess check).getAnArgument()
|
||||||
@@ -86,7 +86,7 @@ deprecated query predicate problems(
|
|||||||
string message1, DataFlow::Node sourceNode, string message2
|
string message1, DataFlow::Node sourceNode, string message2
|
||||||
) {
|
) {
|
||||||
CorsOriginFlow::flowPath(source, sink) and
|
CorsOriginFlow::flowPath(source, sink) and
|
||||||
not CorsSourceReachesCheckFlow::flow(sourceNode, _) and
|
not CorsSourceReachesCheckFlow::flowFrom(sourceNode) and
|
||||||
sinkNode = sink.getNode() and
|
sinkNode = sink.getNode() and
|
||||||
message1 = "CORS header is being set using user controlled value $@." and
|
message1 = "CORS header is being set using user controlled value $@." and
|
||||||
sourceNode = source.getNode() and
|
sourceNode = source.getNode() and
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ deprecated import JwtAuth0 as JwtAuth0
|
|||||||
deprecated module JwtDecodeConfig implements DataFlow::ConfigSig {
|
deprecated module JwtDecodeConfig implements DataFlow::ConfigSig {
|
||||||
predicate isSource(DataFlow::Node source) {
|
predicate isSource(DataFlow::Node source) {
|
||||||
source instanceof RemoteFlowSource and
|
source instanceof RemoteFlowSource and
|
||||||
not FlowToJwtVerify::flow(source, _)
|
not FlowToJwtVerify::flowFrom(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(JwtAuth0::GetPayload a) }
|
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(JwtAuth0::GetPayload a) }
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ module Config implements DataFlow::ConfigSig {
|
|||||||
|
|
||||||
module Flow = DataFlow::Global<Config>;
|
module Flow = DataFlow::Global<Config>;
|
||||||
|
|
||||||
predicate isSunk(StringLiteral sl) {
|
predicate isSunk(StringLiteral sl) { Flow::flowFromExpr(sl) }
|
||||||
exists(DataFlow::Node source | Flow::flow(source, _) and sl = source.asExpr())
|
|
||||||
}
|
|
||||||
|
|
||||||
query predicate shouldBeSunkButIsnt(ShouldBeSunk src) { not isSunk(src) }
|
query predicate shouldBeSunkButIsnt(ShouldBeSunk src) { not isSunk(src) }
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ module Config implements DataFlow::ConfigSig {
|
|||||||
|
|
||||||
module Flow = DataFlow::Global<Config>;
|
module Flow = DataFlow::Global<Config>;
|
||||||
|
|
||||||
predicate isSunk(StringLiteral sl) {
|
predicate isSunk(StringLiteral sl) { Flow::flowFromExpr(sl) }
|
||||||
exists(DataFlow::Node source | Flow::flow(source, _) and sl = source.asExpr())
|
|
||||||
}
|
|
||||||
|
|
||||||
query predicate shouldBeSunkButIsnt(ShouldBeSunk src) { not isSunk(src) }
|
query predicate shouldBeSunkButIsnt(ShouldBeSunk src) { not isSunk(src) }
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module FlowStepTest implements TestSig {
|
|||||||
predicate hasActualResult(Location l, string element, string tag, string value) {
|
predicate hasActualResult(Location l, string element, string tag, string value) {
|
||||||
tag = "taintReachesReturn" and
|
tag = "taintReachesReturn" and
|
||||||
value = "" and
|
value = "" and
|
||||||
exists(DataFlow::Node source | Flow::flow(source, _) |
|
exists(DataFlow::Node source | Flow::flowFrom(source) |
|
||||||
l = source.getLocation() and
|
l = source.getLocation() and
|
||||||
element = source.toString()
|
element = source.toString()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module SinkTest implements TestSig {
|
|||||||
predicate hasActualResult(Location l, string element, string tag, string value) {
|
predicate hasActualResult(Location l, string element, string tag, string value) {
|
||||||
tag = "taintReachesSink" and
|
tag = "taintReachesSink" and
|
||||||
value = "" and
|
value = "" and
|
||||||
exists(DataFlow::Node source | Flow::flow(source, _) |
|
exists(DataFlow::Node source | Flow::flowFrom(source) |
|
||||||
l = source.getLocation() and
|
l = source.getLocation() and
|
||||||
element = source.toString()
|
element = source.toString()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ import UnverifiedDecodeFlow::PathGraph
|
|||||||
from UnverifiedDecodeFlow::PathNode source, UnverifiedDecodeFlow::PathNode sink
|
from UnverifiedDecodeFlow::PathNode source, UnverifiedDecodeFlow::PathNode sink
|
||||||
where
|
where
|
||||||
UnverifiedDecodeFlow::flowPath(source, sink) and
|
UnverifiedDecodeFlow::flowPath(source, sink) and
|
||||||
not VerifiedDecodeFlow::flow(source.getNode(), _)
|
not VerifiedDecodeFlow::flowFrom(source.getNode())
|
||||||
select source.getNode(), source, sink, "Decoding JWT $@.", sink.getNode(),
|
select source.getNode(), source, sink, "Decoding JWT $@.", sink.getNode(),
|
||||||
"without signature verification"
|
"without signature verification"
|
||||||
|
|||||||
Reference in New Issue
Block a user