Menu

How I Stopped Passcode Brute-Force From Freezing Live Keystrokes in Carrel
📰

How I Stopped Passcode Brute-Force From Freezing Live Keystrokes in Carrel

DEV Community·Ayush Agarwal·3 days ago
#Mivr2Y8o
#dev#carrel#scrypt#server#room
Long article (343 words) — no AI summary yet.
Reading 0:00
15s threshold

When I started building Carrel, a real-time collaborative CodeMirror 6 workspace, I thought auth was the easy part: hash room passcodes with scrypt , verify on join, done.

Then I tested what happens under brute-force traffic. scrypt is slow on purpose. Run it synchronously and it blocks Node's event loop; run dozens of async scrypt calls uncapped and they saturate libuv's threadpool. Either way, anyone hammering wrong passcodes starts stuttering live keystrokes for everyone typing in the room.

Here is how I ended up structuring the server and protocol across the 3-package TypeScript monorepo ( @carrel/shared , @carrel/server , @carrel/client ):

1. Bounded scrypt + single-use WS tickets

In server/src/throttle.ts , POST /api/rooms/:id/ticket runs async scrypt inside a 4-slot concurrency limiter paired with per-IP progressive lockouts (and ignores X-Forwarded-For unless TRUST_PROXY is explicitly enabled).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.