Skip to content

Commit a9757fb

Browse files
committed
Setting null Components is not a sanitizer
1 parent a59a402 commit a9757fb

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

java/ql/lib/semmle/code/java/frameworks/android/Intent.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ExplicitIntent extends Expr {
9999
ma.getMethod() = m and
100100
m.getDeclaringType() instanceof TypeIntent and
101101
m.hasName(["setPackage", "setClass", "setClassName", "setComponent"]) and
102+
not exists(NullLiteral nullLiteral | DataFlow::localExprFlow(nullLiteral, ma.getAnArgument())) and
102103
ma.getQualifier() = this
103104
)
104105
or

java/ql/test/query-tests/security/CWE-927/ImplicitPendingIntentsTest.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public static void testPendingIntentAsAnExtra(Context ctx)
3434
ctx.startService(fwdIntent); // Safe
3535
ctx.sendBroadcast(fwdIntent); // $hasImplicitPendingIntent
3636

37+
fwdIntent.setComponent(null); // Not a sanitizer
38+
ctx.startActivity(fwdIntent); // $hasImplicitPendingIntent
39+
3740
fwdIntent.setPackage("a.safe.package"); // Sanitizer
3841
ctx.startActivity(fwdIntent); // Safe
3942
}
@@ -285,19 +288,5 @@ public boolean onCreateSliceProvider() {
285288
mPendingIntent = PendingIntent.getActivity(getContext(), 0, baseIntent, 0);
286289
return true;
287290
}
288-
289-
// Implementations needed for compilation
290-
291-
@Override
292-
public AssetFileDescriptor openTypedAssetFile(Uri uri, String mimeTypeFilter, Bundle opts,
293-
CancellationSignal signal) throws RemoteException, FileNotFoundException {
294-
return null;
295-
}
296-
297-
@Override
298-
public Bundle call(String authority, String method, String arg, Bundle extras)
299-
throws RemoteException {
300-
return null;
301-
}
302291
}
303292
}

0 commit comments

Comments
 (0)