Skip to content

Commit c3da3a9

Browse files
Add a bit of additional context to the alert message; fix issue with finding the config file
1 parent 17348fb commit c3da3a9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

java/ql/lib/semmle/code/java/security/AndroidCertificatePinningQuery.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Definitiona for the Android Missing Certificate Pinning query. */
2+
13
import java
24
import semmle.code.xml.AndroidManifest
35
import semmle.code.java.dataflow.TaintTracking
@@ -8,7 +10,7 @@ class AndroidNetworkSecurityConfigFile extends XmlFile {
810
exists(AndroidApplicationXmlElement app, AndroidXmlAttribute confAttr, string confName |
911
confAttr.getElement() = app and
1012
confAttr.getValue() = "@xml/" + confName and
11-
this.getRelativePath() = "res/xml/" + confName + ".xml" and
13+
this.getRelativePath().matches("%res/xml/" + confName + ".xml") and
1214
this.getARootElement().getName() = "network-security-config"
1315
)
1416
}

java/ql/src/experimental/Security/CWE/CWE-295/AndroidMissingCertificatePinning.ql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
* @kind problem
55
* @problem.severity warning
66
* @precision medium
7-
* @id java/android/missingcertificate-pinning
7+
* @id java/android/missing-certificate-pinning
88
* @tags security
99
* external/cwe/cwe-295
1010
*/
1111

1212
import java
1313
import semmle.code.java.security.AndroidCertificatePinningQuery
1414

15-
from DataFlow::Node node
16-
where missingPinning(node)
17-
select node, "This network call does not implement certificate pinning."
15+
from DataFlow::Node node, string msg
16+
where
17+
missingPinning(node) and
18+
if exists(string x | trustedDomain(x))
19+
then msg = "(untrusted domain)"
20+
else msg = "(no trusted domains)"
21+
select node, "This network call does not implement certificate pinning. " + msg

0 commit comments

Comments
 (0)