Skip to content

Commit 56bcbf3

Browse files
committed
add additional taint steps to SSRF query
1 parent e38cb0f commit 56bcbf3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

go/ql/src/experimental/CWE-918/SSRF.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module ServerSideRequestForgery {
1515
private import semmle.go.security.UrlConcatenation
1616
private import semmle.go.dataflow.barrierguardutil.RegexpCheck
1717
private import semmle.go.dataflow.Properties
18+
private import semmle.go.frameworks.Fasthttp
1819

1920
/**
2021
* DEPRECATED: Use `Flow` instead.
@@ -175,4 +176,30 @@ module ServerSideRequestForgery {
175176
* of the error binding exists, and the tag to check is one of "alpha", "alphanum", "alphaunicode", "alphanumunicode", "number", "numeric".
176177
*/
177178
class ValidatorAsSanitizer extends Sanitizer, ValidatorVarCheckBarrier { }
179+
180+
/**
181+
* A additional step that can be used mostly for request forgery related queries
182+
*/
183+
bindingset[this]
184+
abstract class AdditionalStep extends string {
185+
/**
186+
* Holds if `pred` to `succ` is an additional taint-propagating step for this query.
187+
*/
188+
abstract predicate hasTaintStep(DataFlow::Node pred, DataFlow::Node succ);
189+
}
190+
191+
/**
192+
* An additional step for Fasthttp framework uri and request instances.
193+
*
194+
* These steps can help to track the user provided URI to a dangerous SSRF sink.
195+
*/
196+
class FasthttpAdditionalStep extends AdditionalStep {
197+
FasthttpAdditionalStep() { this = "FastHTtp additional steps" }
198+
199+
override predicate hasTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
200+
any(Fasthttp::Request::RequestAdditionalStep r).hasTaintStep(pred, succ)
201+
or
202+
any(Fasthttp::URI::UriAdditionalStep r).hasTaintStep(pred, succ)
203+
}
204+
}
178205
}

0 commit comments

Comments
 (0)