mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
Merge pull request #10360 from atorralba/atorralba/fix-taint-implicit-reads
Dataflow: Fix implicit reads in taint tracking when FlowStates are used
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: fix
|
||||||
|
---
|
||||||
|
* Fixed an issue in the taint tracking analysis where implicit reads were not allowed by default in sinks or additional taint steps that used flow states.
|
||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: fix
|
||||||
|
---
|
||||||
|
* Fixed an issue in the taint tracking analysis where implicit reads were not allowed by default in sinks or additional taint steps that used flow states.
|
||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: fix
|
||||||
|
---
|
||||||
|
* Fixed an issue in the taint tracking analysis where implicit reads were not allowed by default in sinks or additional taint steps that used flow states.
|
||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
|
import java.util.Map;
|
||||||
import java.util.function.*;
|
import java.util.function.*;
|
||||||
|
|
||||||
public class A {
|
public class A {
|
||||||
Object source(String state) { return null; }
|
Object source(String state) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
void sink(Object x, String state) { }
|
void sink(Object x, String state) {}
|
||||||
|
|
||||||
void stateBarrier(Object x, String state) { }
|
void stateBarrier(Object x, String state) {}
|
||||||
|
|
||||||
Object step(Object x, String s1, String s2) { return null; }
|
Object step(Object x, String s1, String s2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
void check(Object x) { }
|
void check(Object x) {}
|
||||||
|
|
||||||
void test1() {
|
void test1() {
|
||||||
Object x = source("A");
|
Object x = source("A");
|
||||||
@@ -31,4 +36,13 @@ public class A {
|
|||||||
sink(x, "B"); // $ flow=B
|
sink(x, "B"); // $ flow=B
|
||||||
sink(x, "C"); // $ flow=B
|
sink(x, "C"); // $ flow=B
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test3(Map m) {
|
||||||
|
// Test implicit reads
|
||||||
|
Object x = source("A");
|
||||||
|
m.put("k", x);
|
||||||
|
sink(m, "A"); // $ flow=A
|
||||||
|
Object y = step(m, "A", "B");
|
||||||
|
sink(y, "B"); // $ flow=A
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import java
|
import java
|
||||||
import semmle.code.java.dataflow.DataFlow
|
import semmle.code.java.dataflow.TaintTracking
|
||||||
import TestUtilities.InlineExpectationsTest
|
import TestUtilities.InlineExpectationsTest
|
||||||
import DataFlow
|
import DataFlow
|
||||||
|
|
||||||
@@ -39,16 +39,16 @@ predicate step(Node n1, Node n2, string s1, string s2) {
|
|||||||
|
|
||||||
predicate checkNode(Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("check") }
|
predicate checkNode(Node n) { n.asExpr().(Argument).getCall().getCallee().hasName("check") }
|
||||||
|
|
||||||
class Conf extends Configuration {
|
class Conf extends TaintTracking::Configuration {
|
||||||
Conf() { this = "qltest:state" }
|
Conf() { this = "qltest:state" }
|
||||||
|
|
||||||
override predicate isSource(Node n, FlowState s) { src(n, s) }
|
override predicate isSource(Node n, FlowState s) { src(n, s) }
|
||||||
|
|
||||||
override predicate isSink(Node n, FlowState s) { sink(n, s) }
|
override predicate isSink(Node n, FlowState s) { sink(n, s) }
|
||||||
|
|
||||||
override predicate isBarrier(Node n, FlowState s) { bar(n, s) }
|
override predicate isSanitizer(Node n, FlowState s) { bar(n, s) }
|
||||||
|
|
||||||
override predicate isAdditionalFlowStep(Node n1, FlowState s1, Node n2, FlowState s2) {
|
override predicate isAdditionalTaintStep(Node n1, FlowState s1, Node n2, FlowState s2) {
|
||||||
step(n1, n2, s1, s2)
|
step(n1, n2, s1, s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: fix
|
||||||
|
---
|
||||||
|
* Fixed an issue in the taint tracking analysis where implicit reads were not allowed by default in sinks or additional taint steps that used flow states.
|
||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
category: fix
|
||||||
|
---
|
||||||
|
* Fixed an issue in the taint tracking analysis where implicit reads were not allowed by default in sinks or additional taint steps that used flow states.
|
||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ abstract class Configuration extends DataFlow::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
override predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
|
||||||
(this.isSink(node) or this.isAdditionalTaintStep(node, _)) and
|
(
|
||||||
|
this.isSink(node) or
|
||||||
|
this.isSink(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _) or
|
||||||
|
this.isAdditionalTaintStep(node, _, _, _)
|
||||||
|
) and
|
||||||
defaultImplicitTaintRead(node, c)
|
defaultImplicitTaintRead(node, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user