How to Protect Your Website From Bot Attacks

Bhanu Reddy
5 min readFeb 25, 2024

Introduction :

In today’s digital age, where the heartbeat of businesses resonates online, the threat landscape has evolved to include sophisticated and automated adversaries. Among these, bot attacks stand out as a formidable challenge, capable of wreaking havoc on companies of all sizes and industries.

As businesses increasingly rely on web applications, APIs, and online services, the risk of falling victim to malicious bots has become a pressing concern. Whether it’s the insidious spread of misinformation, therobot.txt relentless onslaught of spam, or the orchestrated attempts to compromise sensitive data, bot attacks pose a real and pervasive threat.

🌐💻🛡️Let’s make our website a no-go zone for malicious bots! 🌐💻🛡️

What are Bots?

Bots, short for robots, are software applications that perform automated online tasks. They can be programmed to perform various functions, ranging from simple and repetitive tasks to more complex actions. Bots can be beneficial or malicious, depending on their intended purpose.

Good Bots: Good bots are designed to perform helpful and constructive tasks. They serve a variety of positive purposes across different domains, they are usually defined in robot.txt file. Here are some examples:

  1. Search Engine Crawlers: Search engines like Google, Bing, and others use bots to crawl and index web pages. These bots help in organizing and presenting information to users when they perform online searches.
  2. Chatbots: Chatbots are automated programs that engage in conversation with users, providing information, assistance, or performing specific tasks. They are commonly used in customer support, virtual assistants, and online messaging platforms.
  3. Web Scraping Bots for Data Collection: Some bots are designed for web scraping, collecting data from websites for legitimate purposes such as market research, price comparison, or aggregating information.
  4. Monitoring Bots: Bots can monitor websites for changes, updates, or availability. This is beneficial for tracking competitive intelligence or ensuring the uptime of web services.
  5. Social Media Bots for Engagement: Social media platforms use bots to facilitate engagement, such as liking posts, sharing content, and following users. These bots can enhance user experience and interaction.

Bad Bots: Bad bots are designed maliciously, often causing harm or disruption. They can be used for various nefarious purposes, including cyber attacks, fraud, and information theft. Here are examples of bad bots:

  1. Web Scraping Bots for Content Theft: Bots may scrape websites to steal content, which can be used for unauthorized reproduction, plagiarism, or to create fake websites.
  2. Credential Stuffing Bots: Bots can be employed to automate credential stuffing attacks, where stolen username and password combinations are systematically tested on various websites to gain unauthorized access.
  3. Distributed Denial of Service (DDoS) Bots: DDoS bots flood a website or online service with traffic, overwhelming its resources and causing it to become slow or unavailable.
  4. Spam Bots: Bots can be programmed to flood online forums, comment sections, or social media with spam messages, links, or advertisements.
  5. Click Fraud Bots: Bots engage in click fraud by repeatedly clicking on online ads to exhaust the advertiser’s budget or promote fraudulent activities.
  6. Impersonation Bots: Bots may impersonate legitimate users on social media or other platforms to spread misinformation, manipulate opinions, or engage in cyberbullying.
APPLICATION TOPOLOGY

Bot-Control Managed Rule Group :

The managed rule group provides 2 protection levels

  1. Common: Detects a variety of self-identifying bots and adds labels to them. It is ideal for customers with generic bot problems. Categorizing and verifying simple bots e.g bot:category:social_media such as Redditbot
  2. Targeted: Detection based on client-side JavaScript interrogation, browser fingerprinting, captcha, and dynamic rate limiting. Protect against advanced bots that target specific applications by mimicking human traffic and changing the attack vectors to evade detection. It is ideal for customers who are getting targeted by advanced bots.

SCENARIO A: Prevent identified and unidentified bots.

  1. Create a web ACL and associate ALB/CF with it.
  2. Add AWS-managed rule group with Common Bot Control.
  3. By default put the rule on block mode to identify and restrict the bots.
  4. Attack by initiating a fake session with the Identity of “Amazonbot” instead of curl.
  5. Attack by initiating a fake session with the Identity of “Mozilla/5.0” instead of curl.
  6. Verify the sampled requests in WAF for BotControlRuleSet.
  7. WAF should be able to detect fake sessions and block the bot requests.
curl -vkLso /dev/null -A "Amazonbot" -w "%(http_code) \n" https://yourwebsite.com | sort | uniq -c
curl -vklso /dev/null -A "mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/115.0" -w "%{http_code}\n" https://yourwebsite.com

SCENARIO B: Captch response for specific sensitive web pages.

  1. Use the existing web ACL which was created in scenario A.
  2. Add the custom rule to place CAPTCHA verification.
  3. You can have this for specific sensitive pages like /payment.
  4. Browse the https://yourwebsite.com/payment in the browser.
  5. WAF should be able to ask you to solve the puzzle if you are human.
  6. Attack the /payment page by initiating the fake session.
  7. WAF should be able to identify you as BOT and block the request.
curl -vklso /dev/null -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/115.0" -w "%{http_code}\n" https://yourwebsite.com/payment

Testing and tuning :

Prepare for testing

  1. Enable web ACL logging, Amazon Cloud Watch metrics, and web request sampling for the web ACL.
  2. Set your protections to Count mode.
  3. Associate the web ACL with a resource.

Monitoring and tuning

  1. Monitor traffic and rule matches: Logs, Metrics and Sample Requests.
  2. Configure mitigations to address false positives.
  3. Correcting rule inspection criteria.
  4. Correcting more complex problems: Add mitigating rule, scope-down statement, add a label match rule, change the version of managed rule group.

A few things to keep in mind

  1. Rule order: AWS WAF rules should be ordered so that labels are used properly. Fine-grained rules should typically be positioned high in the WebACL.
  2. Cost management: Use scope-down statements to manage Bot Control’s costs. Use rate-based rules as well as CAPTCHA to avoid abuse of ATP or CAPTCHA costs.

Reduce Bot Activities

  1. Identify applications with high potential as bot targets.
  2. Collect client-side signals.
  3. Design applications to remove incentives.
  4. Harden your SDKs.

Conclusion :

In the fast-paced digital landscape, where businesses thrive, the threat of bot attacks is real. From spreading misinformation to compromising data, bots are relentless. Yet, armed with knowledge and vigilance, businesses can stand strong.

Distinguish friend from foe, implement robust security, and stay alert. The battle against bots is ongoing, but with the right strategies, your digital fortress remains secure. As we journey towards a safer digital future, let resilience and proactive defence be your guiding lights.

🚀🛡️💻#DigitalSecurity #BotThreats #BotProtection🚀🛡️💻

--

--