File tree Expand file tree Collapse file tree
java/ql/src/experimental/Security/CWE/CWE-036 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 "-//Semmle//qhelp//EN"
33 "qhelp.dtd">
44<qhelp >
5+
56<overview >
67<p >Calling <code >openStream</code > on URLs created from remote source can lead to local file disclosure.</p >
7-
88<p >If <code >openStream</code > is called on a <code >java.net.URL</code >, that was created from a remote source
99an attacker can try to pass absolute URLs starting with <code >file://</code > or <code >jar://</code > to access
1010local resources in addition to remote ones.</p >
11-
1211</overview >
13- <recommendation >
1412
13+ <recommendation >
1514<p >When you construct a URL using <code >java.net.URL</code > from a remote source, make sure
1615to not call openStream on it. Instead fetch the URL with a HTTP Client to access its content.
1716Also validate that the URL uses the correct protocol and host combination.</p >
18-
1917</recommendation >
20- <example >
2118
19+ <example >
2220<p >The following example shows an URL that is constructed from a request parameter. Afterwards <code >openStream</code >
2321is called on the URL, potentially leading to a local file access.</p >
24-
2522<sample src =" OpenStream.java" />
26-
2723</example >
28- <references >
2924
25+ <references >
3026<ul >
3127<li >Java Platform, Standard Edition 11, API Specification:
3228<a href =" https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/URL.html" >
3329Class URL</a >.
34- <li >
30+ </ li >
3531</ul >
36-
37- <!-- LocalWords: CWE
38- -->
39-
32+ <!-- LocalWords: CWE -->
4033</references >
34+
4135</qhelp >
You can’t perform that action at this time.
0 commit comments