|
5 | 5 |
|
6 | 6 |
|
7 | 7 | <overview>
|
8 |
| -<p>Constructing a server-side redirect path with user input could allow an attacker to download application binaries |
9 |
| -(including application classes or jar files) or view arbitrary files within protected directories.</p> |
| 8 | +<p>Directly incorporating user input into a URL forward request without validating the input |
| 9 | +can cause file information disclosure by allowing an attacker to access unauthorized URLs.</p> |
10 | 10 |
|
11 | 11 | </overview>
|
12 | 12 | <recommendation>
|
13 | 13 |
|
14 |
| -<p>Unsanitized user provided data must not be used to construct the path for URL forwarding. In order to prevent |
15 |
| -untrusted URL forwarding, it is recommended to avoid concatenating user input directly into the forwarding URL. |
16 |
| -Instead, user input should be checked against allowed (e.g., must come within <code>user_content/</code>) or disallowed |
17 |
| -(e.g. must not come within <code>/internal</code>) paths, ensuring that neither path traversal using <code>../</code> |
18 |
| -or URL encoding are used to evade these checks. |
19 |
| -</p> |
| 14 | +<p>To guard against untrusted URL forwarding, it is advisable to avoid putting user input |
| 15 | +directly into a forwarded URL. Instead, maintain a list of authorized |
| 16 | +URLs on the server; then choose from that list based on the user input provided.</p> |
20 | 17 |
|
21 | 18 | </recommendation>
|
22 | 19 | <example>
|
23 | 20 |
|
24 |
| -<p>The following examples show the bad case and the good case respectively. |
25 |
| -The <code>bad</code> methods show an HTTP request parameter being used directly in a URL forward |
26 |
| -without validating the input, which may cause file leakage. In the <code>good1</code> method, |
27 |
| -ordinary forwarding requests are shown, which will not cause file leakage. |
| 21 | +<p>The following example shows an HTTP request parameter being used directly in a URL forward |
| 22 | +without validating the input, which may cause file information disclosure. |
| 23 | +It also shows how to remedy the problem by validating the user input against a known fixed string. |
28 | 24 | </p>
|
29 | 25 |
|
30 | 26 | <sample src="UrlForward.java" />
|
31 | 27 |
|
32 |
| -<p>The following examples show an HTTP request parameter or request path being used directly in a |
33 |
| -request dispatcher of Java EE without validating the input, which allows sensitive file exposure |
34 |
| -attacks. It also shows how to remedy the problem by validating the user input. |
35 |
| -</p> |
36 |
| - |
37 |
| -<sample src="UnsafeServletRequestDispatch.java" /> |
38 |
| - |
39 |
| -<p>The following examples show an HTTP request parameter or request path being used directly to |
40 |
| -retrieve a resource of a Java EE application without validating the input, which allows sensitive |
41 |
| -file exposure attacks. It also shows how to remedy the problem by validating the user input. |
42 |
| -</p> |
43 |
| - |
44 |
| -<sample src="UnsafeResourceGet.java" /> |
45 |
| - |
46 |
| -<p>The following examples show an HTTP request parameter being used directly to retrieve a resource |
47 |
| - of a Java Spring application without validating the input, which allows sensitive file exposure |
48 |
| - attacks. It also shows how to remedy the problem by validating the user input. |
49 |
| - </p> |
50 |
| - |
51 |
| - <sample src="UnsafeLoadSpringResource.java" /> |
52 | 28 | </example>
|
53 | 29 | <references>
|
54 |
| -<li>File Disclosure: |
55 |
| - <a href="https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.file_disclosure_spring">Unsafe Url Forward</a>. |
56 |
| -</li> |
57 |
| -<li>Jakarta Javadoc: |
58 |
| - <a href="https://jakarta.ee/specifications/webprofile/9/apidocs/jakarta/servlet/servletrequest#getRequestDispatcher-java.lang.String-">Security vulnerability with unsafe usage of RequestDispatcher</a>. |
59 |
| -</li> |
60 |
| -<li>Micro Focus: |
61 |
| - <a href="https://vulncat.fortify.com/en/detail?id=desc.dataflow.java.file_disclosure_j2ee">File Disclosure: J2EE</a> |
62 |
| -</li> |
63 |
| -<li>CVE-2015-5174: |
64 |
| - <a href="https://vuldb.com/?id.81084">Apache Tomcat 6.0/7.0/8.0/9.0 Servletcontext getResource/getResourceAsStream/getResourcePaths Path Traversal</a> |
65 |
| -</li> |
66 |
| -<li>CVE-2019-3799: |
67 |
| - <a href="https://github.com/mpgn/CVE-2019-3799">CVE-2019-3799 - Spring-Cloud-Config-Server Directory Traversal < 2.1.2, 2.0.4, 1.4.6</a> |
| 30 | + |
| 31 | +<li>OWASP: |
| 32 | + <a href="https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html">Unvalidated Redirects and Forwards Cheat Sheet</a>. |
68 | 33 | </li>
|
| 34 | + |
69 | 35 | </references>
|
70 | 36 | </qhelp>
|
0 commit comments