Files
codeql/go/ql/test/query-tests/Security/CWE-918/RequestForgery.go
2022-05-20 10:07:19 -07:00

19 lines
329 B
Go

package main
import (
"net/http"
)
func handler(w http.ResponseWriter, req *http.Request) {
target := req.FormValue("target")
// BAD: `target` is controlled by the attacker
resp, err := http.Get("https://" + target + ".example.com/data/")
if err != nil {
// error handling
}
// process request response
use(resp)
}