When anything becomes popular in technology, they are exposed to millions of professionals, including security experts, attackers, hackers, etc. A node.js core is secure, but when you install third-party packages, the way you configure, install and deploy may require additional security to protect web applications from hackers. To get an idea, 83% of Snyk users found one or more vulnerabilities in their applications. Snyk is one of the popular node.js security scanning platforms. And another latest research shows ~14% of the whole npm ecosystem was affected. In my previous article, I mentioned finding security vulnerabilities in a Node.js application, and many of you asked about remediating/securing them. So here you go…

Snyk

Snyk can be integrated into GitHub, Jenkins, Circle CI, Tarvis, Code Ship, Bamboo to find and fixes the known vulnerabilities. You can understand your application dependencies and monitor real-time alerts when risk is found in your code. On a high-level, Snyk provides complete security protection, including the following.

Finding vulnerabilities in the codeMonitor code in real-timeFix the vulnerable dependenciesGet notified when a new weakness impacts your application.Collaborate with your team members

Snyk maintains its own vulnerabilities database, and currently, it supports Node.js, Ruby, Scala, Python, PHP, .NET, Go, etc.

Jscrambler

Jscrambler takes an interesting, unique approach to providing code & web page integrity on the client-side. Jscrambler makes your web application self-defensive to fight fraud, avoid code modification in run-time, data leakage, and protect from reputational loss and business. Another exciting feature is application logic, and data is transformed so that it’s hard to understand and hidden on the client side. This makes it difficult to guess the algorithm, technologies used in the application. Some of the Jscrambler featured include the following.

Real-time detection, notification & protectionProtection from code injection, DOM-tampering, man-in-the-browser, bots, zero-day attacksCredential, credit card, private data loss preventionMalware injection prevention

Jscrambler supports most JavaScript frameworks such as Angular, Ionic, Meteor, Vue.js, React, Express, Socket, React, Koa, etc. So go ahead and give a try to make your JavaScript application bullet-proof.

Cloudflare WAF

Cloudflare WAF (Web Application Firewall) protects your web applications from the cloud (network edge). You don’t have to install anything in your node application. There are three types of WAF rules you get.

OWASP – to protect an application from OWASP top 10 vulnerabilitiesCustom rules – you can define the rule.Cloudflare specials – Rules defined by Cloudflare based on application.

By utilizing Cloudflare, you don’t add security to your site and take advantage of their fast CDN for better content delivery. Cloudflare WAF is available in the Pro plan, which costs $20 per month. Another cloud-based security provider option would be SUCURI and StackPath, a complete site security solution to protect from DDoS, malware, known vulnerabilities, etc.

Helmet

Helmet is a middleware for express and Koa to provide OWASP best practices secure header. It let you implement HTTP response headers such as HSTS, CSP, Referrer-Policy, Expect CT, etc.

Sqreen

Get it started in less than 5 minutes; Sqreen is deployed within your code to protect your application and users from intrusions, and attacker. Sqreen is a lightweight agent built for performance to provide complete security, including the following.

SQL/No-SQL/Code/Command injectionsOwasp Top 10Cross-site scripting attacksZero-day attacks

Not just Node.js, but it supports Python, Ruby, PHP, Java, Go as well. Sqreen uses collective intelligence to detect an early attack by taking advantage of data coming from other applications.

N|Solid

N|Solid is a drop-in replacement platform to run a mission-critical Node.js application. It got inbuilt real-time vulnerability scanning and custom security policies for enhanced application security. You can configure it to get alerted when a new security vulnerability is detected in your Nodejs applications.

Rate Limit Flexible

Use this tiny package to limit the rate and trigger a function on the event. This will be handy to protect from DDoS and brute force attacks. Some of the use cases would be as below.

Login endpoint protectionCrawler/bot rate limitingIn-memory block strategyDynamic block based on the user’s actionRate limiting by IPBlock too many login attempts

Wondering if this will slow the application? No, you won’t even notice that. It’s fast; the average request adds 0.7ms in the cluster environment.

CSURF

Add CSRF protection by implementing csurf. It requires a session middleware or cookie parser to be initialized first.

Conclusion

I hope the above list of security protection helps you to secure your NodeJS application. Next, don’t forget to check out the monitoring solution.

8 Tools to Secure NodeJS Applications from Online Threats - 168 Tools to Secure NodeJS Applications from Online Threats - 888 Tools to Secure NodeJS Applications from Online Threats - 568 Tools to Secure NodeJS Applications from Online Threats - 718 Tools to Secure NodeJS Applications from Online Threats - 958 Tools to Secure NodeJS Applications from Online Threats - 138 Tools to Secure NodeJS Applications from Online Threats - 108 Tools to Secure NodeJS Applications from Online Threats - 158 Tools to Secure NodeJS Applications from Online Threats - 6