The tale of avoiding a time-based DDOS attack in Node.js

Rate this content
Bookmark

Web applications are commonly vulnerable to several Distributed Denial of Service attacks, sometimes in unexpected ways. An example is the SlowLoris attack, an exploit that leads to service interruption by simply sending the data to the server as slowest as possible.  In this talk I will tell the tale of how it took almost 13 years for Node to be completely protected by SlowLoris attack. I will also show that sometimes prioritizing performance can lead to incorrect fixes that can result in a false sense of protection.

Paolo Insogna
Paolo Insogna
29 min
14 Apr, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Web applications face constant threats from DDoS attacks, including the new Zoloris attack that can bring down a server with minimal bandwidth. Node.js has had vulnerabilities in its timeout handling, but recent versions like Node 18 provide better protection. NGINX is recommended for protection against slow loris attacks due to its superior timeout handling. Mitigating slow loris attacks for WebSockets involves enforcing higher timeouts and shutting down idle clients. It is important to prioritize security over performance and use common sense in software development.

1. Introduction and Background

Short description:

Sometimes your worst enemy is just slowness. At the end of the talk, you will be amazed at what happened. I am a staff Dx engineer at Nearform and co-founder and principal architect at Orama. Nearform is a professional services company fully remote. We are 300 and counting, fully remote, and unfortunately you cannot escape from us on NPM. Without Orama, we plan to reinvent the text search industry using JavaScript and staying open source.

I promise I will change this title because it's definitely too long but let's put to a short catchy sentence. Sometimes your worst enemy is just slowness. You now don't believe me but at the end of the talk you actually will believe me and you will be amazed on how this happened.

First of all let me slightly reintroduce myself. For people that ask me where do I come from? The little tiny dot there in the centre of South Italy and I can tell you that the rest of Italy does not acknowledge our existence. My region is completely forgotten. Don't ask me why but as I was also said I am a staff Dx engineer at Nearform and co-founder and principal architect at Orama. What are these companies? Nearform is a professional services company fully remote. We are always looking for new talents so if you're interested come say hi to me after this talk. We are 300 and counting, fully remote, and unfortunately you cannot escape from us on NPM. We are 1 billion monthly downloads on our packages, 8% so unfortunately you cannot escape. Without Orama, we plan just to do one simple thing. Search everywhere, wherever you can run JavaScript. We are trying to reinvent the text search industry, just using JavaScript and staying open source. Once again, if you're interested, come say hi to me later, to me or my co-founder Michele and Angela, we are outside.

2. DDoS Attacks and the Zoloris

Short description:

Nowadays web applications are crucial, serving important functions like telemedicine, online banking, and national security, as well as more trivial purposes like social networks and messaging. However, even these seemingly trivial applications are vital for certain individuals, such as the elderly who rely on messaging apps to communicate. The constant threat of DDoS attacks looms over all applications, as attackers always outnumber those defending. DDoS attacks involve overwhelming a network resource with malicious requests, and the distributed variant, where malicious traffic comes from multiple sources, is particularly challenging to combat. While it was once believed that DDoS attacks required a significant amount of resources, a new threat called Zoloris proves otherwise.

Let's get to the meat. Nowadays we are using more and more web applications and they are very important for all our usage. They can range from very important topics like, I don't know telemedicine, online banking, national security, or whatever, to what might be taken as trivial topics like social networks, messaging and so forth.

I say it might be called trivial because if you think about accessibility and inclusion, for some kind of people like elderly and so forth, WhatsApp might be the only way to talk to their nephew. So if you have WhatsApp down, you cut them off from very important part of their communication. So all these applications simply can never go down. That's not going to happen.

Which brings to another problem that we are always all vulnerable. No matter how smart you think you are, no matter how many people work for security in your company, remember that there's going to be 10 more people outside trying to waste your time and mess with your application and to bring them down. Unfortunately, they always outnumbering you.

This brings to one category of attacks which is usually well known. Please raise your hand if you know about DDoS attacks. And raise your hand if you know DDoS attacks, the dead variant. Okay pretty much the same people. So in short. So denial of service attack is kind of attack where a network resource is maliciously made unavailable to the intended user. Now the application is not breached by the attacker but is overwhelmed by requests. There is the distributed version which is the DDoS attack which is what I'm gonna focus from now on. Which is a variant where malicious traffic comes from several resources across the web. Which is much harder to fight for the reason that we will see in a bit. Now up to a few years ago it was a common understanding that in order to drive a DDoS attack, the attacker must use a lot of resources from several sources across the globe. Now please raise your hand if you think that this is still true and in order to run a DDoS attack you have to use a lot of resources. Okay, okay, that's kind of true and not and I will show you in a bit why that's the case. Because first of all let me introduce you your real enemy for today. This is the most horrific animal I ever seen in IT. This guy. This guy is terrifying. When I will tell you why you will say okay, this is amazing. So this is the Zoloris and basically is a very, very, very, very small, small and slow animal. By definition, it moves very slow.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
You can check the slides for James' talk here.
ESM Loaders: Enhancing Module Loading in Node.js
JSNation 2023JSNation 2023
22 min
ESM Loaders: Enhancing Module Loading in Node.js
Native ESM support for Node.js was a chance for the Node.js project to release official support for enhancing the module loading experience, to enable use cases such as on the fly transpilation, module stubbing, support for loading modules from HTTP, and monitoring.
While CommonJS has support for all this, it was never officially supported and was done by hacking into the Node.js runtime code. ESM has fixed all this. We will look at the architecture of ESM loading in Node.js, and discuss the loader API that supports enhancing it. We will also look into advanced features such as loader chaining and off thread execution.
Out of the Box Node.js Diagnostics
Node Congress 2022Node Congress 2022
34 min
Out of the Box Node.js Diagnostics
In the early years of Node.js, diagnostics and debugging were considerable pain points. Modern versions of Node have improved considerably in these areas. Features like async stack traces, heap snapshots, and CPU profiling no longer require third party modules or modifications to application source code. This talk explores the various diagnostic features that have recently been built into Node.
You can check the slides for Colin's talk here. 
The State of Passwordless Auth on the Web
JSNation 2023JSNation 2023
30 min
The State of Passwordless Auth on the Web
Can we get rid of passwords yet? They make for a poor user experience and users are notoriously bad with them. The advent of WebAuthn has brought a passwordless world closer, but where do we really stand?
In this talk we'll explore the current user experience of WebAuthn and the requirements a user has to fulfill for them to authenticate without a password. We'll also explore the fallbacks and safeguards we can use to make the password experience better and more secure. By the end of the session you'll have a vision for how authentication could look in the future and a blueprint for how to build the best auth experience today.
Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Can Deno run apps and libraries authored for Node.js? What are the tradeoffs? How does it work? What’s next?

Workshops on related topic

Node.js Masterclass
Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Matteo Collina
Matteo Collina
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
0 to Auth in an hour with ReactJS
React Summit 2023React Summit 2023
56 min
0 to Auth in an hour with ReactJS
WorkshopFree
Kevin Gao
Kevin Gao
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool. There are multiple alternatives that are much better than passwords to identify and authenticate your users - including SSO, SAML, OAuth, Magic Links, One-Time Passwords, and Authenticator Apps.
While addressing security aspects and avoiding common pitfalls, we will enhance a full-stack JS application (Node.js backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session securely for subsequent client requests, validating / refreshing sessions- Basic Authorization - extracting and validating claims from the session token JWT and handling authorization in backend flows
At the end of the workshop, we will also touch other approaches of authentication implementation with Descope - using frontend or backend SDKs.
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
0 to Auth in an Hour Using NodeJS SDK
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
GraphQL - From Zero to Hero in 3 hours
React Summit 2022React Summit 2022
164 min
GraphQL - From Zero to Hero in 3 hours
Workshop
Pawel Sawicki
Pawel Sawicki
How to build a fullstack GraphQL application (Postgres + NestJs + React) in the shortest time possible.
All beginnings are hard. Even harder than choosing the technology is often developing a suitable architecture. Especially when it comes to GraphQL.
In this workshop, you will get a variety of best practices that you would normally have to work through over a number of projects - all in just three hours.
If you've always wanted to participate in a hackathon to get something up and running in the shortest amount of time - then take an active part in this workshop, and participate in the thought processes of the trainer.