mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-17 04:37:48 +00:00
fix(security): close confirmed findings from the 2026-10-15 hunt (#166)
Seven findings are fixed. Each fix has a regression test. - Compare X-Forwarded-Host and the serving host case-insensitively, so a case variant cannot widen the session cookie Domain. - Reject a future iat on the opaque introspection path. - Serve the cached parsed JWKS inside the signature-refresh cooldown. - Release the half-open circuit slot when a probe panics. - Cap requests that wait for provider initialisation at 512. Extra requests receive 503 with Retry-After. - Cap cookie deletion headers at 32 cookie names per response. - Cap front-channel sid markers at 1000, so unauthenticated requests cannot evict backchannel or jti replay markers.
This commit is contained in:
+10
-1
@@ -116,6 +116,10 @@ const (
|
||||
defaultCookiePrefix = "_oidc_raczylo_"
|
||||
)
|
||||
|
||||
// maxCleanupCookies bounds the cookie names CleanupOldCookies emits deletion
|
||||
// headers for per response (up to 4 Set-Cookie headers each).
|
||||
const maxCleanupCookies = 32
|
||||
|
||||
const (
|
||||
// maxCookieSize is the maximum raw data size per chunk before securecookie encoding.
|
||||
//
|
||||
@@ -937,6 +941,9 @@ func (sm *SessionManager) EnhanceSessionSecurity(options *sessions.Options, r *h
|
||||
// service). Keep it unless it is a strict parent of the serving
|
||||
// host, which would scope the token-bearing cookie to sibling
|
||||
// subdomains — then fall back to the serving host.
|
||||
// DNS names and the cookie Domain attribute are case-insensitive.
|
||||
host = strings.ToLower(host)
|
||||
fh = strings.ToLower(fh)
|
||||
if !strings.HasSuffix(host, "."+fh) {
|
||||
host = fh
|
||||
}
|
||||
@@ -1024,6 +1031,7 @@ func (sm *SessionManager) CleanupOldCookies(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
processedCookies := make(map[string]bool)
|
||||
deletedCookies := 0
|
||||
|
||||
for _, cookie := range cookies {
|
||||
// Check if cookie belongs to this middleware instance using the configured prefix
|
||||
@@ -1037,7 +1045,8 @@ func (sm *SessionManager) CleanupOldCookies(w http.ResponseWriter, r *http.Reque
|
||||
shouldCleanup := currentDomain != "" && !sm.cleanupDone
|
||||
sm.cleanupMutex.RUnlock()
|
||||
|
||||
if shouldCleanup {
|
||||
if shouldCleanup && deletedCookies < maxCleanupCookies {
|
||||
deletedCookies++
|
||||
for _, domain := range domainsToClean {
|
||||
if domain == currentDomain || domain == "."+currentDomain || "."+domain == currentDomain {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user