Corrupting the true last character of a JWT's base64url-encoded HMAC-SHA256 signature is unreliable: that character encodes only 4 real bits plus 2 unused padding bits, and Go's encoding/base64 ignores those padding bits by default -- about 1 in 4 replacement characters decode to byte-identical signature bytes, so the "tampered" cookie still verifies and the test spuriously passes. Corrupting the second-to-last character instead is deterministic, since HMAC-SHA256's fixed 32-byte digest length means that position is always fully significant. Confirmed via 20 repeated runs (previously ~1/3 failure rate). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2.2 KiB
2.2 KiB