AWS Logo
Menu

Strategies to Mitigate Exfiltration Attacks in Amazon S3

In this post, I’ll be using only AWS services. In a future post, I’ll discuss OpenSource tools that can also help.

Published Feb 25, 2025

1. Understanding the Risk of Exfiltration in S3

Exfiltration consists of extracting or transferring information in an unauthorized manner outside the organization. When it comes to S3, this can happen if:
  • There are overly permissive bucket policies or ACLs, allowing public access or access by malicious users.
  • Activity monitoring and logging are not in place, making it difficult to detect suspicious downloads or data copies.
  • Encryption and auditing mechanisms are lacking, making it easier for an attacker to read and export sensitive data.

2. Minimum Access and Identity Governance

Least Privilege Principle
  • Grant only the necessary permissions for each user, service, or application.
  • Avoid broad policies (such as “s3:*”) when only a few specific actions are needed (e.g., s3:GetObject or s3:PutObject).
Bucket Policies and IAM Policies
  • Use Bucket Policies and IAM policies to restrict access to trusted IP addresses, VPC Endpoints, or specific accounts.
  • Consider using Condition Keys, such as aws:SourceVpce, to authorize traffic originating only from an AWS PrivateLink (VPC Endpoint).
S3 Block Public Access
  • Enable this setting for all buckets that do not require public access.
  • This prevents accidental exposure if someone inadvertently applies public permissions.
Integration with AWS Organizations
  • If your company uses multiple accounts, establish Service Control Policies (SCPs) to enforce security controls at the organizational level, restricting unauthorized S3 actions.

3. Protecting Traffic and Data

Server-Side Encryption (At-Rest Encryption)
  • Activate default encryption (SSE-S3) or use SSE-KMS with AWS KMS-managed keys for granular control over encryption keys and usage logs.
  • This approach ensures that even if someone gains unauthorized access to objects, they cannot read their contents without the appropriate keys.
Encryption in Transit (HTTPS/TLS)
  • Always require HTTPS connections, blocking HTTP requests to prevent interception in transit.
  • Configure clients, applications, and services to use aws:SecureTransport as an access condition.
VPC Endpoints for S3
  • When using S3 within a VPC, create VPC Endpoints so that traffic between the VPC and S3 does not traverse the public internet, reducing the risk of interception or exfiltration via external routes.
S3 Object Lock and Versioning
  • Enabling Object Lock in Compliance mode prevents objects from being deleted or overwritten before the retention period is over. This helps protect data against malicious tampering.
  • Versioning retains previous versions of objects, making it easier to recover if an object is modified or removed improperly.

4. Monitoring and Detecting Suspicious Activities

S3 Access Logs
  • Configure S3 access logs to capture details of every read (GET) or write (PUT) request.
  • Store these logs in a separate bucket (with appropriate security policies) for analysis and auditing.
AWS CloudTrail
  • Records all API calls related to S3, such as bucket creation and deletion, policy modifications, object listing, etc.
  • Enable CloudTrail Data Events to track specific actions on objects (e.g., downloads), helping identify unusual or unauthorized access.
Amazon GuardDuty
  • A threat detection service that monitors suspicious activity, such as large-scale data extraction or access from malicious IP addresses.
  • Provides exfiltration findings when it detects attack patterns (e.g., bucket scanning or abnormal downloads).
Amazon Macie
  • Uses machine learning to identify sensitive data stored in S3.
  • Helps classify and track where confidential information resides, making it easier to implement policies and detect suspicious access.
AWS Security Hub
  • Centralizes security findings from multiple services (GuardDuty, Macie, Inspector, etc.) in one place.
  • Allows you to create automations via EventBridge for immediate response (e.g., IP blocking or removal of permissions).

5. Automation and Incident Response

Amazon EventBridge and Lambda
  • Create rules in EventBridge to trigger Lambda functions when detecting suspicious behaviors in logs or security findings.
  • Examples:
    • Upon detecting an unusual number of downloads (via CloudTrail Data Events), temporarily isolate the bucket.
    • If GuardDuty generates a high-risk finding related to S3, automatically update the bucket policy to block anonymous access.
Automatic Remediation
  • Use AWS Config with custom rules to verify if buckets comply with security standards (encryption enabled, public access blocked, etc.).
  • If something is out of compliance, trigger a script (Lambda) that immediately corrects the settings.
Incident Playbooks
  • Maintain documented procedures (playbooks) to respond to exfiltration incidents, including steps to trace the source, block exit points, and collect evidence (logs, screenshots, etc.).

6. Auditing and Compliance Policies

Manage the Data Lifecycle
  • Use S3 Lifecycle Policies to move older data to lower-cost storage tiers (Glacier), reducing the risk surface and limiting exposure of sensitive data.
  • Properly delete data that no longer needs to be stored.
Regulatory Compliance
  • If your organization is subject to regulations such as LGPD, HIPAA, GDPR, PCI-DSS, or SOC 2, regularly review S3 retention and access policies.
  • Configure access alerts (e.g., via Macie) when sensitive data is placed in high-risk buckets.
Audit Reports
  • Export logs and findings to SIEM (Security Information and Event Management) systems or to AWS Security Hub.
  • Generate reports showing that all S3 buckets meet requirements for encryption, logging, and minimum access.

7. Additional Best Practices

  • Use private paths when making files available, opting for pre-signed URLs for temporary access instead of leaving objects publicly accessible.
  • Schedule monthly/quarterly reviews of access policies, existing buckets, and sensitive data.
  • Protect IAM credentials (root user, access keys) and enable MFA on all high-privilege accounts, reducing the chance that compromised credentials could be used for exfiltration.
  • Segregate environments: buckets containing sensitive production data should be isolated from development and testing buckets, preferably in separate AWS Organizations accounts.

Conclusion

Protecting data stored in S3 from exfiltration requires a layered defense approach that includes:
  • Strict access control (least privilege, block public access)
  • Encryption (at rest and in transit)
  • Monitoring and logging (CloudTrail, Access Logs, Macie, GuardDuty)
  • Automated response (EventBridge, Lambda, AWS Config)
  • Compliance practices (LGPD, PCI, etc.) and more
As we know, nothing in information security is 100% guaranteed, but by adding layers to the process, you significantly reduce the attack surface and make successful exfiltration attacks much more difficult. With the rapidly evolving threat landscape, it’s critical to keep your processes, configurations, and policies up to date to ensure a more secure S3 environment.
 

Comments