Express JS Important NPM Packages Related to Security

Naveen DA
HackerNoon.com
5 min readJan 6, 2019

--

Few words before we start

When you create a website or application, it means you are ready to show it thousands of people on the internet. Your customer/audience may be legit, but some of them will try to tamper your application. So you need to follow the following golden rules

  1. Never trust your audience when it comes to your application’s security
  2. Always validate the user input before getting it into the server.
  3. Always encode the user inputs before printing them on to the screen.

helmet

The helmet is really like a helmet for your applications. It protects your application by setting up various HTTP headers.

express-session

The express-session middleware stores session data on the server; it only saves the session ID in the cookie itself, not session data.

cookie-session

A simple cookie-based session middleware, that allows storing cookies.It does not require any database/resources on the server side, though the total session data cannot exceed the browser’s max cookie size.

JOI

Object schema description language and validator for JavaScript objects by hapi. It is very useful to validate the user input.

express-rate-limit

You may aware of the brute force attack. express-rate-limit is a middleware for express routes that rate-limits incoming requests, increasing the delay with each request in a Fibonacci-like sequence.

express-jwt-permissions

A middleware that checks JWT tokens for permissions. It is very useful to build a user access control system.

express-mongo-sanitize

Express middleware which sanitizes user-supplied data to prevent MongoDB Operator Injection.

hpp

Express middleware to protect against HTTP Parameter Pollution attacks. To know more read Chetan Karande’s slides

dotenv

Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env.. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

csurf

The csurf is a CSRF protection middleware.

I wish you happy coding.

If you enjoyed this article, please clap it up and share it so that others can find it!

--

--