Skip to content

Commit 9d048e7

Browse files
Apply suggestions from code review - fix typos/style, make things private
Co-authored-by: Tony Torralba <[email protected]>
1 parent d88d216 commit 9d048e7

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private class OnReceiveMethod extends Method {
1010
.hasQualifiedName("android.content", "BroadcastReceiver", "onReceive")
1111
}
1212

13-
/** Gets the paramter of this method that holds the received `Intent`. */
13+
/** Gets the parameter of this method that holds the received `Intent`. */
1414
Parameter getIntentParameter() { result = this.getParameter(1) }
1515
}
1616

@@ -30,7 +30,7 @@ private class VerifiedIntentConfig extends DataFlow::Configuration {
3030
}
3131
}
3232

33-
/** An `onReceive` method that doesn't verify the action of the intent it recieves. */
33+
/** An `onReceive` method that doesn't verify the action of the intent it receives. */
3434
class UnverifiedOnReceiveMethod extends OnReceiveMethod {
3535
UnverifiedOnReceiveMethod() {
3636
not any(VerifiedIntentConfig c).hasFlow(DataFlow::parameterNode(this.getIntentParameter()), _)
@@ -70,7 +70,7 @@ class SystemActionName extends Top {
7070
)
7171
}
7272

73-
/** Gets the name of the system intent that this expression or attriute represents. */
73+
/** Gets the name of the system intent that this expression or attribute represents. */
7474
string getName() { result = name }
7575

7676
override string toString() {
@@ -125,8 +125,8 @@ private class RegisterSystemActionConfig extends DataFlow::Configuration {
125125
}
126126
}
127127

128-
/** Holds if `rrc` registers a reciever `orm` to recieve the system action `sa` that doesn't verifiy intents it recieves. */
129-
predicate registeredUnverifiedSystemReceiver(
128+
/** Holds if `rrc` registers a receiver `orm` to receive the system action `sa` that doesn't verify the intents it receives. */
129+
private predicate registeredUnverifiedSystemReceiver(
130130
RegisterReceiverCall rrc, UnverifiedOnReceiveMethod orm, SystemActionName sa
131131
) {
132132
exists(RegisterSystemActionConfig conf, ConstructorCall cc |
@@ -136,8 +136,8 @@ predicate registeredUnverifiedSystemReceiver(
136136
)
137137
}
138138

139-
/** Holds if the XML element `rec` declares a reciever `orm` to recieve the system action named `sa` that doesn't verifiy intents it recieves. */
140-
predicate xmlUnverifiedSystemReceiver(
139+
/** Holds if the XML element `rec` declares a receiver `orm` to receive the system action named `sa` that doesn't verify intents it receives. */
140+
private predicate xmlUnverifiedSystemReceiver(
141141
XMLElement rec, UnverifiedOnReceiveMethod orm, SystemActionName sa
142142
) {
143143
exists(XMLElement filter, XMLElement action, Class ormty |
@@ -152,7 +152,7 @@ predicate xmlUnverifiedSystemReceiver(
152152
)
153153
}
154154

155-
/** Holds if `reg` registers (either explicitly or through XML) a reciever `orm` to recieve the system action named `sa` that doesn't verify intents it recieves. */
155+
/** Holds if `reg` registers (either explicitly or through XML) a receiver `orm` to receive the system action named `sa` that doesn't verify the intents it receives. */
156156
predicate unverifiedSystemReceiver(Top reg, Method orm, SystemActionName sa) {
157157
registeredUnverifiedSystemReceiver(reg, orm, sa) or
158158
xmlUnverifiedSystemReceiver(reg, orm, sa)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
...
1+
// ...
22
IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
33
BroadcastReceiver sReceiver = new ShutDownReceiver();
44
context.registerReceiver(sReceiver, filter);
5-
...
5+
// ...
66

77
public class ShutdownReceiver extends BroadcastReceiver {
88
@Override

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
...
1+
// ...
22
IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);
33
BroadcastReceiver sReceiver = new ShutDownReceiver();
44
context.registerReceiver(sReceiver, filter);
5-
...
5+
// ...
66

77
public class ShutdownReceiver extends BroadcastReceiver {
88
@Override

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
<overview>
88
<p>
9-
When an android application uses a <code>BroadcastReciever</code> to receive Intents,
10-
it is also able to receive explicit Intents that are sent drctly to it, egardless of its filter.
9+
When an android application uses a <code>BroadcastReciever</code> to receive intents,
10+
it is also able to receive explicit intents that are sent directly to it, regardless of its filter.
1111

1212
Certain intent actions are only able to be sent by the operating system, not third-party applications.
13-
However, a <code>BroadcastReceiver</code> that is registered to recieve system intents is still able to recieve
13+
However, a <code>BroadcastReceiver</code> that is registered to receive system intents is still able to receive
1414
other intents from a third-party application, so it should check that the intent received has the expected action.
15-
Otherwise, a third-party application could impersonate the system this way and cause unintended behaviour, such as a denial of service.
15+
Otherwise, a third-party application could impersonate the system this way and cause unintended behavior, such as a denial of service.
1616
</p>
1717
</overview>
1818

1919
<example>
20-
<p>In the following code, the <code>ShutdownReceiver</code> initiates a shutdown procedure upon receiving an Intent,
20+
<p>In the following code, the <code>ShutdownReceiver</code> initiates a shutdown procedure upon receiving an intent,
2121
without checking that the received action is indeed <code>ACTION_SHUTDOWN</code>. This allows third-party applications to
2222
send explicit intents to this receiver to cause a denial of service.</p>
2323
<sample src="Bad.java" />

java/ql/src/change-notes/2022-04-27-intent-verification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
category: newQuery
33
---
44
* A new query "Improper Verification of Intent by Broadcast Receiver" (`java/improper-intent-verification`) has been added.
5-
This query finds instances of Android `BroadcastReceiver`s that don't verify the action string of received Intents when registered
5+
This query finds instances of Android `BroadcastReceiver`s that don't verify the action string of received intents when registered
66
to receive system intents.

0 commit comments

Comments
 (0)