<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Federico Iarlori</title>
    <description>The latest articles on DEV Community by Federico Iarlori (@fedeiar).</description>
    <link>https://dev.to/fedeiar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F987435%2Fa3c69688-2470-4db9-9933-45c2903155a1.png</url>
      <title>DEV Community: Federico Iarlori</title>
      <link>https://dev.to/fedeiar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fedeiar"/>
    <language>en</language>
    <item>
      <title>Protect an API from SQL Injection attacks in Node.js with PostgreSQL</title>
      <dc:creator>Federico Iarlori</dc:creator>
      <pubDate>Fri, 09 Dec 2022 15:28:04 +0000</pubDate>
      <link>https://dev.to/fedeiar/protect-an-api-from-sql-injection-attacks-in-nodejs-with-postgresql-1j8e</link>
      <guid>https://dev.to/fedeiar/protect-an-api-from-sql-injection-attacks-in-nodejs-with-postgresql-1j8e</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;
Initial Setup

&lt;ul&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;SQL Injection attack&lt;/li&gt;
&lt;li&gt;Preventing SQL Injection attack&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;SQL injection is a code injection technique where an attacker targets SQL-like databases by entering malicious SQL code into input fields in the web app to gain access, modify or delete the data in the database. It's one of the most common attacks in web applications.&lt;/p&gt;

&lt;p&gt;In this post I will show you how to prevent this type of attacks when using Node.js and a SQL-like database to implement the API for a web application. The SQL database chosen for demonstrating the example is PostgreSQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial Setup
&lt;/h2&gt;

&lt;p&gt;First of all, I will show how to do the initial setup in order to have a working API without entering into great detail. We will need to have PosgreSQL and Node.js installed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; since my operating system is in Spanish, some of the screenshots used in this post will be in Spanish too.&lt;/p&gt;

&lt;h3&gt;
  
  
  PostgreSQL
&lt;/h3&gt;

&lt;p&gt;PostgreSQL can be downloaded following the steps in this &lt;a href="https://www.postgresql.org/download/"&gt;link&lt;/a&gt;, chosing the operative system of your preference, in my case I'll be using Windows. When installing PostgreSQL, simply follow the steps provided in the installation guide. In my case, I chose the password "admin" and the default port "5432". Remember this information because it will be necessary when developing the API.&lt;/p&gt;

&lt;p&gt;After installation, in case of using Windows make sure that the path of the "bin" folder of PostgreSQL is placed in the enviroment variables.&lt;/p&gt;

&lt;p&gt;Once installed, open a command prompt, and execute the command &lt;code&gt;psql -U postgres&lt;/code&gt; in order to log into PostgreSQL with the default user "postgres". Then you will be prompted with a password. Use the password chosen in the installation process, in my case it is "admin". If everything is OK, you should be seeing the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KdvYxqoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lv7d33do1dz09j16tq8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KdvYxqoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lv7d33do1dz09j16tq8j.png" alt="Image description" width="880" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once logged in, we need to create a database for the API to use. This can be done by using the command &lt;code&gt;CREATE DATABASE api_example&lt;/code&gt;. Then we connect to this database with &lt;code&gt;\c api_example&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;With the command &lt;code&gt;\conninfo&lt;/code&gt; we can see all the relevant information we will need when connecting the Node.js app with the recently created database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9-FPNXK2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12s9qodmsh7mtpzhihuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9-FPNXK2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12s9qodmsh7mtpzhihuh.png" alt="Image description" width="880" height="59"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Node.js
&lt;/h3&gt;

&lt;p&gt;Node.js can be downloaded in the following &lt;a href="https://nodejs.org/es/"&gt;link&lt;/a&gt;. Once installed, we create a new folder and a new project by opening a command prompt inside the folder and executing the command &lt;code&gt;npm init&lt;/code&gt;. Then we install the following libraries that we will need when developing the API with the command &lt;code&gt;npm install&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;npm install express&lt;/code&gt; to ease us the process for developing the endpoints of the API&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm install nodemon&lt;/code&gt; so we don't need to restart the app every time we make changes in the code&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm install dotenv&lt;/code&gt; so we can use enviroment variables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm install pg&lt;/code&gt; so we can connect to the PostgreSQL database&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;npm install pg-escape&lt;/code&gt; to prevent SQL Injection attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After installing the libraries, we create a file called "index.js" with the following initial code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
require('dotenv').config()
const app = express();

app.get('/', (request, response) =&amp;gt; {
    response.send("Welcome to the API!");
});

const PORT = process.env.PORT || 5000
app.listen(PORT, () =&amp;gt; console.log('Listening on port '+PORT+'...'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we open the "package.json" file, and in the "scripts" field we add the following field: &lt;code&gt;"start": "nodemon src/index.js"&lt;/code&gt;. After adding it, the file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "api_sql-injection",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon src/index.js",
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "nodemon": "^2.0.20",
    "pg": "^8.8.0",
    "pg-escape": "^0.2.0"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we must set out .env file, initially only specifying the port number. For this purpose, we create a new file named ".env", and we add the following variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we can test our API with &lt;code&gt;npm start&lt;/code&gt;. If everything went OK, we should be seeing the following text in the browser when accessing localhost in the port 3000, i.e &lt;a href="http://127.0.0.1:3000/"&gt;http://127.0.0.1:3000/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b4g5r3Ze--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni2wgrweovfjbl9j2j3z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b4g5r3Ze--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ni2wgrweovfjbl9j2j3z.png" alt="Image description" width="274" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that our API is working, let's add some more endpoints to give a little bit more of functionality, so then we can perform a SQL Injection attack.&lt;/p&gt;

&lt;p&gt;First, we must connect to the api_database database in Node.js. For this purpose, we'll create the file "dbConnection.js" with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const dotenv = require('dotenv');
dotenv.config();

const { Pool } = require('pg');

let pool = new Pool({
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,
    database: process.env.DB_DATABASE,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    ssl: false
});

module.exports = pool;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see, we need to specify some enviroment variables in the .env file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=3000

DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=api_example
DB_USER=postgres
DB_PASSWORD=admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember that you can access all this information using the &lt;code&gt;\conninfo&lt;/code&gt; command in PostgreSQL. The password must be the same as the one that was specified in the installation of PostgreSQL.&lt;/p&gt;

&lt;p&gt;Once configured the database, we will import it in "index.js"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const pool = require("./dbConnection.js");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can make some more interesting endpoints. First, an endpoint to initialize the database with a table named "users" and some user examples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/initialize_database', async (request, response) =&amp;gt; {
    try{
        const query = `CREATE TABLE IF NOT EXISTS users (
                username varchar(45) NOT NULL,
                email varchar(450) NOT NULL,
                PRIMARY KEY (username) 
            )`;
        await pool.query(query);
        await pool.query("DELETE FROM users WHERE username = 'john' ");
        await pool.query("INSERT INTO users(username, email) VALUES ('john', 'john@mail.com')");
        await pool.query("DELETE FROM users WHERE username = 'jack' ");
        await pool.query("INSERT INTO users(username, email) VALUES ('jack', 'jack@mail.com')");
        await pool.query("DELETE FROM users WHERE username = 'peter' ");
        await pool.query("INSERT INTO users(username, email) VALUES ('peter', 'peter@mail.com')");
        response.status(200).json({"message": "table created succesfully."});
    } catch(error){
        response.status(500).json({"message": error.message});
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "DELETE" commands are in case that we are initializing an already initialized database. After accessing this endpoint in the URL &lt;code&gt;http://127.0.0.1:3000/initialize_database&lt;/code&gt;, we will get the following message&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TMSlEd0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6vflmy8gtf46br071gw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TMSlEd0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6vflmy8gtf46br071gw.png" alt="Image description" width="575" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if we go to PostgreSQL and execute the query &lt;code&gt;SELECT * from users;&lt;/code&gt; we will see the following table&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f7oI0AAZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9jg2p8cg40cyl2a36kr4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f7oI0AAZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9jg2p8cg40cyl2a36kr4.png" alt="Image description" width="312" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to this endpoint, we will make another one for recovering one particular user from the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/users/:username', async (request, response) =&amp;gt; {
    let username = request.params.username;
    try{
        const query = `SELECT * FROM users WHERE username='${username}'`;
        console.log(query);
        const result = await pool.query(query);
        response.status(200).json(result.rows);
    } catch(error){
        response.status(500).json({"message": error.message});
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next section we'll see why this last endpoint is insecure and vulnerable to SQL Injection attacks.&lt;/p&gt;

&lt;h2&gt;
  
  
  SQL Injection Attack
&lt;/h2&gt;

&lt;p&gt;As we mentioned before, in an SQL Injection Attack the attacker enters malicious SQL code through the input fields. In the endpoint implemented before, the input comes in the &lt;code&gt;request&lt;/code&gt; variable, when accessing the field &lt;code&gt;username&lt;/code&gt;, and then this input it's used in the query. &lt;/p&gt;

&lt;p&gt;When using the endpoint normally (i.e, without malicious intentions), we would use, for example, the following URL if we are looking for a user named "john".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dqGlQ0cE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg692qpua9vr4c9l5v4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dqGlQ0cE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wg692qpua9vr4c9l5v4t.png" alt="Image description" width="397" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and the SQL query that we are performing in Node.js would look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM users WHERE username='john'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, instead of "john", we could use another input with certain format, to perform other operations than just searching for a user. Consider the following URL:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://127.0.0.1:3000/users/john'; DROP TABLE users; --&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What we are doing here is first searching for john, we close the name we are trying to match with a simple quote ('), then close the query with the ";" operator, and then perform another query. This second query is essentially deleting the whole table! After this, if you remember the original query, we have a simple quote left that isn't closed. In order for PostgreSQL to not throw an error for this single simple quote being left, we use the "--" so that everything that comes after the last ";" is considered a comment and gets ignored. So, the final query would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM users WHERE username='john'; DROP TABLE users; --';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we said, when the second query gets executed, the users table will be erased. Lets see what happens when we try to see the table in postgreSQL&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qjbXsHwE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsq0kk34akegu9ev5c8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qjbXsHwE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsq0kk34akegu9ev5c8z.png" alt="Image description" width="347" height="70"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We lost our table! In a real life application, a vulnerability like this could cause the loss of a lot of valuable information, which translates in the loss of tons of money.&lt;/p&gt;

&lt;p&gt;The problem here is that the input data was not sanitized at all. In the following section, we will see how we can protect our database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preventing SQL Injection Attack
&lt;/h2&gt;

&lt;p&gt;There are many ways to prevent a SQL Injection Attack. In this post, we will see how to do this using the pg-escape library. First of all, let's recover our table accessing the URL &lt;code&gt;http://127.0.0.1:3000/initialize_database&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, consider the following end-point&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/protected_users/:username', async (request, response) =&amp;gt; {
    let username = request.params.username;
    try{
        const query = `SELECT * FROM users WHERE username=${escape.literal(username)}`;
        console.log(query);
        const result = await pool.query(query);
        response.status(200).json(result.rows);
    } catch(error){
        response.status(500).json({"message": error.message});
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, it's very similar to the previous end-point, but with one fundamental difference. When we are using the content of &lt;code&gt;username&lt;/code&gt; in the query, we are escaping the input (a sequence of characters) with &lt;code&gt;escape.literal(username)&lt;/code&gt;. To escape a sequence of characters means that we are translating that sequence into another sequence.&lt;/p&gt;

&lt;p&gt;So what this function from pg-escape is doing is transforming a malicious input into one that can't cause any harm, for example not allowing the execution of two queries in one single http request. Let's consider the previous malicious URL but with our protected route:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://127.0.0.1:3000/protected_users/john'; DROP TABLE users; --&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When accessing that URL, we will get an empty JSON.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mgae5pvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zw5l03mfm6g57ltj8l7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mgae5pvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zw5l03mfm6g57ltj8l7y.png" alt="Image description" width="880" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And when we check our table in PostgreSQL with &lt;code&gt;SELECT * FROM users&lt;/code&gt;, we can see that it is still there!&lt;/p&gt;

&lt;p&gt;If we print the query that we just made in the end-point with &lt;code&gt;console.log()&lt;/code&gt;, we can see that the following command was executed&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM users WHERE username='john''; DROP TABLE users; --'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you pay attention, you can see that there is an extra single quote in the query after "john". In SQL, this means that we want to include the character " ' " (single quote) in the username we want to match. So instead of executing two SQL commands like before, what we are doing now is executing only one query that tries to search for a user with the name &lt;code&gt;john'; DROP TABLE users; --&lt;/code&gt;. Since there is no user with that name in the table users, the end-point returns and empty JSON.&lt;/p&gt;

&lt;p&gt;In this way, we could easily sanitize the input using pg-escape by simply applying the function &lt;code&gt;literal&lt;/code&gt; to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;SQL Injection is one of the many attacks that a malicious user can perform to a web application. What is dangerous about this type of attack is that it is easily exploitable and can cause a lot of damage to the system.&lt;/p&gt;

&lt;p&gt;In this post we saw an easy way to protect against this types of attacks when using a SQL like database in Node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/fedeiar/api_sql-injection"&gt;Source code in Github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
