DEV Community

Cover image for Timing Attacks in Node.js

Timing Attacks in Node.js

Ali nazari on April 22, 2025

Let’s start from the very beginning: What a timing attack is (CWE‑208), why it matters in Node.js, and exactly how you can stop it. CWE stands f...
Collapse
 
voidbrain profile image
daniele

How does it handle high inconsistency in response time of a request in the network? How can it work?

Collapse
 
silentwatcher_95 profile image
Ali nazari

By enforcing a fixed minimum server‐side processing time, you guarantee every response leaves the server at the same moment.

Any extra network jitter then just adds random noise, so attackers can’t tease out microsecond‑scale differences—even over an inconsistent connection.

Collapse
 
voidbrain profile image
daniele

So did you just confirm fixed minimum server reply time is useless based on the fact that there is always random noise since internet is an incosistent network?

Thread Thread
 
silentwatcher_95 profile image
Ali nazari

consider this example:

Imagine you're trying to hide a whisper in a room:

  • If the room is silent, people might hear your whisper.
  • But if the room has lots of random noise (like a party 🎉), your whisper gets lost in the chaos.

Now:

  • The server’s timing differences (like failing early when a password is wrong) are like that whisper.
  • The internet (with random delays) is the noisy party.
  • But if your server sometimes whispers, sometimes shouts, patterns might still be found.

p.s : i got this example from chatgpt 🤣

Thread Thread
 
voidbrain profile image
daniele

I see the point and yes, in theory this can be done.
The topic is interesting.

However I just need to PING google.com
time=31.390 ms
time=25.018 ms
time=28.266 ms
time=24.029 ms
time=27.678 ms
to answer myself this is unusable in RL.

Thread Thread
 
silentwatcher_95 profile image
Ali nazari

Next time my boss tells me to add this feature, I’ll show him this comment as proof that it’s useless—thanks! 🗿🫡🤣

Thread Thread
 
voidbrain profile image
daniele

Maybe you'll save him money.

Thread Thread
 
silentwatcher_95 profile image
Ali nazari

you're right, I just can’t stop being everyone’s hero.

Collapse
 
nevodavid profile image
Nevo David

super helpful breakdown honestly - makes me want to double check my stuff. you ever caught a timing leak in your own code before or did you only learn about it later?

Collapse
 
silentwatcher_95 profile image
Ali nazari

Thanks! Honestly, I just patch what I can and pray to the dev gods no one ever reports a timing attack on my stuff 🗿🤲🏻

Collapse
 
silentwatcher_95 profile image
Ali nazari

Happy to hear you're inspired to change that! :)

Collapse
 
silentwatcher_95 profile image
Ali nazari

Send this post to someone who needs to read this before Monday.