Skip to content

Commit e37f62b

Browse files
committed
Android ContentProvider.openFile does not check mode initital commit
Initial commit for work on a query finding instances where the `mode` parameter of an override of the `openFile` method of the `android.content.ContentProvider` class
1 parent 00891fa commit e37f62b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @name Misconfigured ContentProvider use
3+
* @description ContentProvider#openFile override which does not use `mode` argument.
4+
* @kind problem
5+
* @id java/android/misconfigured-content-provider
6+
* @problem.severity warning
7+
* @security-severity 7.8
8+
* @tags security external/cwe/cwe-276
9+
* @precision medium
10+
*/
11+
12+
import java
13+
14+
class ContentProviderOpenFileMethod extends Method {
15+
ContentProviderOpenFileMethod() {
16+
this.hasName("openFile") and
17+
this.getDeclaringType().getASupertype*().hasQualifiedName("android.content", "ContentProvider")
18+
}
19+
20+
predicate doesNotCheckMode() {
21+
exists(Parameter p | p = this.getParameter(1) | not exists(p.getAnAccess()))
22+
}
23+
}
24+
25+
from ContentProviderOpenFileMethod ofm
26+
where ofm.doesNotCheckMode()
27+
select ofm, "Open file"

0 commit comments

Comments
 (0)