Skip to content

Commit 89867d6

Browse files
committed
Swift: Default content read step.
1 parent fe2468e commit 89867d6

File tree

6 files changed

+5
-33
lines changed

6 files changed

+5
-33
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/TaintTrackingPublic.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ predicate defaultImplicitTaintRead(DataFlow::Node node, DataFlow::ContentSet cs)
3737
cx.asNominalTypeDecl() = d and
3838
cs.getAReadContent().(DataFlow::Content::FieldContent).getField() = cx.getAMember()
3939
)
40+
or
41+
// We often expect taint to reach a sink inside `CollectionContent`, for example an array element
42+
// or pointer contents. It is convenient to have a default implicit read step for these cases rather
43+
// than implementing this step in a lot of separate `allowImplicitRead`s.
44+
cs.getAReadContent() instanceof DataFlow::Content::CollectionContent
4045
}

swift/ql/lib/codeql/swift/security/CleartextLoggingQuery.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ module CleartextLoggingConfig implements DataFlow::ConfigSig {
2525
predicate isAdditionalFlowStep(DataFlow::Node n1, DataFlow::Node n2) {
2626
any(CleartextLoggingAdditionalFlowStep s).step(n1, n2)
2727
}
28-
29-
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
30-
// flow out from collection content at the sink.
31-
isSink(node) and
32-
c.getAReadContent() instanceof DataFlow::Content::CollectionContent
33-
}
3428
}
3529

3630
/**

swift/ql/lib/codeql/swift/security/CleartextStorageDatabaseQuery.qll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ module CleartextStorageDatabaseConfig implements DataFlow::ConfigSig {
4545
isSink(node) and
4646
node.asExpr().getType().getUnderlyingType() instanceof DictionaryType and
4747
c.getAReadContent().(DataFlow::Content::TupleContent).getIndex() = 1
48-
or
49-
// flow out from array elements (and other collection content) at the sink,
50-
// for example in `database.allStatements(sql: "", arguments: [sensitive])`.
51-
isSink(node) and
52-
c.getAReadContent() instanceof DataFlow::Content::CollectionContent
5348
}
5449
}
5550

swift/ql/lib/codeql/swift/security/CommandInjectionQuery.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ module CommandInjectionConfig implements DataFlow::ConfigSig {
2323
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
2424
any(CommandInjectionAdditionalFlowStep s).step(nodeFrom, nodeTo)
2525
}
26-
27-
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
28-
// flow out from array elements of at the sink, for example in `task.arguments = [tainted]`.
29-
isSink(node) and
30-
c.getAReadContent() instanceof DataFlow::Content::CollectionContent
31-
}
3226
}
3327

3428
/**

swift/ql/lib/codeql/swift/security/HardcodedEncryptionKeyQuery.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ module HardcodedKeyConfig implements DataFlow::ConfigSig {
4141
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
4242
any(HardcodedEncryptionKeyAdditionalFlowStep s).step(nodeFrom, nodeTo)
4343
}
44-
45-
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
46-
// flow out of collections at the sink
47-
isSink(node) and
48-
c.getAReadContent() instanceof DataFlow::Content::CollectionContent
49-
}
5044
}
5145

5246
module HardcodedKeyFlow = TaintTracking::Global<HardcodedKeyConfig>;

swift/ql/lib/codeql/swift/security/UnsafeJsEvalQuery.qll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ module UnsafeJsEvalConfig implements DataFlow::ConfigSig {
2222
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
2323
any(UnsafeJsEvalAdditionalFlowStep s).step(nodeFrom, nodeTo)
2424
}
25-
26-
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
27-
// flow out from content a the sink
28-
(
29-
isSink(node)
30-
or
31-
isAdditionalFlowStep(node, _)
32-
) and
33-
c.getAReadContent() instanceof DataFlow::Content::CollectionContent
34-
}
3525
}
3626

3727
/**

0 commit comments

Comments
 (0)