-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Java: Add query for Improper Verification of Intent by Broadcast Receiver (CWE-925) #8669
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
Conversation
848309f
to
9cbc4be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found 1 vulnerability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good looking query! Good job including the dynamically declared receivers too, I'm eager to see what this catches when run at scale.
I added some inline comments.
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
java/ql/lib/semmle/code/java/security/ImproperIntentVerificationQuery.qll
Outdated
Show resolved
Hide resolved
9950f57
to
f317ebf
Compare
This is mostly looking good to me. I think we need FP ratio and performance evaluations before merging though. |
f317ebf
to
e2cf7cc
Compare
After experimenting a little with real world results, it seems that this vulnerability cannot be exploited through dynamically registered receivers (i.e. using So, I think we should restrict the query to only check statically registered receivers (i.e. through the Android manifest). I guess we could also handle dynamically registered receivers that have a filter for both a privileged action and an unprivileged action, but I'd say this is a pretty rare case and the chances of the receiver actually doing something sensitive would drop significantly. So I'll leave up to you to decide whether you want to handle that case — otherwise, we should just remove everything related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joefarebrother 👋🏻 - this LGTM, I've made a few comments and suggestions for your consideration.
Would be great if you could correct the typo, and reword the query description. Hope this helps 🙂
@@ -0,0 +1,19 @@ | |||
/** | |||
* @name Improper Verification of Intent by Broadcast Receiver | |||
* @description The Android application uses a Broadcast Receiver that receives an Intent but does not properly verify that the Intent came from an authorized source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, unless you absolutely need to use capitalization (like in Android).
Also, this is not the preferred syntax for a description ("Syntax X causes behavior Y."). Could you reword and remove the capitalization?
java/ql/src/Security/CWE/CWE-925/ImproperIntentVerification.qhelp
Outdated
Show resolved
Hide resolved
<overview> | ||
<p> | ||
When an android application uses a <code>BroadcastReciever</code> to receive intents, | ||
it is also able to receive explicit intents that are sent directly to it, regardless of its filter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the its
pronoun refer to here, the app or the BroadcastReceiver
(sorry, not a developer)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to the BroadcastReceiver
|
||
Certain intent actions are only able to be sent by the operating system, not third-party applications. | ||
However, a <code>BroadcastReceiver</code> that is registered to receive system intents is still able to receive | ||
other intents from a third-party application, so it should check that the intent received has the expected action. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required?
other intents from a third-party application, so it should check that the intent received has the expected action. | |
intents from a third-party application, so it should check that the intent received has the expected action. |
…vate Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
fix typos and capitilisation; reword description.
4717d32
to
a6736a9
Compare
No description provided.