Skip to content

Commit 380bf21

Browse files
committed
Swift: Update InsecureTLSExtensions.ql sinks to not depend on AssignExpr.
1 parent c1a95d5 commit 380bf21

File tree

4 files changed

+131
-50
lines changed

4 files changed

+131
-50
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ private class EnumInsecureTlsExtensionsSource extends InsecureTlsExtensionsSourc
5050
*/
5151
private class NsUrlTlsExtensionsSink extends InsecureTlsExtensionsSink {
5252
NsUrlTlsExtensionsSink() {
53-
exists(AssignExpr assign |
54-
assign.getSource() = this.asExpr() and
55-
assign.getDest().(MemberRefExpr).getMember().(ConcreteVarDecl).getName() =
53+
exists(MemberRefExpr e |
54+
e.getBase().getType().getABaseType*().getUnderlyingType().getName() =
55+
"URLSessionConfiguration" and
56+
e.getMember().(ConcreteVarDecl).getName() =
5657
[
5758
"tlsMinimumSupportedProtocolVersion", "tlsMinimumSupportedProtocol",
5859
"tlsMaximumSupportedProtocolVersion", "tlsMaximumSupportedProtocol"
59-
]
60+
] and
61+
this.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr() = e.getBase()
6062
)
6163
}
6264
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ module InsecureTlsConfig implements DataFlow::ConfigSig {
2222
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
2323
any(InsecureTlsExtensionsAdditionalTaintStep s).step(nodeFrom, nodeTo)
2424
}
25+
26+
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
27+
// flow out from fields of an `URLSessionConfiguration` at the sink,
28+
// for example in `sessionConfig.tlsMaximumSupportedProtocolVersion = tls_protocol_version_t.TLSv10`.
29+
isSink(node) and
30+
exists(NominalTypeDecl d, Decl cx |
31+
d.getType().getABaseType*().getUnderlyingType().getName() = "URLSessionConfiguration" and
32+
cx.asNominalTypeDecl() = d and
33+
c.getAReadContent().(DataFlow::Content::FieldContent).getField() = cx.getAMember()
34+
)
35+
}
2536
}
2637

2738
module InsecureTlsFlow = TaintTracking::Global<InsecureTlsConfig>;

0 commit comments

Comments
 (0)