Skip to content

Commit

Permalink
SEC-53 don't backto to external urls (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
DTCurrie authored Oct 22, 2024
1 parent 56b97fc commit 25570d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,15 @@ func (h *loginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
})

if r.FormValue("backto") != "" {
session.Data["backto"] = r.FormValue("backto")
backto := r.FormValue("backto")

// to prevent redirecting to an external URL we only set the session data when we fail to parse backto
_, err := url.ParseRequestURI(backto)
if err != nil {
session.Data["backto"] = backto
}
}

if session.Data["backto"] == "" {
session.Data["backto"] = r.Header.Get("Referer")
}
Expand Down

0 comments on commit 25570d0

Please sign in to comment.