Skip to content

fix: use constant-time comparison for auth token (CWE-208) - #576

Closed
spidershield-contrib wants to merge 1 commit into
taskgenius:masterfrom
spidershield-contrib:fix/cwe-208-timing-safe-comparison
Closed

spidershield-contrib wants to merge 1 commit into
taskgenius:masterfrom
spidershield-contrib:fix/cwe-208-timing-safe-comparison

Conversation

@spidershield-contrib

Copy link
Copy Markdown

Summary

Fixes #575 — replaces timing-vulnerable === comparison with constant-time timingSafeEqual via SHA-256 digest.

Changes

  • Add safeEqual() helper using crypto.createHash + crypto.timingSafeEqual
  • Replace direct === in validateRequest() with constant-time comparison
  • No behavioral change for valid authentication flows

CWE Reference

  • CWE-208: Observable Timing Discrepancy
  • Uses stdlib only (crypto) — no new dependencies

Found by SpiderShield security scanner

Replace direct === comparison with crypto.timingSafeEqual via SHA-256
digest to prevent timing-based token extraction attacks.

- No behavioral change for valid authentication flows
- Uses stdlib only (crypto) — no new dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@spidershield-contrib

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@Quorafind

Copy link
Copy Markdown
Member

Thank you for reporting this and for the fix! Because the CLA hasn't been signed, I can't merge this PR, so I'm closing it; #575 stays open to track the timing-safe comparison.

@Quorafind Quorafind closed this Nov 29, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: timing-vulnerable token comparison in AuthMiddleware (CWE-208)

2 participants