Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26e10f3

Browse files
committed
SSRF: don't consider results of fetches we initiated to be untrustworthy
1 parent c63d598 commit 26e10f3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

java/ql/src/Security/CWE/CWE-918/RequestForgery.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ import DataFlow::PathGraph
1818
class RequestForgeryConfiguration extends TaintTracking::Configuration {
1919
RequestForgeryConfiguration() { this = "Server Side Request Forgery" }
2020

21-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
21+
override predicate isSource(DataFlow::Node source) {
22+
source instanceof RemoteFlowSource and
23+
// Exclude results of remote HTTP requests: fetching something else based on that result
24+
// is no worse than following a redirect returned by the remote server, and typically
25+
// we're requesting a resource via https which we trust to only send us to safe URLs.
26+
not source.asExpr().(MethodAccess).getCallee() instanceof URLConnectionGetInputStreamMethod
27+
}
2228

2329
override predicate isSink(DataFlow::Node sink) { sink instanceof RequestForgerySink }
2430

0 commit comments

Comments
 (0)