Security is of prime concern while deploying an app. Thanks to the awesome nodejs community, there are lot of security middlewares one can use to mitigate common security risks.
Some vulnerabilities are:
- SQL injection
- XSS
- Clickjacking
- Man in the middle attack
This is not an exhaustive list, but the list of most common ones.
SQL Injection
You have to worry about this attack only if you are using sql databases as your database. If you use MongoDB you should check MongoDB Injection instead. Following code is vulnerable to injections.
Consider the input where username=admin'--&password=dummy
The sql query build to SELECT * FROM users WHERE username = 'admin'--'AND password = 'dummy'
You see, --
is comment syntax in sql. How simple was it to get access. hmm!
The solution:
- Escape user inputs.
- Use parameterised sql queries.
This is first one in the node js security series. I will update this with link to other posts as I complete other ones.