Skip to content

fix(mcp): improve SseAuthGuard timing-safe comparison#717

Merged
JeremyDev87 merged 2 commits intomasterfrom
fix/sse-auth-timing-safe-704
Mar 20, 2026
Merged

fix(mcp): improve SseAuthGuard timing-safe comparison#717
JeremyDev87 merged 2 commits intomasterfrom
fix/sse-auth-timing-safe-704

Conversation

@JeremyDev87
Copy link
Owner

Summary

  • Replace tokensMatch() Buffer length early-return with HMAC-SHA256 hashing before timingSafeEqual
  • Eliminates token length timing side-channel leak — both tokens are hashed to fixed 32-byte digests
  • Add 3 tests: different-length token rejection, HMAC hash property verification

Test plan

  • 11 SseAuthGuard tests pass (8 existing + 3 new)
  • lint, format, typecheck, coverage, circular, build all pass
  • Correct token accepted, wrong token rejected (behavior unchanged)
  • Different-length tokens compared in constant time via HMAC

Closes #704

- Replace Buffer length check with HMAC-SHA256 hashing before timingSafeEqual
- Eliminates token length timing side-channel leak
- Add tests for different-length token rejection and HMAC hash properties

Closes #704
@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codingbuddy-landing Ready Ready Preview, Comment Mar 20, 2026 8:00am

@JeremyDev87 JeremyDev87 merged commit 6a8226d into master Mar 20, 2026
25 checks passed
@JeremyDev87 JeremyDev87 deleted the fix/sse-auth-timing-safe-704 branch March 20, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(mcp): improve SseAuthGuard timing-safe comparison

1 participant