DEV Community

Cover image for 🚨 I Secured My Compromised AWS Account : Here’s the Incident Response Playbook
Rahul Joshi
Rahul Joshi

Posted on

🚨 I Secured My Compromised AWS Account : Here’s the Incident Response Playbook

“It started with a small billing spike… and ended with an AWS Abuse Report.”

One morning, I noticed something unusual in my AWS billing dashboard.

At first glance, it didn’t look huge — around $20.
But something felt off.

⚠️ The Red Flag

When I checked deeper:

  • Most charges were from data transfer
  • Traffic originated from ap-south-1 (Mumbai)
  • Data was being sent to Middle East (Bahrain) region
  • And the scary part…

👉 This activity happened at night — when I wasn’t even using AWS


💣 Then Came the Real Shock

During the same time window…

I received an AWS Abuse Report email.

It said:

  • My EC2 instance was involved in suspicious activity
  • Possibly Denial of Service (DoS)-like behavior
  • AWS warned my environment might be compromised

👉 That’s when it was clear:

This wasn’t just billing. This was an active compromise.


⚠️ Phase 0: What Actually Happened

📊 Key Indicators:

  • ~209 GB data transfer to Bahrain
  • Unexpected outbound traffic charges
  • Activity during inactive hours
  • AWS Abuse Report notification

💡 Interpretation:
This strongly indicates:

  • Your instance was likely used as a bot / relay server
  • Or part of malicious traffic / scanning / DoS activity

🛑 Phase 1: Immediate Containment

🔒 Step 1: Lock Access

  • Changed root password
  • Verified MFA was already enabled and re-authenticated all sessions to ensure no unauthorized access persisted.
  • Logged out all sessions

🔐 Step 2: Kill Entry Points

  • Revoked all IAM access keys
  • Deleted unknown users (if any)
  • Checked roles for misuse

💻 Step 3: Stop the Attack Source

  • Terminated the EC2 instance (important)
  • Stopped all suspicious services
  • Restricted outbound traffic in Security Groups

💡 In your case:

The EC2 instance itself was the attack vector.


🔍 Phase 2: Investigation

📜 What I Checked:

  • CloudTrail logs
  • VPC Flow Logs (for traffic pattern)
  • EC2 instance activity

🔎 Findings:

  • High outbound traffic to external IPs
  • Data routed from Mumbai → Bahrain
  • Pattern matched automated traffic behavior

💡 Most likely cause:

  • Compromised EC2 (open ports / weak SSH / exposed key)

🧹 Phase 3: Eradication

🔥 Actions Taken:

  • Terminated compromised EC2
  • Removed unused security group rules
  • Closed open ports (like 0.0.0.0/0 on SSH)
  • Rotated all credentials

🔐 Security Fixes:

  • Disabled password-based SSH
  • Enforced key-based login only
  • Removed unnecessary public access

🛡️ Phase 4: Recovery & Hardening

✅ What I Implemented:

1. Strict Security Groups

  • No open ports to the world
  • Only whitelisted IPs

2. Monitoring Enabled

  • CloudWatch alerts
  • Billing alarms

3. GuardDuty Turned On

  • Real-time threat detection

4. IAM Hardening

  • Least privilege roles
  • No long-term access keys

📧 AWS Abuse Report: What It Meant

That email was critical.

It basically confirmed:

  • Your infrastructure was being misused
  • AWS had detected malicious patterns
  • Action was required immediately

💡 Important:

Ignoring this email can lead to account suspension


⚔️ Final Playbook (Based on Real Incident)

If you see:

  • Unexpected data transfer
  • Unknown regions involved
  • AWS abuse email

👉 Do THIS immediately:

  1. Terminate suspicious EC2
  2. Revoke all access keys
  3. Enable MFA
  4. Check CloudTrail
  5. Lock down Security Groups
  6. Rotate secrets
  7. Enable GuardDuty

🧠 Real Lesson

“It wasn’t a hack of AWS… it was a misconfigured EC2.”

Most likely reasons:

  • Open SSH port (0.0.0.0/0)
  • Weak credentials or leaked key
  • No monitoring in place

🔥 Final Thought

This incident cost me:

  • Money 💸
  • Time ⏱️
  • Stress 😓

But it gave me something more valuable:

👉 Real-world cloud security experience

Top comments (2)

Collapse
 
kate8382 profile image
Ecaterina Sevciuc

Great write-up, Rahul! Reading this just confirms my lifelong vow: never to touch the backend by my own free will. 😂 I get enough stress and responsibility just trying to set up an SSH connection! 😅

Huge respect to you for handling such a crisis and then writing about it with such ease. It’s a great lesson for all of us. Stay secure! ✨

Collapse
 
17j profile image
Rahul Joshi

Haha, I totally get it! Backend and Security can definitely feel like a dark forest sometimes, especially when an abuse report hits your inbox. But honestly, even setting up an SSH connection is the first step toward understanding the 'gates' of a system—so you’re already on the path! Thanks for the kind words; glad the write-up could take some of the mystery (and stress) out of the process. Stay safe!