Skip to content

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

Open
spidershield-contrib wants to merge 1 commit intoagent0ai:mainfrom
spidershield-contrib:fix/cwe-208-timing-safe-comparison
Open

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

Conversation

@spidershield-contrib
Copy link
Copy Markdown

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

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)

1 participant