Node.js Secure Coding – Disabling Authentication

This is a snippet of a function that performs user authentication (login).

What’s wrong here?


module.exports.authenticate = function(req, res, next) {
if (env !== 'production') {
return next();
}
...

Give up?
You want to default to a more secure posture, not less. If you need to disable authentication, you must, Must, MUST be explicit as to when, and you must, Must, MUST default to more secure. The above should look something like:


module.exports.authenticate = function(req, res, next) {
if (env === 'development' || env === 'testing' ) {
return next();
}
...

This problem is not restricted to node, obviously. It’s a basic premise of secure coding.

Advertisements

About jeffmershon

Director of Program Management at SiriusXM.
This entry was posted in Software and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s