File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
java/ql/src/experimental/Security/CWE/CWE-036 Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change 2
2
"-//Semmle//qhelp//EN"
3
3
"qhelp.dtd">
4
4
<qhelp >
5
+
5
6
<overview >
6
7
<p >Calling <code >openStream</code > on URLs created from remote source can lead to local file disclosure.</p >
7
-
8
8
<p >If <code >openStream</code > is called on a <code >java.net.URL</code >, that was created from a remote source
9
9
an attacker can try to pass absolute URLs starting with <code >file://</code > or <code >jar://</code > to access
10
10
local resources in addition to remote ones.</p >
11
-
12
11
</overview >
13
- <recommendation >
14
12
13
+ <recommendation >
15
14
<p >When you construct a URL using <code >java.net.URL</code > from a remote source, make sure
16
15
to not call openStream on it. Instead fetch the URL with a HTTP Client to access its content.
17
16
Also validate that the URL uses the correct protocol and host combination.</p >
18
-
19
17
</recommendation >
20
- <example >
21
18
19
+ <example >
22
20
<p >The following example shows an URL that is constructed from a request parameter. Afterwards <code >openStream</code >
23
21
is called on the URL, potentially leading to a local file access.</p >
24
-
25
22
<sample src =" OpenStream.java" />
26
-
27
23
</example >
28
- <references >
29
24
25
+ <references >
30
26
<ul >
31
27
<li >Java Platform, Standard Edition 11, API Specification:
32
28
<a href =" https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/URL.html" >
33
29
Class URL</a >.
34
- <li >
30
+ </ li >
35
31
</ul >
36
-
37
- <!-- LocalWords: CWE
38
- -->
39
-
32
+ <!-- LocalWords: CWE -->
40
33
</references >
34
+
41
35
</qhelp >
You can’t perform that action at this time.
0 commit comments