Breaching AWS Accounts Through Shadow Resources
This talk demonstrates how attackers can exploit 'shadow resources'—automatically created AWS resources like S3 buckets—to perform account takeovers and information disclosure. By predicting the naming patterns of these resources, an attacker can pre-claim them in their own account, intercepting sensitive data or injecting malicious code into services like CloudFormation, Glue, and SageMaker. The researchers introduce 'TrailShark', a Wireshark plugin designed to identify and debug these undocumented API calls, and provide actionable mitigation strategies using resource-based policies.
Exploiting Shadow Resources: How Automated AWS Provisioning Creates Account Takeover Paths
TLDR: Cloud services often auto-provision S3 buckets to store temporary configuration files, creating a predictable attack surface known as "shadow resources." By identifying these naming patterns, researchers demonstrated that attackers can pre-claim these buckets to intercept sensitive data or inject malicious code into services like CloudFormation, Glue, and SageMaker. This research highlights a critical need for using resource-based policies with the
aws:ResourceAccountcondition to prevent cross-account resource hijacking.
Cloud security often feels like a game of whack-a-mole, but the most dangerous vulnerabilities are frequently the ones baked into the platform's own convenience features. When you use services like AWS CloudFormation or Glue, you expect the platform to handle the heavy lifting of infrastructure management. However, that automation often relies on "shadow resources"—S3 buckets created behind the scenes to store your templates or job scripts. If those resources follow predictable naming patterns, they become a massive, cross-account liability.
The core of this research centers on the fact that many AWS services generate S3 buckets with deterministic names. If an attacker can predict the name of a bucket that a victim’s account is about to create, they can simply create that bucket in their own account first. Because S3 bucket names must be globally unique, the victim’s attempt to provision their infrastructure will fail or, worse, be redirected to the attacker's bucket. This isn't just a theoretical denial-of-service; it is a direct path to information disclosure and remote code execution.
The Mechanics of Shadow Resource Hijacking
The attack flow is deceptively simple. When a user initiates a stack deployment in CloudFormation, the service attempts to upload a template file to a bucket named using a specific pattern: cf-templates-{hash}-{region}. The researchers found that the hash component is often predictable or discoverable. By monitoring public repositories or using brute-force techniques, an attacker can identify these patterns.
Once the attacker claims the bucket in their own region, they can set up a Lambda function triggered by PutBucketNotification events. When the victim attempts to deploy their stack, their template file is uploaded directly into the attacker's bucket. The attacker’s Lambda function then intercepts this file, modifies it to include a malicious IAM role or backdoored configuration, and places it back. When the victim’s CloudFormation service eventually processes the file, it executes the attacker's injected code with the victim's permissions.
To debug these undocumented API interactions, the researchers released TrailShark, a Wireshark plugin. It allows you to capture and inspect the internal API calls that AWS services make to one another, which are often invisible in standard CloudTrail logs. For a pentester, this tool is invaluable for mapping out how a specific service interacts with its underlying storage.
From Information Disclosure to RCE
The impact varies by service, but the potential for full account takeover is real. In the case of AWS Glue, the service stores Python scripts in a bucket named aws-glue-assets-{account-id}-{region}. Because the account ID is not a secret, an attacker can easily predict this bucket name. By hijacking this bucket, an attacker can replace a legitimate ETL script with a malicious one. When the victim runs their Glue job, they inadvertently execute the attacker's code.
Similarly, in Amazon SageMaker, the service uses a bucket named sagemaker-{region}-{account-id} to store Jupyter notebooks. By injecting JavaScript into these notebooks, an attacker can achieve a stored cross-site scripting (XSS) attack. When the victim opens their notebook in the SageMaker console, the malicious script executes in their browser, potentially stealing session tokens or performing actions on their behalf. This falls squarely under OWASP A05:2021-Security Misconfiguration, as the platform's default behavior creates a dangerous trust relationship.
Practical Engagement Strategy
If you are performing an AWS penetration test, start by auditing the S3 buckets in your target's environment. Look for buckets that seem to be managed by AWS services rather than human operators. Use the aws s3api list-objects-v2 command with the --expected-bucket-owner flag to verify that the buckets you are interacting with actually belong to the account you are testing.
aws s3api list-objects-v2 --bucket <BUCKET_NAME> --expected-bucket-owner <ACCOUNT_ID>
If you find that your target is using services like Glue or CloudFormation, check if they have implemented strict resource-based policies. If they haven't, you have a clear path to demonstrate how an external actor could intercept their deployment pipeline.
Hardening Your Infrastructure
The primary defense against this class of attack is the use of the aws:ResourceAccount condition in your resource-based policies. By explicitly defining which account is allowed to access a resource, you prevent cross-account confusion.
"Condition": {
"StringEquals": {
"aws:ResourceAccount": "123456789012"
}
}
Beyond policy enforcement, verify the owner of every S3 bucket your services interact with. If you are building custom automation, avoid relying on default naming conventions. Use random strings or unique identifiers in your bucket names to make them impossible for an external actor to guess. The convenience of automated provisioning is not worth the risk of handing an attacker the keys to your entire cloud environment. Treat your infrastructure as code, but audit the hidden resources that code creates.
Vulnerability Classes
Target Technologies
Attack Techniques
OWASP Categories
All Tags
Up Next From This Conference

Breaking Secure Web Gateways for Fun and Profit

Listen to the Whispers: Web Timing Attacks That Actually Work

Abusing Windows Hello Without a Severed Hand
Similar Talks

Kill List: Hacking an Assassination Site on the Dark Web

Firewalls Under Fire: China's Ongoing Campaign to Compromise Network Protection Devices

