crowdsecurity/crowdsec · error
ErrCookieSignature
ErrCookieSignature
Error message
%w: %w
What it means
AES-GCM authentication of the cookie ciphertext failed while opening a v0 cookie envelope: the ciphertext (or AAD) does not match the master cookie key. ErrCookieSignature wraps the crypto error; causes are key rotation to a different secret, a tampered cookie, or corruption. The cookie is treated as invalid and the client re-challenged.
Source
Thrown at pkg/appsec/challenge/crypto.go:239
if err != nil {
return nil, fmt.Errorf("failed to create cipher: %w", err)
}
gcm, err := cipher.NewGCM(block)
if err != nil {
return nil, fmt.Errorf("failed to create GCM: %w", err)
}
nonceSize := gcm.NonceSize()
if len(body) < nonceSize {
return nil, fmt.Errorf("%w: ciphertext too short", ErrCookieMalformed)
}
nonce, ciphertext := body[:nonceSize], body[nonceSize:]
plaintext, err := gcm.Open(nil, nonce, ciphertext, aad)
if err != nil {
return nil, fmt.Errorf("%w: %w", ErrCookieSignature, err)
}
if len(plaintext) < cookiePlaintextFixedHeaderLen {
return nil, fmt.Errorf("%w: plaintext shorter than fixed header", ErrCookieMalformed)
}
notAfter := int64(binary.BigEndian.Uint64(plaintext[:8]))
flags := plaintext[8]
reasonLen := int(binary.BigEndian.Uint16(plaintext[9:11]))
if reasonLen > MaxAllowlistReasonLen {
return nil, fmt.Errorf("%w: reason_len=%d", ErrCookieMalformed, reasonLen)
}
if len(plaintext) < cookiePlaintextFixedHeaderLen+reasonLen {
return nil, fmt.Errorf("%w: plaintext shorter than declared reason_len", ErrCookieMalformed)
}
View on GitHub (pinned to 909b515798)
Solutions
- Check cookie-key consistency across replicas — different master keys make all cookies fail GCM open
- No action for isolated occurrences (tampered cookies are the attacker's problem)
- If all cookies fail after a redeploy, restore the previous secret or wait for cookie TTL expiry
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pkg/appsec/challenge/crypto.go:239 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/49888cf2968dbdec.
Report an issue: GitHub.