Web Security: Unleashing the Superhero techniques

Aatif Bandey
Engineering at Bajaj Health
4 min readSep 20, 2023

--

In the contemporary business landscape, virtually every enterprise maintains an online footprint in the form of a website. This website serves as a fundamental aspect of a company’s brand identity. Leveraging your website as an e-commerce platform has the potential to significantly augment your revenue. However, for your online business to flourish seamlessly, it is imperative that your website priorities exceptional user experience, optimal performance, and robust security measures

I’ve already delved into the strategies for achieving exceptionally fast performance and an outstanding user experience in a previous case study. However, in this article, our focus will shift towards exploring the best practices that should be observed when addressing web security concerns.

When the subject of web security arises, one often encounters a well-known term that’s frequently discussed: the implementation of a Web Application Firewall (WAF).
Have you integrated a WAF into your security measures?

Web Application Firewall

Well, to clarify, the web isn’t literally ablaze 🔥. Instead, a Web Application Firewall (WAF) can be likened to a protective barrier atop your website. Think of it as a vigilant gatekeeper that carefully watches, intercepts, and filters your incoming traffic based on predefined rulesets

Rulesets

WAF provides you with the ability to manage traffic according to the specific ruleset you establish. These rulesets can encompass a wide array of filters, including:

IP Reputation & Country

Occasionally, your website might experience unwanted traffic or even attacks from specific IP addresses. With Web Application Firewall (WAF) rules in place, you have the capability to block these IPs or groups of IPs that are targeting your website.

Furthermore, you can implement country-level request blocking if needed. If you are utilising AWS WAF, the process of adding such rules is straightforward, as demonstrated below:

Path Rulesets

You can certainly use Web Application Firewall (WAF) rules to block incoming requests with specific paths that match certain strings or patterns. This feature is valuable for preventing unwanted or potentially harmful traffic from reaching your website. Here’s how you might go about setting this up:

Example: If you want to block requests to a specific path like "/admin" or any path containing certain keywords like "malicious," you can create a rule with appropriate conditions and actions.

Rate Limiter

Rate limiting stands out as one of the most frequently employed firewall strategies. This rule empowers you to restrict the volume of requests that reach your server within a given timeframe. For instance, you can employ a Rate Limiter rule to hinder the number of requests per minute or second originating from a specific source. When a requester exceeds the defined limits, the rate limiter can respond by delaying, throttling, or blocking further requests, thus preventing misuse or overuse of resources.

Bot Mitigation

AWS Managed Rule Sets for Bot Control provide predefined rules and bot detection capabilities that are continuously updated to combat evolving bot threats.

WAF provides reports and metrics to help you identify patterns of bot activity and adjust your rules accordingly. Bot detection typically incorporates rules such as rate limiting, IP reputation, and user agent analysis

We’ve discussed some rules earlier, so now let’s delve into User Agent Analysis. This rule allows us to inspect the user agent string found in HTTP headers, which can help us identify bots that might be using recognised bot user agents.

These foundational practices are crucial for fortifying your website against threats, allowing you to confidently declare that you have a firm grip on your website’s security

Never Underestimate the Attacker

What if your attacker possesses advanced tactics, outsmarting your defences and persistently executing DDoS attacks on your website?

The attacker can dynamically cycle through IP addresses for each request and manipulate the geo-location for every request, causing a surge in website traffic that could potentially lead to the site’s disruption.

To address this challenge, you must outsmart the attacker. Employ advanced prevention techniques to thwart their efforts.

But, what could be done?

One effective technique at our disposal is caching, which we can implement through Nginx. We have the flexibility to configure caching based on our specific needs. By introducing caching, any attempts by the attacker to launch a DDoS attack will result in them receiving a cached version. This not only decreases the volume of requests directed at the server but also safeguards against your CPU usage spiking to 100%.

Moreover, there are advanced solutions like Cloudflare that simplify the process significantly. If your website frequently encounters threats, I highly recommend considering Cloudflare as a valuable addition to your security arsenal.

Cloudflare features a robust “Under Attack” mode, which meticulously scrutinises each incoming request to your web server and responds accordingly. Setting up Cloudflare is quite akin to AWS, allowing you to implement tools such as rate limiters and IP blocking for enhanced security.

That’s a wrap, everyone.

I trust you found this article engaging and gained fresh insights. If you found it valuable, please show your appreciation with a round of applause. Thank you for reading.

--

--