{"record":{"id":"49888cf2968dbdec","repo":"crowdsecurity/crowdsec","slug":"errcookiesignature","errorCode":"ErrCookieSignature","errorMessage":"%w: %w","messagePattern":"%w: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/challenge/crypto.go","lineNumber":239,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create cipher: %w\", err)\n\t}\n\n\tgcm, err := cipher.NewGCM(block)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create GCM: %w\", err)\n\t}\n\n\tnonceSize := gcm.NonceSize()\n\tif len(body) < nonceSize {\n\t\treturn nil, fmt.Errorf(\"%w: ciphertext too short\", ErrCookieMalformed)\n\t}\n\n\tnonce, ciphertext := body[:nonceSize], body[nonceSize:]\n\n\tplaintext, err := gcm.Open(nil, nonce, ciphertext, aad)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%w: %w\", ErrCookieSignature, err)\n\t}\n\n\tif len(plaintext) < cookiePlaintextFixedHeaderLen {\n\t\treturn nil, fmt.Errorf(\"%w: plaintext shorter than fixed header\", ErrCookieMalformed)\n\t}\n\n\tnotAfter := int64(binary.BigEndian.Uint64(plaintext[:8]))\n\tflags := plaintext[8]\n\treasonLen := int(binary.BigEndian.Uint16(plaintext[9:11]))\n\n\tif reasonLen > MaxAllowlistReasonLen {\n\t\treturn nil, fmt.Errorf(\"%w: reason_len=%d\", ErrCookieMalformed, reasonLen)\n\t}\n\n\tif len(plaintext) < cookiePlaintextFixedHeaderLen+reasonLen {\n\t\treturn nil, fmt.Errorf(\"%w: plaintext shorter than declared reason_len\", ErrCookieMalformed)\n\t}\n","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/challenge/crypto.go#L221-L257","documentation":"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.","triggerScenarios":"Thrown at pkg/appsec/challenge/crypto.go:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}