Skip to content

Commit c9b75af

Browse files
committed
Fix QLL and add change notes with tests
1 parent a374953 commit c9b75af

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ private module VerifiedIntentFlow = DataFlow::Global<VerifiedIntentConfig>;
5151
/** An `onReceive` method that doesn't verify the action of the intent it receives. */
5252
private class UnverifiedOnReceiveMethod extends OnReceiveMethod {
5353
UnverifiedOnReceiveMethod() {
54-
not VerifiedIntentFlow::flow(DataFlow::parameterNode(this.getIntentParameter()), _)
54+
not VerifiedIntentFlow::flow(DataFlow::parameterNode(this.getIntentParameter()), _) and
55+
// Empty methods do not need to be verified since they do not perform any actions.
56+
this.getBody().getNumStmt() > 0
5557
}
5658
}
5759

java/ql/src/Security/CWE/CWE-925/ImproperIntentVerification.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ import java
1414
import semmle.code.java.security.ImproperIntentVerificationQuery
1515

1616
from AndroidReceiverXmlElement reg, Method orm, SystemActionName sa
17-
where unverifiedSystemReceiver(reg, orm, sa) and orm.getBody().getBlock().getNumStmt() > 0
17+
where unverifiedSystemReceiver(reg, orm, sa)
1818
select orm, "This reciever doesn't verify intents it receives, and $@ to receive $@.", reg,
1919
"it is registered", sa, "the system action " + sa.getName()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Fixed false positive in CWE-925 by requiring the `onReceive` method must be non-empty

java/ql/test/query-tests/security/CWE-925/AndroidManifest.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
<action android:name="android.intent.action.BOOT_COMPLETED" />
66
</intent-filter>
77
</receiver>
8+
<reveicer android:name=".EmptyReceiverXml">
9+
<intent-filter>
10+
<action android:name"android.intent.action.BOOT_COMPLETED" />
11+
</intent-filter>
12+
</receiver>
813
</application>
9-
</manifest>
14+
</manifest>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package test;
2+
import android.content.Intent;
3+
import android.content.Context;
4+
import android.content.BroadcastReceiver;
5+
6+
class EmptyReceiverXml extends BroadcastReceiver {
7+
@Override
8+
public void onReceive(Context ctx, Intent intent) { }
9+
}

0 commit comments

Comments
 (0)