Skip to content

Commit fa2a6a7

Browse files
committed
Remove unnecessary taint step and update qldoc
1 parent e564481 commit fa2a6a7

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

java/ql/src/experimental/Security/CWE/CWE-200/AndroidWebResourceResponse.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ class WebResourceResponse extends RefType {
2020
WebResourceResponse() { this.hasQualifiedName("android.webkit", "WebResourceResponse") }
2121
}
2222

23-
/** The `shouldInterceptRequest` method of Android's `WebViewClient` class. */
23+
/** The `shouldInterceptRequest` method of a class implementing `WebViewClient`. */
2424
class ShouldInterceptRequestMethod extends Method {
2525
ShouldInterceptRequestMethod() {
2626
this.hasName("shouldInterceptRequest") and
2727
this.getDeclaringType().getASupertype*() instanceof TypeWebViewClient
2828
}
2929
}
3030

31-
/** A method call to `setWebViewClient` of `WebView`. */
31+
/** A method call to `WebView.setWebViewClient`. */
3232
class SetWebViewClientMethodAccess extends MethodAccess {
3333
SetWebViewClientMethodAccess() {
3434
this.getMethod().hasName("setWebViewClient") and
@@ -75,7 +75,6 @@ private class LoadUrlSummaries extends SummaryModelCsv {
7575
row =
7676
[
7777
"java.io;FileInputStream;true;FileInputStream;;;Argument[0];Argument[-1];taint",
78-
"android.net;Uri;false;getPath;;;Argument[0];ReturnValue;taint",
7978
"android.webkit;WebResourceRequest;false;getUrl;;;Argument[-1];ReturnValue;taint"
8079
]
8180
}

java/ql/src/experimental/Security/CWE/CWE-200/InsecureWebResourceResponse.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<overview>
66
<p>Android provides a <code>WebResourceResponse</code> class, which allows an Android application to behave
77
as a web server by handling requests of popular protocols such as <code>http(s)</code>, <code>file</code>,
8-
as well as <code>javascript</code>; and returning a response (including status code, content type, content
8+
as well as <code>javascript</code> and returning a response (including status code, content type, content
99
encoding, headers and the response body). Improper implementation with insufficient input validation can lead
1010
to leakage of sensitive configuration files or user data because requests could refer to paths intended to be
1111
application-private.

java/ql/src/experimental/semmle/code/java/PathSanitizer.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ private class ExactStringPathMatchGuard extends PathTraversalBarrierGuard instan
2121
}
2222

2323
/**
24-
* Returns the qualifier of a method call if it's a variable access, or the qualifier of the qualifier
25-
* if the qualifier itself is a method call, which helps to reduce FPs by handling scenarios such as
26-
* `!uri.getPath().contains("..")`.
24+
* Given input `e` = `v.method1(...).method2(...)...`, returns `v` where `v` is a `VarAccess`.
25+
*
26+
* This is used to look through field accessors such as `uri.getPath()`.
2727
*/
28-
private Expr getRealQualifier(Expr e) {
29-
result = getRealQualifier(e.(MethodAccess).getQualifier())
28+
private Expr getUnderlyingVarAccess(Expr e) {
29+
result = getUnderlyingVarAccess(e.(MethodAccess).getQualifier())
3030
or
3131
result = e.(VarAccess)
3232
}
@@ -37,7 +37,7 @@ private class AllowListGuard extends Guard instanceof MethodAccess {
3737
not isDisallowedWord(super.getAnArgument())
3838
}
3939

40-
Expr getCheckedExpr() { result = getRealQualifier(super.getQualifier()) }
40+
Expr getCheckedExpr() { result = getUnderlyingVarAccess(super.getQualifier()) }
4141
}
4242

4343
/**
@@ -84,7 +84,7 @@ private class BlockListGuard extends Guard instanceof MethodAccess {
8484
isDisallowedWord(super.getAnArgument())
8585
}
8686

87-
Expr getCheckedExpr() { result = getRealQualifier(super.getQualifier()) }
87+
Expr getCheckedExpr() { result = getUnderlyingVarAccess(super.getQualifier()) }
8888
}
8989

9090
/**
@@ -155,7 +155,7 @@ class PathTraversalGuard extends Guard instanceof MethodAccess {
155155
super.getAnArgument().(CompileTimeConstantExpr).getStringValue() = ".."
156156
}
157157

158-
Expr getCheckedExpr() { result = getRealQualifier(super.getQualifier()) }
158+
Expr getCheckedExpr() { result = getUnderlyingVarAccess(super.getQualifier()) }
159159
}
160160

161161
/** A complementary sanitizer that protects against path traversal using path normalization. */

0 commit comments

Comments
 (0)