File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
java/ql/lib/semmle/code/java/security Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,14 @@ private class DefaultIntentUriPermissionManipulationSink extends IntentUriPermis
38
38
}
39
39
}
40
40
41
+ /**
42
+ * Sanitizer that prevents access to arbitrary content providers by modifying the Intent in one of
43
+ * the following ways:
44
+ * * Removing the flags `FLAG_GRANT_READ_URI_PERMISSION` and `FLAG_GRANT_WRITE_URI_PERMISSION`.
45
+ * * Setting the flags to a combination that doesn't include `FLAG_GRANT_READ_URI_PERMISSION` or
46
+ * `FLAG_GRANT_WRITE_URI_PERMISSION`.
47
+ * * Replacing the data URI.
48
+ */
41
49
private class IntentFlagsOrDataChangedSanitizer extends IntentUriPermissionManipulationSanitizer {
42
50
IntentFlagsOrDataChangedSanitizer ( ) {
43
51
exists ( MethodAccess ma , Method m |
@@ -60,6 +68,20 @@ private class IntentFlagsOrDataChangedSanitizer extends IntentUriPermissionManip
60
68
}
61
69
}
62
70
71
+ /**
72
+ * A guard that checks an Intent's flags or data URI to make sure they are trusted.
73
+ * It matches the following patterns:
74
+ *
75
+ * ```java
76
+ * if (intent.getData().equals("trustedValue")) {}
77
+ *
78
+ * if (intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION == 0 &&
79
+ * intent.getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION == 0) {}
80
+ *
81
+ * if (intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION != 0 ||
82
+ * intent.getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION != 0) {}
83
+ * ```
84
+ */
63
85
private class IntentFlagsOrDataCheckedGuard extends IntentUriPermissionManipulationGuard {
64
86
Expr condition ;
65
87
You can’t perform that action at this time.
0 commit comments