Code RoomLogin redirect open redirect
MediumPrep Room Coding #2178

Login redirect open redirect

Code reviewSecurityMid–Senior~15 min

Review this Go post-login redirect handler.

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 15 min
Mark a line and say what kind of problem it is.0 findings
1func PostLogin(w http.ResponseWriter, r *http.Request) {
2 if !authenticate(r) {
3 http.Error(w, "bad creds", 401)
4 return
5 }
6 next := r.URL.Query().Get("next")
7 if next == "" {
8 next = "/dashboard"
9 }
10 http.Redirect(w, r, next, http.StatusFound)
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.