Skip to content

Commit 0053158

Browse files
committed
update qhelp file and ql comments
1 parent 0159956 commit 0053158

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

java/ql/src/experimental/Security/CWE/CWE-348/UseOfLessTrustedSource.qhelp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"qhelp.dtd">
44
<qhelp>
55
<overview>
6-
<p>The software obtains the original client IP address through the http header <code>X-Forwarded-For</code>, which is used to ensure
7-
security or track it in the log for statistical or other reasons. Attackers can use <code>X-Forwarded-For </code> Spoofing software.</p>
6+
<p>The software obtains the original client IP address through the http header (<code>X-Forwarded-For</code> or <code>X-Real-IP</code> or <code>Proxy-Client-IP</code>
7+
etc.), which is used to ensure security or track it in the log for statistical or other reasons. Attackers can forge the value of these identifiers to attack the
8+
software.</p>
89

910
</overview>
1011
<recommendation>
@@ -15,9 +16,10 @@ security or track it in the log for statistical or other reasons. Attackers can
1516
<example>
1617

1718
<p>The following examples show the bad case and the good case respectively. Bad case, such as <code>bad1</code> to <code>bad2</code>.
18-
In the <code>bad1</code> method, the value of <code>X-Forwarded-For</code> in <code>header</code> is split, and the first value of
19-
the split array is obtained. Good case, such as <code>good1</code>, split the value of <code>X-Forwarded-For</code> in <code>header</code>
20-
and get the last value of the split array.</p>
19+
In the <code>bad1</code> method, obtain the client ip according to the specified identifier from the <code>header</code> for local
20+
output and logging. In the <code>bad2</code> method, the client ip is obtained and judged according to the specified identifier
21+
from the <code>header</code>. When used for permission verification, it can be bypassed by forging the ip. Good case, such as
22+
<code>good1</code>, split the value of <code>X-Forwarded-For</code> in <code>header</code> and get the last value of the split array.</p>
2123

2224
<sample src="UseOfLessTrustedSource.java" />
2325

java/ql/src/experimental/Security/CWE/CWE-348/UseOfLessTrustedSource.ql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* @name IP address spoofing
3-
* @description The software obtains the client ip through `X-Forwarded-For`,
4-
* and the attacker can modify the value of `X-Forwarded-For` to forge the ip.
3+
* @description The software obtains the client ip from the remote endpoint identifier specified (`X-Forwarded-For`,
4+
* `X-Real-IP`, `Proxy-Client-IP`, etc.) in the header and uses it. Attackers can modify these The value
5+
* of the identifier to forge the client ip.
56
* @kind path-problem
67
* @problem.severity error
78
* @precision high
@@ -12,12 +13,12 @@
1213

1314
import java
1415
import UseOfLessTrustedSourceLib
15-
import semmle.code.java.dataflow.DataFlow2
16-
import semmle.code.java.dataflow.TaintTracking2
1716
import semmle.code.java.dataflow.FlowSources
1817
import DataFlow::PathGraph
1918

20-
/** Taint-tracking configuration tracing flow from get method request sources to output jsonp data. */
19+
/**
20+
* Taint-tracking configuration tracing flow from obtain client ip to use the client ip.
21+
*/
2122
class UseOfLessTrustedSourceConfig extends TaintTracking::Configuration {
2223
UseOfLessTrustedSourceConfig() { this = "UseOfLessTrustedSourceConfig" }
2324

java/ql/src/experimental/Security/CWE/CWE-348/UseOfLessTrustedSourceLib.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import java
22
import DataFlow
3-
import semmle.code.java.dataflow.TaintTracking2
43
import semmle.code.java.security.QueryInjection
54
import experimental.semmle.code.java.Logging
65

76
/**
87
* A data flow source of the client ip obtained according to the remote endpoint identifier specified
9-
* in the header (`X-Forwarded-For`, `X-Real-IP`, `Proxy-Client-IP`, etc.).
8+
* (`X-Forwarded-For`, `X-Real-IP`, `Proxy-Client-IP`, etc.) in the header.
109
*
1110
* For example: `ServletRequest.getHeader("X-Forwarded-For")`.
1211
*/

0 commit comments

Comments
 (0)