Code RoomFile path traversal unvalidated
HardPrep Room Coding #1778

File path traversal unvalidated

Code reviewCode quality & reviewSenior–Staff~24 min

Review this Go file-download endpoint.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 24 min
Mark a line and say what kind of problem it is.0 findings
1func Download(w http.ResponseWriter, r *http.Request) {
2 name := r.URL.Query().Get("file")
3 path := filepath.Join("/srv/uploads", name)
4 data, err := os.ReadFile(path)
5 if err != nil {
6 http.Error(w, "not found", 404)
7 return
8 }
9 w.Header().Set("Content-Type", "application/octet-stream")
10 w.Write(data)
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.