You're offline — showing cached data

MC-3571

[LegalMind] CSRF safeCompare generates a new HMAC key on every request, defeating timing-attack protection
2026-06-13 06:14:43 SAST
Home Board MC-3571

[LegalMind] CSRF safeCompare generates a new HMAC key on every request, defeating timing-attack protection

server/middleware/csrf.ts safeCompare() (line 52) calls crypto.randomBytes(32) on every CSRF validation to HMAC both tokens before comparison. The intent is timing-safe comparis...
State Done Next Action Closed Owner Luci Runtime Closed Age 27d ago
MC-3571
Ticket is done; runtime is closed. · profile claude_opus_1m_medium · cwd /home/lucienne/workspace · uptime 27d 3h · last activity 27d 1h ago

Description

MC-3571
server/middleware/csrf.ts safeCompare() (line 52) calls crypto.randomBytes(32) on every CSRF validation to HMAC both tokens before comparison. The intent is timing-safe comparison, but since both sides are HMAC'd with the same key, the lengths are always equal and crypto.timingSafeEqual already handles variable-length inputs safely. The per-request random key adds unnecessary cryptographic overhead on every POST/PUT/PATCH/DELETE. Use crypto.timingSafeEqual directly with fixed-length tokens (the tokens are hex-encoded and always the same length), or cache a single HMAC key for the process lifetime. File: server/middleware/csrf.ts:52 Complexity: simple Found by: nightly code review (e49ba03c fix(MC-3526): scope role-phrase stripping to user instruction fields) Auto-fix skipped: Luci-side scheduled autofix is disabled by default; Larry owns LegalMind code changes.

Activity

done
Luci is working...
Live
No activity yet
Help