Skip to content

Commit 143ce0b

Browse files
Add sensitive notification query
1 parent 95a2004 commit 143ce0b

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

java/ql/lib/ext/android.app.model.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ extensions:
3838
- ["android.app", "PendingIntent", False, "send", "(Context,int,Intent,PendingIntent$OnFinished,Handler)", "", "Argument[2]", "pending-intents", "manual"]
3939
- ["android.app", "PendingIntent", False, "send", "(Context,int,Intent,PendingIntent$OnFinished,Handler,String)", "", "Argument[2]", "pending-intents", "manual"]
4040
- ["android.app", "PendingIntent", False, "send", "(Context,int,Intent,PendingIntent$OnFinished,Handler,String,Bundle)", "", "Argument[2]", "pending-intents", "manual"]
41+
- ["android.app", "NotificationManager", True, "notify", "(String,int,Notification)", "", "Argument[2]", "notification", "manual"]
42+
- ["android.app", "NotificationManager", True, "notify", "(int,Notification)", "", "Argument[1]", "notification", "manual"]
43+
- ["android.app", "NotificationManager", True, "notifyAsPackage", "(String,String,int,Notification)", "", "Argument[3]", "notification", "manual"]
44+
- ["android.app", "NotificationManager", True, "notifyAsUser", "(String,int,Notification,UserHandle)", "", "Argument[2]", "notification", "manual"]
4145
- addsTo:
4246
pack: codeql/java-all
4347
extensible: summaryModel

java/ql/lib/ext/androidx.core.app.model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extensions:
99
- ["androidx.core.app", "AlarmManagerCompat", True, "setExactAndAllowWhileIdle", "", "", "Argument[3]", "pending-intents", "manual"]
1010
- ["androidx.core.app", "NotificationManagerCompat", True, "notify", "(String,int,Notification)", "", "Argument[2]", "pending-intents", "manual"]
1111
- ["androidx.core.app", "NotificationManagerCompat", True, "notify", "(int,Notification)", "", "Argument[1]", "pending-intents", "manual"]
12+
- ["androidx.core.app", "NotificationManagerCompat", True, "notify", "(String,int,Notification)", "", "Argument[2]", "notification", "manual"]
13+
- ["androidx.core.app", "NotificationManagerCompat", True, "notify", "(int,Notification)", "", "Argument[1]", "notification", "manual"]
1214
- addsTo:
1315
pack: codeql/java-all
1416
extensible: summaryModel
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** Definitions for Android Sensitive UI queries */
2+
3+
import java
4+
private import semmle.code.java.dataflow.ExternalFlow
5+
private import semmle.code.java.dataflow.TaintTracking
6+
private import semmle.code.java.security.SensitiveActions
7+
8+
/** A configuration for tracking sensitive information to system notifications. */
9+
private module NotificationTrackingConfig implements DataFlow::ConfigSig {
10+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SensitiveExpr }
11+
12+
predicate isSink(DataFlow::Node sink) { sinkNode(sink, "notifications") }
13+
}
14+
15+
/** Taint tracking flow for sensitive data flowing to system notifications. */
16+
module NotificationTracking = TaintTracking::Global<NotificationTrackingConfig>;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @name Exposure of sensitive information to notifications
3+
* @id java/android/sensitive-notification
4+
* @kind path-problem
5+
* @description Sensitive information exposed in a system notification can be read by an unauthorized application.
6+
* @problem.severity error
7+
* @precision medium
8+
* @security-severity 6.5
9+
* @tags security
10+
* external/cwe/cwe-200
11+
*/
12+
13+
import java
14+
import java
15+
import semmle.code.java.security.SensitiveUiQuery
16+
import NotificationTracking::PathGraph
17+
18+
from NotificationTracking::PathNode source, NotificationTracking::PathNode sink
19+
where NotificationTracking::flowPath(source, sink)
20+
select sink, source, sink, "This $@ is exposed in a system notification.", source,
21+
"sensitive information"

0 commit comments

Comments
 (0)