Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CWE-925] Intent verification is only needed on non-empty onReceive methods. #18907

Merged
merged 6 commits into from
Mar 6, 2025

Conversation

teuron
Copy link
Contributor

@teuron teuron commented Mar 3, 2025

The intent verification is currently triggering on empty onReceive methods like

@Override
public void onReceive(Context context, Intent intent) {}

which is not needed and leads to false positives.

@teuron teuron requested a review from a team as a code owner March 3, 2025 09:28
@github-actions github-actions bot added the Java label Mar 3, 2025
Copy link
Contributor

@egregius313 egregius313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @teuron,

Thank you for the contribution.

I think this change is better suited for the UnverifiedOnReceiveMethod class in java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll like so:

  UnverifiedOnReceiveMethod() {
-    not VerifiedIntentFlow::flow(DataFlow::parameterNode(this.getIntentParameter()), _)
+    not VerifiedIntentFlow::flow(DataFlow::parameterNode(this.getIntentParameter()), _) and
+    // Empty methods do not need to be verified since they do not perform any actions.
+    this.getBody().getNumStmt() > 0
  }

Adding it there will update any other location where unverifiedSystemReceiver is used, such as in the tests.

For testing this change, it would make sense to add an empty receiver to the test files (and AndroidManifest) in java/ql/test/query-tests/security/CWE-925.

Finally, this will need a minorAnalysis change note (guide here).

teuron and others added 2 commits March 5, 2025 12:50
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
…cation-query.md

Co-authored-by: Edward Minnix III <egregius313@github.com>
@owen-mc owen-mc merged commit cbe7edd into github:main Mar 6, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants