Skip to content

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

Closed
teehooai wants to merge 1 commit intoagent0ai:mainfrom
teehooai:fix/cwe-208-timing-safe-comparison
Closed

fix: use constant-time comparison for auth token (CWE-208)#1352
teehooai wants to merge 1 commit intoagent0ai:mainfrom
teehooai:fix/cwe-208-timing-safe-comparison

Conversation

@teehooai
Copy link
Copy Markdown

@teehooai teehooai commented Mar 28, 2026

Summary

Fixes #1351 — replaces timing-vulnerable == comparison with constant-time hmac.compare_digest.

Changes

  • Replace direct string comparison with constant-time comparison for MCP server token (2 locations)
  • Add None guard to prevent TypeError when token is not set
  • No behavioral change for valid authentication flows

CWE Reference

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

Found by SpiderShield security scanner

@teehooai
Copy link
Copy Markdown
Author

teehooai commented Apr 3, 2026

Superseded by #1424 (submitted from correct account spidershield-contrib)

@teehooai teehooai closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: timing attack in auth token comparison (CWE-208)

2 participants