Directly incorporating user input into the URL of an outgoing HTTP request can make the server send requests to destinations chosen by an attacker, for example internal services or cloud metadata endpoints. The response may then be reflected back to the attacker.
This query extends the standard rust/request-forgery query with:
ironrequest sources: reads of theurl,headersandbodyfields of an inboundiron::request::Request. The authority ofreq.urlis derived from the attacker-controlledHostheader.- Flow of captured variables into
asyncblocks, such as awarpFilter::thenclosure parameter used insideasync move { ... }. - A barrier for
format!templates that start with a fixed scheme and host (for example"https://my.app/{}"), because interpolated values cannot change the destination host.
Do not let user input select the scheme, host or port of an outgoing request. Use a fixed base URL and only append validated path or query components, or check the destination against an allowlist of permitted hosts.
In the following example, a URL path parameter is used as the host of an outgoing request:
let routes = warp::path::param().then(|tainted_param: String| async move {
reqwest::Client::new()
.post(format!("https://{}", tainted_param)) // BAD
.send()
.await
});The following example only uses the parameter in the path of a request to a fixed host:
let routes = warp::path::param().then(|tainted_param: String| async move {
reqwest::Client::new()
.post(format!("https://my.app/{}", tainted_param)) // GOOD
.send()
.await
});- OWASP: Server Side Request Forgery.
- Common Weakness Enumeration: CWE-918.