AntFleet

Disagreement · 748568f3-anthropic-1

Token comparison decodes attacker-controlled base64 length before length check — non-issue but `timingSafeEqual` precondition is checked correctly; however, payload JSON parsing happens after MAC verify which is fine, but the `dot === token.length - 1` guard does not reject tokens whose payload is empty

solo Opus
repo e24ef98c·PR #9·reviewed 1 week ago

Opus finding

Token comparison decodes attacker-controlled base64 length before length check — non-issue but `timingSafeEqual` precondition is checked correctly; however, payload JSON parsing happens after MAC verify which is fine, but the `dot === token.length - 1` guard does not reject tokens whose payload is empty

lowapi-contractmedium
  • apps/web/lib/optin-token.ts:62-66
  • apps/web/lib/optin-token.ts:67
If `dot === 0` (token like ".mac"), `encodedPayload` is the empty string. The HMAC is computed over an empty payload and the function proceeds to JSON.parse on an empty buffer, which throws and returns invalid — so functionally safe. But the explicit empty-payload guard is missing, so the test case `verifyToken(".onlymac")` happens to pass only because base64-decoded empty MAC has length 0 ≠ expected 32, returning invalid. Still works; defensive guard would clarify intent. Low severity.

Recommendation

Reject `dot === 0` explicitly alongside the trailing-dot check for clarity and to harden against future refactors.

Other reviewer

The other reviewer flagged nothing in this file/line range.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →

From the same review

These findings passed the unanimous gate on the same PR review. The disagreement above was filtered out; the findings below were posted.