Avoid Asymmetry in Your Code

Applications are often asymmetric when it comes to client requests. Handling the request is much more resource heavy than making the request. Our Fibonacci example was a good illustration of how it took a long calculation to answer a simple request. Points like these are popular targets for DoS attacks, because by targeting these, attackers can successfully take down a service with limited resources.

You don’t want to be an easy target, so you should protect functions that are asymmetrical by limiting access to those functions. One way is to restrict access to the functions to only authenticated users. This way, you can block users who abuse the functions. Another way is to provide a queue system for guest users, ...

Get Secure Your Node.js Web Application now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.