Skip to content

Commit 81b358a

Browse files
committed
Swift: Replace a similar additional taint step in another query.
1 parent 27bdee8 commit 81b358a

File tree

3 files changed

+159
-58
lines changed

3 files changed

+159
-58
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,9 @@ private class CleartextStorageDatabaseDefaultBarrier extends CleartextStorageDat
128128
/**
129129
* An additional taint step for cleartext database storage vulnerabilities.
130130
*/
131-
private class CleartextStorageDatabaseArrayAdditionalFlowStep extends CleartextStorageDatabaseAdditionalFlowStep
131+
private class CleartextStorageDatabaseFieldsAdditionalFlowStep extends CleartextStorageDatabaseAdditionalFlowStep
132132
{
133133
override predicate step(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
134-
// needed until we have proper content flow through arrays.
135-
exists(ArrayExpr arr |
136-
nodeFrom.asExpr() = arr.getAnElement() and
137-
nodeTo.asExpr() = arr
138-
)
139-
or
140134
// if an object is sensitive, its fields are always sensitive
141135
// (this is needed because the sensitive data sources are in a sense
142136
// approximate; for example we might identify `passwordBox` as a source,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ module CleartextStorageDatabaseConfig implements DataFlow::ConfigSig {
3939
cx.asNominalTypeDecl() = d and
4040
c.getAReadContent().(DataFlow::Content::FieldContent).getField() = cx.getAMember()
4141
)
42+
or
43+
// flow out from array elements of at the sink,
44+
// for example in `database.allStatements(sql: "", arguments: [sensitive])`.
45+
isSink(node) and
46+
c.getAReadContent() instanceof DataFlow::Content::ArrayContent
4247
}
4348
}
4449

0 commit comments

Comments
 (0)