A server sends a request to an address taken from an incoming request without a check
What it finds
http.Get(r.URL.Query().Get("url")): a server that fetches whatever address a request names can be made to reach hosts that only it can see, such as cloud metadata services or internal administration pages, and to send the answers back. Addresses are checked against the hosts the feature needs.
The address must be a request value of the handler, as described for the request values of the pack, given to http.Get, http.Head, http.Post, http.PostForm, http.NewRequest or http.NewRequestWithContext, that the function does not check in a condition.
From the rule's source, request_url_fetched.rs.
package p import "net/http" func proxy(w http.ResponseWriter, r *http.Request) { resp, err := http.Get(r.URL.Query().Get("url"))tx0 reports: http.Get is given an address taken from the request if err != nil { return } defer resp.Body.Close() target := "https://api.example.com/" + r.FormValue("id") req, _ := http.NewRequest("GET", target, nil)tx0 reports: http.NewRequest is given an address taken from the request _ = req} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go: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/go:request-url-fetched] reason="..."tx0 explain tx0/go:request-url-fetched shows the same in the terminal. Found a false positive? Report it.