#0605
Your application encodes session data as a base64 JSON payload and appends a signature — forming a cookie like `PAYLOAD_B64.SIGNATURE`.
The buggy implementation decodes and returns the payload without ever checking the signature, so an attacker can craft a cookie with an arbitrary payload (e.g., elevating their role to `admin`) and the server accepts it as authentic.
The fix must compute HMAC-SHA256 of the base64 payload with a secret key and reject any cookie whose signature does not match.
Skipping signature verification on session cookies has caused critical authentication bypasses in real-world applications. Without HMAC, any user can forge any session payload and impersonate any account, including administrators.
verifyCookie('supersecret', 'eyJ1c2VySWQiOiJhbGljZSIsInJvbGUiOiJhZG1pbiJ9.FAKE_SIG')// BUG returns: {userId:'alice', role:'admin'} — privilege escalation!// FIX throws: Error('Invalid signature')
verifyCookie('supersecret', 'invaliddatanocookie')// throws: Error('Invalid cookie format')