Skip to content

Commit f5e9690

Browse files
luchua-bcsmowton
authored andcommitted
Update the doc comments
1 parent c7750fd commit f5e9690

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</overview>
1414

1515
<recommendation>
16-
<p>Only allow trusted web content to be displayed in WebViews when JavaScript is enabled. Disallow cross-origin resource access in WebSetting to reduce the attack surface .</p>
16+
<p>Only allow trusted web content to be displayed in WebViews when JavaScript is enabled. Disallow cross-origin resource access in WebSetting to reduce the attack surface.</p>
1717
</recommendation>
1818

1919
<example>

java/ql/src/experimental/Security/CWE/CWE-749/UnsafeAndroidAccess.ql

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class IntentGetExtraMethodAccess extends MethodAccess {
7171
}
7272

7373
/**
74-
* Source of fetching urls
74+
* Source of fetching URLs
7575
*/
7676
class UntrustedResourceSource extends RemoteFlowSource {
7777
UntrustedResourceSource() {
@@ -84,21 +84,28 @@ class UntrustedResourceSource extends RemoteFlowSource {
8484
}
8585

8686
/**
87-
* Holds if `ma` loads url `sink`
87+
* Holds if `ma` loads URL `sink`
8888
*/
8989
predicate fetchResource(FetchResourceMethodAccess ma, Expr sink) { sink = ma.getArgument(0) }
9090

9191
/**
92-
* Sink of fetching urls
92+
* A URL argument to a `loadUrl` or `postUrl` call, considered as a sink.
9393
*/
9494
class UrlResourceSink extends DataFlow::ExprNode {
9595
UrlResourceSink() { fetchResource(_, this.getExpr()) }
9696

97+
/** Gets the fetch method that fetches this sink URL. */
9798
FetchResourceMethodAccess getMethodAccess() { fetchResource(result, this.getExpr()) }
9899

100+
/**
101+
* Holds if cross-origin access is enabled for this resource fetch.
102+
*
103+
* Specifically this looks for code like
104+
* `webView.getSettings().setAllow[File|Universal]AccessFromFileURLs(true);`
105+
*/
99106
predicate crossOriginAccessEnabled() {
100107
exists(MethodAccess ma, MethodAccess getSettingsMa |
101-
ma.getMethod() instanceof CrossOriginAccessMethod and // Unsafe resource fetching of more severe vulnerabilities
108+
ma.getMethod() instanceof CrossOriginAccessMethod and
102109
ma.getArgument(0).(BooleanLiteral).getBooleanValue() = true and
103110
ma.getQualifier().(VarAccess).getVariable().getAnAssignedValue() = getSettingsMa and
104111
getSettingsMa.getMethod() instanceof WebViewGetSettingsMethod and
@@ -107,13 +114,20 @@ class UrlResourceSink extends DataFlow::ExprNode {
107114
)
108115
}
109116

117+
/**
118+
* Returns a description of this vulnerability, assuming Javascript is enabled and
119+
* the fetched URL is attacker-controlled.
120+
*/
110121
string getSinkType() {
111122
if crossOriginAccessEnabled()
112123
then result = "user input vulnerable to cross-origin and sensitive resource disclosure attacks"
113124
else result = "user input vulnerable to XSS attacks"
114125
}
115126
}
116127

128+
/**
129+
* Taint configuration tracking flow from untrusted inputs to `loadUrl` or `postUrl` calls.
130+
*/
117131
class FetchUntrustedResourceConfiguration extends TaintTracking::Configuration {
118132
FetchUntrustedResourceConfiguration() { this = "FetchUntrustedResourceConfiguration" }
119133

0 commit comments

Comments
 (0)