The Security Toolbox For Node

Rate this content
Bookmark

Do you have a way to quickly check all of your repos for any vulnerabilities to various attacks? Do you know which attacks you should be preparing your applications for? In this talk, we will cover the top 10 attacks on Node applications and how to handle all of them. Multiple tools will be covered, all of which have been used in production across different back-end architectures.

A few of the areas that will be covered include securing dependencies, securing data, and securing your server. By the end of this talk, attendees should have a full security toolbox and they will know how to implement it quickly. This will help with production applications because you will still get through your sprints on time and you will be able to rest knowing you have security measures in place.

Milecia McGregor
Milecia McGregor
29 min
24 Jun, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Talk focuses on Node application security, covering topics such as OWASP top 10 vulnerabilities, handling packages, managing data, and protecting servers. Best practices include password security, input validation, and data encryption. The importance of securing access to packages and managing data is emphasized. Encrypting data for secure communication is discussed, along with protecting servers using HTTPS and rate limiting. The challenges of security implementation and resources for learning are mentioned, as well as the use of attacker tools. Docker security and preventing IP attacks are also touched upon.

1. Introduction to Node Application Security

Short description:

My name is Milesha McGregor, a developer advocate at Conducto, and today I'm going to talk about a security toolbox for node applications. We'll cover the OWASP top 10 vulnerabilities, handling packages, managing data, and protecting servers from attacks like cross-site scripting. Validate all inputs, especially numeric fields.

Alright, hey, everybody. My name is Milesha McGregor, and I'm a developer advocate at Conducto. So we make this really cool tool where you can debug your pipelines and do your deploys easier and all that good stuff. So make sure you check me and us out on Twitter. But today, I'm going to talk to you about a security toolbox you can build for all of your node applications. So since we've been virtual for so long, I always like to give an overview. That way, you know where you can kind of, you know, tune in, tune out, fast forward through the video later when you're going back through it.

But to get started, I'm going to jump off with just the OWASP top 10 vulnerabilities. We'll cover pretty much all of them and some of the packages and other tools and strategies you can use to secure your Node apps from these kinds of attacks. And then we'll talk about how you can handle your packages because as every JavaScript engineer knows, we use a package for just about everything. So you want to make sure that you're taking care of those. And we'll also talk a bit about managing your data. So we all know on the back end that we don't want other people or people that shouldn't have access to the data to actually be able to access the data. So we're going to talk about some different strategies that we can use to just make sure that, you know, nobody that got fired three months ago is going to come back and drop all the databases. And we'll talk some more about protecting your server from different attacks, like the ones that just shut down your server. I know the word for this, but I'm going to remember it much later than I should. And then we'll wrap up with just a few key takeaways and some things I hope you can just go back to work and implement as soon as you can.

So to get started, we're going to just jump into the OWASP top 10 vulnerabilities. So there's this node goat app that is just in existence and it'll walk you through all 10 of the vulnerabilities using this cool little node application. So if you want to see some live examples that have been developed by just some of the top security people in the world, go ahead and check out this node goat app. But one thing that you want to keep in mind with this OWASP top 10, these 10 vulnerabilities are present on, I believe it was 85% of all web apps online right now. So almost the whole internet is just vulnerable to some kind of attack. And that is the reason why I want to give you just some tools and stuff you can use to make sure you don't have one of those apps or that when you do encounter one you can clean it up and just make sure that it becomes less attack-friendly. So the first thing we're going to talk about is cross-site scripting. This is basically when somebody injects JavaScript into your app, and it makes the app redirect users to some other place, it steals cookies so that they can authenticate themselves as other users, or basically anywhere there is some kind of input field that they can type text into, they're able to execute some kind of JavaScript statement. So we want to make sure that some random person on the Internet isn't injecting or cross-site scripting something really crazy into our app, so we're going to prevent that. And to do that, start by validating all of your inputs. I know we already do that because form validation is everybody's favorite thing. But I just want to make sure that we're really all doing it. So validate those inputs, make sure any numeric fields are actually receiving numbers.

2. Best Practices for Node Application Security

Short description:

Make sure passwords have their certain security requirements, validate user inputs, and encrypt all data sent to users. Prevent denial of service attacks by implementing checks to prevent looping and data creation. Validate all inputs, both on the front-end and back-end, to prevent server-side injection attacks.

Make sure passwords have their certain security requirements, whether that's lowercase and capital letters, numbers, special characters, whatever you want it to be. But have some validation around these inputs to where a user cannot submit a form if it's not in the right format.

And then something else you can do to just help with that whole session hijacking thing with the cross-site scripting, encode all of the data that you send to your users. So we know that we need to encode data that they send to us, just so people on the Wi-Fi in the airport or Windows were a thing. But when you're on an open network, you know that you always encrypt data going to the server so that prying eyes don't get access to it. Make sure you're doing the same thing when you're sending data. So go ahead and encrypt everything.

Now we'll talk about the denial of service attacks. So this is that thing that I could not say in the intro for some reason. But a denial of service attack is pretty much when some malicious party gets access to your server and they send so many requests that it brings down the server for all of your actual users. This means that someone is sending enough requests that they are using up all of your cloud resources or all of your on-prem resources to the point where your app is basically unavailable. So you don't want the denial of service attacks to happen, especially when your app is something very critical to your users. So to prevent those, we really want to put checks in place to prevent looping and data creation. You don't want somebody to be able to submit a query to your back-end that infinitely adds fake users to your database. That's one of the ways that a denial of service attack can bring your entire application down. And again, validate all of those inputs. There's forums on pretty much every site nowadays, whether it's just getting your email or somehow convincing you to sign in with Google. Validate those inputs. They're around, so make sure you're doing that on the front-end and the back-end.

Now let's talk a little bit about the server-side injection attack. This is when an outside party can inject data as part of just a simple query. This happens when you're able to submit bad queries in forums. So basically, what's happening is somebody's typing in a SQL query where they should be typing in a new username. And now you have your database dropped and nobody knows why. Just because someone was able to actually submit this request to the backend and there weren't any type of checks in place to prevent that from happening. So to prevent that, one thing that you'll want to do is parse any user input. You know what kind of data you're expecting from the front end. You know what values should be stored in the database. You have a whole schema for this. So when you're getting this user input, just go ahead and parse it down into what actually needs to be present.

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.