{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"c61acf9d-7746-503a-ba8f-cf96f4042096","frontmatter":{"category":"Coding","title":"Secure coding practices for NodeJS Web Applications","date":"2018-06-20","summary":"This post highlights various coding practices for securing a NodeJS web application against the most critical web attacks.","thumbnail":{"relativePath":"pages/securing-nodejs-applications/thumbnail.jpeg","childImageSharp":{"resolutions":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAHMkZoCv//EABUQAQEAAAAAAAAAAAAAAAAAAAAS/9oACAEBAAEFApSl/8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8BJ//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAECAQE/AWf/xAAXEAADAQAAAAAAAAAAAAAAAAAAECEx/9oACAEBAAY/AoYv/8QAGhABAAIDAQAAAAAAAAAAAAAAAQARIUFxUf/aAAgBAQABPyHOqLFGlciV85P/2gAMAwEAAgADAAAAEHvP/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAh/9oACAEDAQE/EAJs/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAR/9oACAECAQE/EFjP/8QAHBABAAEEAwAAAAAAAAAAAAAAASEAETFxUWHw/9oACAEBAAE/EMpW8q+4qwMgymddUsU0EV//2Q==","width":867,"height":325,"src":"/static/f21842b8ed2aa0a1b2cd57f6dbf9e7fc/a2998/thumbnail.jpeg","srcSet":"/static/f21842b8ed2aa0a1b2cd57f6dbf9e7fc/a2998/thumbnail.jpeg 1x"}}},"authorName":"Rajababu Pradhan","authorDescription":"Raja is Senior Frontend Engineer at AUTO1 Group.","authorAvatar":{"relativePath":"pages/securing-nodejs-applications/avatar.png","childImageSharp":{"resolutions":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAACyElEQVQ4y4VUO2gUURR9mZmN8YcItoKVjeXuzsxu9jOzm92NkBBTqDEmjZAEgtqIpSgI1gp+uhS6kEI7wc7GQsFCLERiISGCaGHhF02yu+M5s/cujyC4cJY379573r3n3XdNvV51xsYiJ4rKbqlUyBj8wjAYyWazp4BVYB3YAraBDeAhMBcE/l76lkrFTLVachuNyCGXEbJMrVbx6ADnaWAtn88nvu8nWBMdQcJ9Auv3wCxjWq2aC9IMSF3DzCyyG1YAs9pSYkL2melmLpfT71tKGkUlz2iZJAuCgA5dEjGAwPoV0AbuAy+tfR7YkZjb5CiXR1OutEw5jWQdCfgCnEiSxNg/7LWAj+KTSiHSzBvrAtascrriPCmnDkP4AYQ0Em3TGPHf8P38ARpP/4PsHQ7aU69Hqdi4OJeI47JXLg9IX1tVbUuWCzSsygcJO+L0goGNRpySoB1colarerhEvcCn4tuxCB/TsC5ZdS3Ct2Ho75uZmRoigWbIbgCxt7Q0O8TLsgg17o2R2+JHzzJcV/1IoBlybel42SLsCcc3I6UqoaZ+lUHFYjjCzJSQa+4J4UVLKiX8ScOGVXJXDN+xd7SfZXFYS65U+n2Wz+cOw+ezHadSkfCRdVJiZdlmMG9ZtHMpgWR3Z0eMSvWExjmrbXoCbZ951dIim7Yk6u1IYtlwavChW51Pp01tXOwf01eC9RHs/Rbbnx2Hf4IUh/Q5zdol8H3KG22Pj9edOK54LF1876pd37TELhqdZ+J4MwxDHUvXgDOFQrB7YqLpjI4WdhG8GLYNbCeBK/1+TWNWRG+Pfy5Hj5Dek3IXzX9+8DkL/AIeLC/PDU1NHXdSQk5altNsDkjPAT+ArzKyFnK5bB2IxbYik4hanmfM5GTL6Q/Y2DUc25y0HLToubR8TI39cL4APJOxr/35AXgOXEJnHKQvepP6eiQj119kDrZjqLo8HAAAAABJRU5ErkJggg==","width":50,"height":50,"src":"/static/26a7a327ccc4b335712e5a7086f2b26d/45876/avatar.png","srcSet":"/static/26a7a327ccc4b335712e5a7086f2b26d/45876/avatar.png 1x,\n/static/26a7a327ccc4b335712e5a7086f2b26d/eb85b/avatar.png 1.5x,\n/static/26a7a327ccc4b335712e5a7086f2b26d/4f71c/avatar.png 2x,\n/static/26a7a327ccc4b335712e5a7086f2b26d/9ec3e/avatar.png 3x"}}},"headerImage":{"relativePath":"pages/securing-nodejs-applications/header-image.jpeg","childImageSharp":{"resolutions":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAHMkZoCv//EABUQAQEAAAAAAAAAAAAAAAAAAAAS/9oACAEBAAEFApSl/8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8BJ//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAECAQE/AWf/xAAXEAADAQAAAAAAAAAAAAAAAAAAECEx/9oACAEBAAY/AoYv/8QAGhABAAIDAQAAAAAAAAAAAAAAAQARIUFxUf/aAAgBAQABPyHOqLFGlciV85P/2gAMAwEAAgADAAAAEHvP/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAh/9oACAEDAQE/EAJs/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAR/9oACAECAQE/EFjP/8QAHBABAAEEAwAAAAAAAAAAAAAAASEAETFxUWHw/9oACAEBAAE/EMpW8q+4qwMgymddUsU0EV//2Q==","width":1200,"height":450,"src":"/static/f21842b8ed2aa0a1b2cd57f6dbf9e7fc/935ac/header-image.jpeg","srcSet":"/static/f21842b8ed2aa0a1b2cd57f6dbf9e7fc/935ac/header-image.jpeg 1x"}}}},"html":"<h1>Secure coding practices for NodeJS Web Applications</h1>\n<p>Everyone would agree that security is very important and with the increase in cyber attacks in the recent past, organizations are investing\nheavily on application security. In this post lets talk about securing a web application built in NodeJS.</p>\n<p><strong>NOTE</strong>: The security concepts discussed here are language or framework agnostic. However, here we will see how these practices are implemented\nin NodeJS web applications.</p>\n<h2>1. Use SSL/TLS for communication</h2>\n<p>It is always a good practice to send your data over HTTPS rather than HTTP and it is imperative if your app transmits sensitive data.\nEncrypting data transmitted between the client and server helps mitigate several attacks like <a href=\"https://www.owasp.org/index.php/Man-in-the-middle_attack\">man-in-the-middle(MITM)</a> attack, packet sniffing,\neavesdropping etc. Let’s see how to set up TLS/SSL in Express 4.x:</p>\n<p>Lets first generate a self-signed certificate:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365</code></pre></div>\n<p>This generates a self-signed certificate valid for 365 days.</p>\n<p><strong>NOTE</strong>: The self-signed certificate is not ideal for production. For production, you should get a certificate from a <em>Certificate Authority(CA)</em>.</p>\n<p>Next, enable HTTPS on Express. Additionally, redirect all HTTP traffic to HTTPS:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const fs = require('fs');\nconst https = require('https');\nconst express = require('express');\n\nconst NODE_ENV = process.env.NODE_ENV || 'development';\nconst PORT = process.env.PORT || 3443;\n\nconst app = express();\n\nhttps.createServer({\n  key: fs.readFileSync('/path/to/key.pem'),\n  cert: fs.readFileSync('/path/to/cert.pem')\n}, app).listen(PORT);\n\n// Redirect http requests to use https in production\nif (NODE_ENV === 'production') {\n  app.use((req, res, next) => {\n    if (req.header('x-forwarded-proto') !== 'https') {\n      res.redirect(`https://${req.header('host')}${req.url}`);\n    } else {\n      next();\n    }\n  });\n}</code></pre></div>\n<h2>2. Use security headers generously</h2>\n<p><strong>i) Strict-Transport-Security:</strong> <em>The HTTP Strict Transport Security(HSTS)</em> if set in the response header, tells the browser that it should only communicate using HTTPS instead of HTTP while communicating with the specified domain.</p>\n<p><em>Syntax:</em></p>\n<p><code class=\"language-text\">Strict-Transport-Security: max-age=&lt;expire-time></code></p>\n<p>Here, max-age is the time(in secs) that the browser should remember that this site is only to be accessed using HTTPS.</p>\n<p><em>Example: from facebook.com:</em></p>\n<p><code class=\"language-text\">strict-transport-security:max-age=15552000;</code></p>\n<p><strong>ii) X-Frame-Options:</strong> This HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <code class=\"language-text\">&lt;frame></code>, <code class=\"language-text\">&lt;iframe></code> or <code class=\"language-text\">&lt;object></code>. Sites can use this to avoid <a href=\"https://www.owasp.org/index.php/Clickjacking\">clickjacking</a> attacks, by ensuring that their content is not embedded into other sites.</p>\n<p><em>Syntax:</em></p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">X-Frame-Options: DENY\nX-Frame-Options: SAMEORIGIN\nX-Frame-Options: ALLOW-FROM https://siteutrust.com/</code></pre></div>\n<p><strong>iii) X-XSS-Protection:</strong> This HTTP response header enables the built-in XSS filter in modern browsers.</p>\n<p><em>Example:</em></p>\n<p><code class=\"language-text\">X-XSS-Protection: 1</code></p>\n<p><strong>iv) X-Content-Type-Options:</strong> This response HTTP header is a marker used by the server to indicate that the MIME types advertised in the Content-Type headers should not be changed and be followed. This prevents MIME type sniffing attacks.</p>\n<p><em>Syntax:</em></p>\n<p><code class=\"language-text\">X-Content-Type-Options: nosniff</code></p>\n<p><strong>v) Content-Security-Policy:</strong> Prevents a range of injection attacks including Cross Site Scripting(XSS) attack.</p>\n<p><em>Syntax:</em></p>\n<p><code class=\"language-text\">Content-Security-Policy: policy</code></p>\n<p>For a detailed explanation of CSP, go through this <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP\">link</a>.</p>\n<p>To set these headers in NodeJS, use the <a href=\"https://helmetjs.github.io/\">helmet</a> npm package:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const express = require('express');\nconst helmet = require('helmet');\n\nconst app = express();\n\n&lt;b>app.use(helmet())&lt;/b></code></pre></div>\n<p>This sets all the necessary headers in response.</p>\n<p>To set the headers individually:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">app.use(helmet({\n  frameguard: {\n    action: 'deny'\n  }\n}));</code></pre></div>\n<p>For an exhaustive list of security headers that should be set in a web application, check out the <a href=\"https://www.owasp.org/index.php/OWASP_Secure_Headers_Project\">OWASP Secure Headers Project</a>.</p>\n<p><strong>NOTE:</strong> In some web servers, the security headers can be set in the server configuration file itself. For example, in nginx server, we can set the above headers in <em>nginx.conf</em> as shown below:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">add_header X-Frame-Options DENY;\nadd_header X-Content-Type-Options nosniff;\nadd_header X-XSS-Protection 1;\nadd_header Content-Security-Policy \"default-src 'self'\";</code></pre></div>\n<h2>3. Preventing CSRF attacks</h2>\n<p><a href=\"https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29\">Cross site request forgery (CSRF)</a>, also known as <em>XSRF</em>, <em>Sea Surf</em> or <em>Session Riding</em>, is an attack vector that tricks a web browser into executing an unwanted action in an application to which a user is logged in. CSRF attacks specially targets state-changing requests and can force the victim to transfer funds, change email/password and so on.</p>\n<p>CSRFs are typically conducted using social engineering, such as an email or link that tricks the victim into sending a request to a server on behalf of the attacker. The server has no way to distinguish a forged request from a genuine one.</p>\n<p>In NodeJS, to prevent CSRF attack, we usually use the <a href=\"https://github.com/expressjs/csurf\">csurf</a> express middleware:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const cookieParser = require('cookie-parser');\nconst csrf = require('csurf');\nconst bodyParser = require('body-parser');\nconst express = require('express');\n\nconst csrfProtection = csrf({ cookie: true });\nconst parseForm = bodyParser.urlencoded({ extended: false });\n\n// create express app\nconst app = express();\n\n// we need this because \"cookie\" is true in csrfProtection\napp.use(cookieParser());\n\napp.get('/form', csrfProtection, (req, res) => {\n  // pass the csrfToken to the view\n  res.render('send', { csrfToken: req.csrfToken() });\n});</code></pre></div>\n<p>In the view use the CSRF token passed:</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>form</span> <span class=\"token attr-name\">action</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>/process<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">method</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>POST<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>input</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>hidden<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>csrf_token<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">value</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>{{csrfToken}}<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\n\n  Enter amount: <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>input</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>number<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>amount<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>button</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>submit<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Submit<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>button</span><span class=\"token punctuation\">></span></span>\n\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>form</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<h2>4. Preventing XSS attacks</h2>\n<p>Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted web sites.\nAn attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not\nbe trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. These scripts can even rewrite the content of the HTML page.</p>\n<p>The thumb rule to prevent this category of attack is to always validate and sanitize user data before processing or storing in database. Never trust data coming from user.\nValidation must be done on the server-side as client-side validation can be easily bypassed using tools such as Burp Suite, TamperData etc.</p>\n<p>A common approach to validate and sanitize user data is to use a library like <a href=\"https://github.com/chriso/validator.js\">validator.js</a>.</p>\n<p>Example: To validate an email</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">import validator from 'validator';\n\nif(validator.isEmail('foo@bar.com')) {\n  // Process email or store in DB\n}</code></pre></div>\n<p>This library provides a number of validators and sanitizers to filter user inputs.</p>\n<p>Other useful libraries include <a href=\"https://github.com/cure53/DOMPurify\">DOMPurify</a> and <a href=\"https://github.com/yahoo/xss-filters\">xss-filters</a>.</p>\n<p>Here is an example to sanitize user input using xss-filters:</p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\">const express = require('express');\nconst app = express();\nconst xssFilters = require('xss-filters');\n\napp.get('/', (req, res) => {\n  let firstname = req.query.firstname; //an untrusted input\n  res.send('<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h1</span><span class=\"token punctuation\">></span></span> Hello, ' + xssFilters.inHTMLData(firstname) + '!<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h1</span><span class=\"token punctuation\">></span></span>');\n});\n\napp.listen(3000);</code></pre></div>\n<h2>5. Preventing SQL Injection(SQLi) attacks</h2>\n<p>Passing unvalidated user input directly to a SQL statement is vulnerable to <a href=\"https://www.owasp.org/index.php/SQL_Injection\">SQL injection</a> attack.</p>\n<p>Conside the following example:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">// SQL query vulnerable to SQLi\nsql = \"SELECT * FROM users WHERE username='\" + username + \"' AND password='\" + password + \"'\";\n\n// Execute the SQL statement\ndatabase.execute(sql)</code></pre></div>\n<p>Now suppose the user enters the following in the username field:</p>\n<p><code class=\"language-text\">' OR '1'='1' --</code></p>\n<p>The above SQL statement becomes:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">sql = \"SELECT * FROM users WHERE username='\" + ' OR 1=1 -- + \"' AND password='\" + password + \"'\";</code></pre></div>\n<p>This effectively nullifies the need of a password and returns all the users in the database.</p>\n<p>This attack can be completely prevented by using parametrized or prepared statement.</p>\n<p>If you’re using an ORM to access the database (Mongoose, Sequelize etc), the ORM will normally take care of SQL injection by using prepared statements under the hood.</p>\n<h2>6. Secure cookies using cookie flags</h2>\n<p>XSS vulnerability in an application can be used to steal browser cookies. To prevent cookie stealing we can set the <strong>httpOnly</strong> flag of the cookie.\nAdditionaly, we can tell the browser to send cookies only over HTTPS using the <strong>secure</strong> flag.</p>\n<p><strong>secure :</strong> this attribute tells the browser to only send the cookie if the request is being sent over HTTPS.</p>\n<p><strong>HttpOnly :</strong> this attribute is used to help prevent attacks such as cross-site scripting, since it does not allow the cookie to be accessed via JavaScript.</p>\n<p>Example:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">app.use(session({\n  secret: ‘My super secret’,\n  &lt;b>cookie: { httpOnly: true, secure: true }&lt;/b>\n}));</code></pre></div>\n<h2>7. Preventing brute force and DoS attack</h2>\n<p>To prevent our site from overwhelming with a large number of requests, we need to put some kind of rate limiting to our API.</p>\n<p>We can use the <a href=\"https://github.com/tj/node-ratelimiter\">ratelimiter</a> npm package to implement rate limiting. If you are using Express, the <a href=\"https://github.com/nfriedly/express-rate-limit\">express-rate-limit</a> middleware can be used as shown below:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">const RateLimit = require('express-rate-limit');\n\nconst limiter = new RateLimit({\n  windowMs: 15*60*1000, // 15 minutes\n  max: 100, // limit each IP to 100 requests per windowMs\n  delayMs: 0 // disable delaying — full speed until the max limit is reached\n});\n\n// apply to all requests\napp.use(limiter);</code></pre></div>\n<h2>8. Error Handling</h2>\n<p>Any error in the application should be handled gracefully by showing a custom error page to the user instead of showing stack trace in the error page\nthereby leaking sensitive infrastructure information like server info.</p>\n<h2>9. Tools of the trade</h2>\n<p><strong>i) <a href=\"https://github.com/nodesecurity/nsp\">The Node Security Project</a></strong>\nTo check the various npm modules for known vulnerabilities, the Node Security Project provides the nsp tool to check for vulnerabilities:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">$ nsp check</code></pre></div>\n<p><strong>ii) <a href=\"https://snyk.io/\">Synk</a></strong>\nSynk checks the application against Snyk’s open source vulnerability database for any known vulnerabilities in our dependencies.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">$ npm install -g snyk\n$ cd your-app\n$ snyk test</code></pre></div>\n<p><strong>iii) <a href=\"https://nmap.org/\">nmap</a></strong>\nNmap (“Network Mapper”) is a free and open source utility for network exploration or security auditing.</p>\n<p><strong>iv) <a href=\"http://sqlmap.org/\">sqlmap</a></strong>\nsqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers.</p>\n<p><strong>v) <a href=\"https://portswigger.net/burp\">Burp Suite</a></strong>\nThe must-have tool for application penetration testing. It includes an automated scanner to detect most common vulnerabilities in a web application.</p>\n<h3>Further Readings</h3>\n<p><a href=\"https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project\">OWASP Top 10 Most Critical Web Application Security Risks</a></p>\n<p><a href=\"https://blog.risingstack.com/node-js-security-checklist/\">NodeJS Security Checklist</a></p>","fields":{"slug":"/securing-nodejs-applications/","tags":["nodejs","javascript","security","appsec","infosec"]}}}]}},"pageContext":{"slug":"/tags/infosec","tag":"infosec","categories":["Architecture","Coding","DevOps","Engineering","ProjectManagement","QA","Social","TechRadar"]}}