Skip to content

Commit 3b7385b

Browse files
committed
fix(auth): set Secure and SameSite on the session-clearing cookie
The logout cookie dropped the attributes the login cookie was set with, so a strict browser could decline to overwrite the Secure cookie and leave the session cookie in place — and CodeQL flagged the missing Secure flag. Match setSessionCookie's attributes so the deletion actually takes.
1 parent 6489910 commit 3b7385b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/server/panel.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,13 @@ func (rt *Router) logout(w http.ResponseWriter, r *http.Request) {
590590
}
591591
_ = rt.mgr.Store().DeleteSession(c.Value)
592592
}
593+
// Match every attribute the session cookie was set with (see setSessionCookie),
594+
// not just the name and path: a browser only overwrites a cookie when Secure and
595+
// SameSite line up too, so a bare deletion can leave the Secure cookie in place —
596+
// and it keeps this expiry off any accidental plaintext path all the same.
593597
http.SetCookie(w, &http.Cookie{
594598
Name: sessionCookie, Value: "", Path: rt.cookiePath(),
595-
HttpOnly: true, MaxAge: -1,
599+
HttpOnly: true, Secure: true, SameSite: http.SameSiteLaxMode, MaxAge: -1,
596600
})
597601
writeOK(w)
598602
}

0 commit comments

Comments
 (0)