A server connects to an address taken from an incoming request without a check
What it finds
URL(call.parameters["url"]).readText() makes the server fetch any address the client names, including services inside the network and cloud metadata endpoints that are not reachable from outside (CWE-918). Fetch only addresses the server chose, or check the host against a list.
Reported for a request value, as for request-path-in-file-access, given to URL(...) that is then opened or read, to the request functions of an HTTP client (get, post, request and the like on a receiver named as a client), to getForObject, getForEntity, postForObject, exchange, or to url(...) of a request builder.
From the rule's source, request_flows.rs.
import io.ktor.server.application.ApplicationCall class Proxy(private val client: HttpClient) { suspend fun fetch(call: ApplicationCall) { val target = call.request.queryParameters["url"]!! val body = URL(target).readText()tx0 reports: the address comes from the request val page = client.get(target)tx0 reports: the address comes from the request val parsed = URL(target) val fixed = client.get("https://api.example.com/status") val request = Request.Builder().url(target).build()tx0 reports: the address comes from the request cache.get(target) val wiki = client.request("https://en.wikipedia.org${call.request.uri}") val host = client.get("https://${call.parameters["host"]}/status")tx0 reports: the address comes from the request }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:request-url-fetched" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:request-url-fetched] reason="..."tx0 explain tx0/kotlin:request-url-fetched shows the same in the terminal. Found a false positive? Report it.