DoS for GCSArtifact.RealAll
The spyglass lens endpoint allows an attacker to control the artifact name, causing the server to download a large object into memory. Concurrent requests can exhaust server memory, leading to denial of service.
- Triaged in 10 days
- Fixed in 6 months
- Paid in 51 days
- Disclosed after 10 months
Hi, I'm not be goot at english, if have anything don’t understand, please contact me.
Thanks!
Summary:
attackers can control artifactName list make google storage client download large object cause denial of service.
Component Version:
kubenetes/test-infra:master(SHA:fea5af139ecdac00e5efa46539bc80bd0f9e951c)
Steps To Reproduce:
- request this url, we can see the http response is slowly.so i analyze the code process flow.
https://prow.k8s.io/spyglass/lens/buildlog/rerender?req={"artifacts":["k8s-test-cache.tar.gz"],"index":0,"src":"gcs/kubernetes-jenkins/cache/poc/"}
```{{media:0}}
2. in "/spyglass/lens/" endpoint handle function, we can control the req.artifacts params make google storage client download a large object in memory. the vuln code flow like this:
test-infra/prow/cmd/deck/main.go:702 func handleArtifactView() -> test-infra/prow/cmd/deck/main.go:1151 sg.FetchArtifacts(..., request.Artifacts) -> test-infra/prow/spyglass/artifacts.go:119 s.GCSArtifactFetcher.artifact(..., artifactname) -> etc..(path process, url sign) test-infra/prow/cmd/deck/main.go:1175 lens.Body(artifacts) -> test-infra/prow/spyglass/lenses/buildlog/lens.go:190 logLinesAll(artifact) -> test-infra/prow/spyglass/lenses/buildlog/lens.go:213 artifact.ReadAll() -> test-infra/prow/spyglass/gcsartifact.go:205 ioutil.ReadAll(reader)
{{media:1}}
3.ensure prow infra is not interrupted, i write the simple code to simulation the vuln code, and use `ab -n 30 -c 30 http://localhost:8090/download` command concurrent request website.
package main
import ( "net/http" "fmt" "io/ioutil" "strings" )
func client() (r *http.Response, err error){ var res *http.Response var hc = &http.Client{} // req, err := http.NewRequest("GET", "https://storage.googleapis.com/kubernetes-jenkins/cache/poc/k8s-test-cache.tar.gz", nil) req, err := http.NewRequest("GET", "http://localhost/10MB.BIN", nil) if err != nil { return nil, err }
res, err = hc.Do(req)
if err != nil {
return nil, err
}
return res, nil
}
func download(w http.ResponseWriter, req *http.Request) { res, err := client() if err != nil { fmt.Fprintf(w, "err") }
defer res.Body.Close()
read, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Fprintf(w, "err")
}
lines := strings.Split(string(read), "\n")
data := strings.Join(lines, "")
fmt.Fprintf(w, data)
}
func main() { http.HandleFunc("/download", download)
http.ListenAndServe(":8090", nil)
}
result:
{{media:2}}
4.i think concurrent request the prow spyglass endpoint also make server out of memory.
## Impact
attacker can send HTTP request to the prow can cause an a denial of service by control the fetcher download large object.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application does not limit the size of artifacts it downloads and reads into memory, allowing user-controlled artifact names to trigger large downloads.
Impact
An attacker could send concurrent HTTP requests to the prow endpoint, causing a denial of service by making the server download large objects into memory.
What the attacker needed
Access to the prow spyglass endpoint; ability to send HTTP requests
How it was found
- Send a request to the spyglass lens endpoint with a crafted req parameter specifying a large artifact.
- Observe that the HTTP response is slow, indicating the server is downloading the large object.
- Simulate the vulnerability with a simple Go program that downloads a large file and reads it into memory.
- Use a concurrent request tool to send many requests to the simulation, causing memory exhaustion.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The server has a feature that fetches files from cloud storage based on a name you provide. If you give it the name of a very large file, the server tries to load the whole file into its memory. If many people do this at once, the server runs out of memory and stops working for everyone.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.