Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ func oauth2login(
// Authorization redirect callback from OAuth2 auth flow.
// Handles both implicit and authorization code flow
callbackHandler := func(w http.ResponseWriter, r *http.Request) {
log.Printf("Callback received on: %s\n", r.URL.Path)
// G706: Sanitize URL path before logging to prevent log injection via newline characters.
safePath := strings.NewReplacer("\n", "", "\r", "").Replace(r.URL.Path)
log.Printf("Callback received on: %s\n", safePath) // #nosec G706 -- path is sanitized above

if formErr := r.FormValue("error"); formErr != "" {
handleErr(w, fmt.Sprintf("%s: %s", formErr, r.FormValue("error_description")))
Expand Down Expand Up @@ -302,7 +304,11 @@ func oauth2login(
completionChan <- ""
}

srv := &http.Server{Addr: "localhost:" + strconv.Itoa(port)}
// G112: Set ReadHeaderTimeout to mitigate Slowloris DoS attack.
srv := &http.Server{
Addr: "localhost:" + strconv.Itoa(port),
ReadHeaderTimeout: 3 * time.Second,
}
http.HandleFunc("/auth/callback", callbackHandler)

var url string
Expand Down
Loading