惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
Microsoft Security Blog
Microsoft Security Blog
Jina AI
Jina AI
博客园 - 叶小钗
J
Java Code Geeks
博客园 - 聂微东
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
美团技术团队
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
罗磊的独立博客
T
The Blog of Author Tim Ferriss
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
小众软件
小众软件

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
🚨 S3 Ransomware Response — What to Do in the First Critic...
Python-T Poi · 2026-05-14 · via DEV Community

An attacker encrypts every object in your production S3 bucket and replaces them with ransom notes. The next 15 minutes determine whether you restore data in under an hour or face a six-figure payout. This is S3 ransomware response — a high-stakes race where speed, precision, and preparation decide the outcome.

📑 Table of Contents

  • ⏱ Minute 0-2 — Stop the Bleed
  • 🛡 Minute 2-10 — Contain and Assess
  • 🔀 Minute 10-X — Recovery Decision Tree
  • 🔐 Preventive Controls — Stop This From Happening Again
  • 🟩 Final Thoughts
  • ❓ Frequently Asked Questions
  • Can AWS help recover data after an S3 ransomware attack?
  • Does S3 Server-Side Encryption (SSE) protect against ransomware?
  • How can I test my S3 ransomware recovery plan?
  • 📚 References & Further Reading

⏱ Minute 0-2 — Stop the Bleed

The first two minutes must halt active damage. The objective is to disable write operations before further encryption or data exfiltration occurs.

Do not pay the ransom. Payment does not guarantee decryption and increases the likelihood of repeat targeting.

Do not delete the compromised IAM user or role. Deletion erases critical audit metadata. Preserve identities for forensic validation.

Do not click links in ransom notes. URLs may execute malicious payloads or signal attacker command-and-control infrastructure.

Immediately block write access to the affected bucket using a deny-all-writes bucket policy:

$ aws s3api put-bucket-policy \
    --bucket prod-backups-2024 \
    --policy file://deny-all-writes.json


{
    "ResponseMetadata": {
        "HTTPStatusCode": 204
    }
}

Enter fullscreen mode Exit fullscreen mode

This policy denies s3:PutObject, s3:DeleteObject, and s3:RestoreObject across all principals. The Deny effect overrides any Allow in IAM or resource policies due to AWS’s policy evaluation order — explicit deny wins, even for administrative users.

Here’s deny-all-writes.json:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyWritesDuringIncident",
      "Effect": "Deny",
      "Principal": "*",
      "Action": [
        "s3:PutObject",
        "s3:DeleteObject",
        "s3:RestoreObject"
      ],
      "Resource": [
        "arn:aws:s3:::prod-backups-2024/*"
      ]
    }
  ]
}

Enter fullscreen mode Exit fullscreen mode

With versioning enabled, attackers cannot permanently erase data without first deleting the latest version — but they can still overwrite objects in place. Blocking new writes prevents encryption of live versions.


🛡 Minute 2-10 — Contain and Assess

Next, isolate the compromised identity and initiate forensic data collection.

Identify the IAM entity behind the malicious writes using CloudTrail. Filter for high-frequency PutObject operations on the affected bucket:

$ aws cloudtrail lookup-events \
    --lookup-attributes AttributeKey=ResourceName,AttributeValue=prod-backups-2024 \
    --start-time 2024-04-15T10:00:00Z \
    --max-results 30


{
    "Events": [
        {
            "EventName": "PutObject",
            "EventTime": "2024-04-15T10:03:12Z",
            "Username": "backup-agent-role",
            "EventSource": "s3.amazonaws.com",
            "Resources": [
                {
                    "ResourceType": "AWS::S3::Object",
                    "ResourceName": "prod-backups-2024/db-snapshot.enc"
                }
            ],
            "AccessKeyId": "ASIA5X2Y3Z4ABCDE5678"
        }
    ]
}

Enter fullscreen mode Exit fullscreen mode

Key indicators:

  • EventName is PutObject with extensions like .enc, .crypt, or random suffixes.
  • Username corresponds to non-human roles, especially those with broad S3 access.
  • AccessKeyId begins with ASIA — signs of assumed role compromise via exposed session tokens.

Disable the role’s permissions by detaching its policies:

$ aws iam detach-role-policy \
    --role-name backup-agent-role \
    --policy-arn arn:aws:iam::123456789012:policy/S3FullAccess


{
    "ResponseMetadata": {
        "HTTPStatusCode": 200
    }
}

Enter fullscreen mode Exit fullscreen mode

The role remains but loses active permissions. This is faster and more forensic-safe than deletion.

If using AWS Organizations, apply a service control policy (SCP) to block all S3 actions for the principal:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "BlockS3WritesForCompromisedAccount",
      "Effect": "Deny",
      "Action": "s3:*",
      "Resource": "*",
      "Condition": {
        "StringLike": {
          "aws:PrincipalArn": "arn:aws:iam::123456789012:role/backup-agent-role"
        }
      }
    }
  ]
}

Enter fullscreen mode Exit fullscreen mode

SCP enforcement occurs before IAM policy evaluation — meaning this deny takes precedence, regardless of local allow rules.

If S3 server access logging is enabled, retrieve logs to trace upload sources:

$ aws s3api get-bucket-logging --bucket prod-backups-2024


{
    "LoggingEnabled": {
        "TargetBucket": "s3-access-logs-bucket",
        "TargetPrefix": "prod-backups-2024/"
    }
}

Enter fullscreen mode Exit fullscreen mode

Download logs from s3-access-logs-bucket matching the incident window. Filter for PUT requests with status 200 and non-zero request size — confirming successful object uploads.

Containment isn’t just access revocation — it’s preserving forensic data while eliminating active attack pathways.


🔀 Minute 10-X — Recovery Decision Tree

Choose the recovery path based on bucket configuration and backup availability.

If versioning is enabled and MFA Delete is disabled: Roll back to the last known clean version.

List versions for affected objects:

$ aws s3api list-object-versions \
    --bucket prod-backups-2024 \
    --prefix db-snapshot.sql


{
    "Versions": [
        {
            "Key": "db-snapshot.sql",
            "VersionId": "ExmPLx.idK9BH4iC.EO8LdyX.aI0.PT",
            "IsLatest": true,
            "LastModified": "2024-04-15T10:05:00Z",
            "Size": 20971520
        },
        {
            "Key": "db-snapshot.sql",
            "VersionId": "L45.bXeQ8.jwMpaLshUOwieqz_vwzCw",
            "IsLatest": false,
            "LastModified": "2024-04-15T09:00:00Z",
            "Size": 20971520
        }
    ]
}

Enter fullscreen mode Exit fullscreen mode

Recover the prior version:

$ aws s3api copy-object \
    --bucket prod-backups-2024 \
    --copy-source prod-backups-2024/db-snapshot.sql?versionId=L45.bXeQ8.jwMpaLshUOwieqz_vwzCw \
    --key db-snapshot.sql

Enter fullscreen mode Exit fullscreen mode

If versioning is disabled but S3 Object Lock is active in Governance mode: You can delete the encrypted object if you have s3:BypassGovernanceRetention.

$ aws s3api delete-object \
    --bucket prod-backups-2024 \
    --key db-snapshot.sql \
    --version-id ExmPLx.idK9BH4iC.EO8LdyX.aI0.PT \
    --bypass-governance-retention

Enter fullscreen mode Exit fullscreen mode

After deletion, restore from an external backup source.

If Cross-Region Replication (CRR) is configured: Check the target bucket in the secondary region:

$ aws s3api list-objects-v2 \
    --bucket prod-backups-2024-euwest1 \
    --prefix db-snapshot.sql

Enter fullscreen mode Exit fullscreen mode

If objects exist, copy them back:

$ aws s3 cp s3://prod-backups-2024-euwest1/db-snapshot.sql s3://prod-backups-2024/

Enter fullscreen mode Exit fullscreen mode

If no versioning or replication, but backups exist elsewhere (e.g., Glacier, EBS snapshots, third-party systems): Initiate restore workflows. Do not attempt re-upload until data is verified and staging is ready.

If none of the above apply: Recovery is not possible from AWS storage layers. Open a Priority Support Case with AWS. Request forensic support and preservation of CloudTrail logs. Concurrently assess regulatory reporting requirements. Do not engage with attackers.


🔐 Preventive Controls — Stop This From Happening Again

Prevention relies on immutable backups, strict least-privilege policies, and automated guardrails.

  1. Enable S3 Versioning on all production buckets — enables rollback to pre-attack state. This is the minimum viable recovery mechanism.
  2. Enable MFA Delete for critical buckets — requires multi-factor authentication to delete or suspend versioning, blocking automated destruction.
  3. Apply S3 Block Public Access at the account level — prevents public exposure that attackers scan for and exploit.
  4. Use S3 Object Lock in Compliance mode for regulated data — prevents deletion or modification even by root users until retention expires.
  5. Restrict S3 write access usingaws:SourceArn and aws:SourceVpc conditions — binds PutObject to specific services or VPCs, reducing risk from compromised credentials.

Example: limit PutObject to requests originating from a specific VPC:

{
  "Effect": "Allow",
  "Action": "s3:PutObject",
  "Resource": "arn:aws:s3:::prod-backups-2024/*",
  "Condition": {
    "ArnEquals": {
      "aws:SourceVpc": "vpc-1a2b3c4d"
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

This uses the request’s network context during policy evaluation — a stronger control than identity alone.

Enable S3 access logging and CloudTrail with log file integrity validation. These logs are append-only and signed, making them admissible for post-incident review.

Monitor configuration drift using AWS Config:

$ aws config list-discovered-resources --resource-type AWS::S3::Bucket

Enter fullscreen mode Exit fullscreen mode

Define custom rules to flag buckets missing versioning, public access, or encryption at rest.

🟩 Final Thoughts

S3 ransomware response is defined by pre-incident configuration. Recovery speed depends on whether versioning was enabled, whether Object Lock was set, and whether least-privilege policies were enforced.

No operational tooling or debugging skill compensates for missing backups or permissive policies. Your infrastructure as code — Terraform, CloudFormation, CI/CD pipelines — is the frontline of resilience.

When an attack occurs, the system responds to what was built, not what was intended. The recovery window starts long before the first encrypted object appears.

Prepare for the attack that bypasses assumptions. Build systems that survive the playbook’s failure.

❓ Frequently Asked Questions

Can AWS help recover data after an S3 ransomware attack?

AWS can assist with forensic analysis and account recovery through AWS Support, but they cannot decrypt files or restore data unless it’s available in versioned, replicated, or backed-up states. Recovery relies on your configuration.

Does S3 Server-Side Encryption (SSE) protect against ransomware?

No. SSE encrypts data at rest, but attackers with write access can still overwrite objects with their own encrypted content. Encryption protects confidentiality, not integrity or availability.

How can I test my S3 ransomware recovery plan?

Run controlled chaos engineering drills: simulate an attack by encrypting a test object, then execute your playbook. Verify version restore, policy rollbacks, and communication workflows. Test quarterly.

📚 References & Further Reading

  • Amazon S3 Versioning documentation — how to enable and manage object versions: docs.aws.amazon.com
  • AWS IAM Policy Evaluation Logic — deep dive into how Deny, Allow, and conditions are processed: docs.aws.amazon.com
  • Amazon S3 Object Lock guide — enforce write-once-read-many (WORM) compliance: docs.aws.amazon.com