Kuboid
Open Luck·Kuboid.in
Security BSides2025
Open in YouTube ↗

Hey, You, Get Out of My (AWS) Cloud

BSidesSLC67 views32:0310 months ago

This talk explores the critical importance of implementing robust network, permission, and resource perimeters within AWS environments to prevent unauthorized access and data exfiltration. It details common misconfigurations, such as overly permissive IAM roles, insecure S3 bucket policies, and the risks associated with API keys and unmanaged services like AWS Cognito. The speaker emphasizes the necessity of adopting a zero-trust approach, utilizing Service Control Policies (SCPs), and implementing security gates in Infrastructure-as-Code (IaC) pipelines to mitigate these risks. Practical guidance is provided on securing outbound traffic and protecting critical data using S3 Object Lock.

How Misconfigured AWS Perimeters Turn Simple Footholds Into Full Account Takeovers

TLDR: Cloud environments are rarely as segmented as they appear, and attackers frequently exploit gaps between network, permission, and resource perimeters to move laterally. This post breaks down how misconfigured IAM trust policies, insecure S3 bucket policies, and unmanaged services like AWS Cognito create massive, overlooked attack surfaces. Pentesters should prioritize auditing these "perimeter" configurations to identify paths for privilege escalation and data exfiltration that bypass traditional network controls.

Security researchers often focus on finding RCEs or SQL injection, but the most devastating breaches in cloud environments rarely involve a single, flashy exploit. Instead, they are the result of "perimeter drift"—the slow accumulation of misconfigurations across network, permission, and resource boundaries. When you land a foothold in an AWS environment, you aren't just looking for a vulnerable EC2 instance; you are looking for the path of least resistance to the account’s crown jewels.

The Illusion of the Network Perimeter

In traditional data centers, the network perimeter was a hard shell. In AWS, that shell is porous. Many developers assume that placing a resource in a private subnet or behind a security group is sufficient protection. However, AWS services often communicate over internal APIs that bypass these controls entirely.

When you are performing a penetration test, stop treating the VPC as a monolithic boundary. Instead, look at how services interact via VPC Endpoints. If a service is configured to use an interface endpoint, it might be reachable from other parts of the network that you previously assumed were isolated. Furthermore, outbound traffic is the most overlooked vector. Most security groups default to allowing all outbound traffic. If you gain execution on a Lambda function or an EC2 instance, you can often exfiltrate data directly to an attacker-controlled endpoint unless you have implemented strict egress filtering via a Network Firewall.

The Real Danger: Permission and Resource Perimeters

Permissions are the new network. If you can manipulate an IAM role, you don't need to bypass a firewall. The most common mistake I see during red team engagements is the over-reliance on "Resource Star" permissions. When a policy grants s3:GetObject on Resource: "*", it effectively ignores the resource perimeter.

Take the case of S3 Object Lock. Many organizations enable this to protect backups from ransomware, but if the IAM role used by the backup service is compromised, the attacker can simply delete the versioned objects or modify the lifecycle policies if the permissions are too broad.

The most dangerous technique I encounter is role-chaining. Attackers look for sts:AssumeRole permissions that allow them to jump from a low-privilege development account into a high-privilege production account. If you are auditing an environment, run a script to map out all sts:AssumeRole relationships. You will almost always find a path that leads to an account with AdministratorAccess.

Exploiting Unmanaged Services

Services like AWS Cognito are frequently misconfigured because they sit outside the standard VPC security model. Cognito identity pools can be configured to grant temporary AWS credentials to unauthenticated users. If the associated IAM role is overly permissive, an attacker can use these credentials to query other AWS services.

During an engagement, always check the IdentityPool configuration. If you find an identity pool that allows unauthenticated access, use the aws-cli to request credentials and see what you can access:

aws cognito-identity get-credentials-for-identity --identity-id <IDENTITY_ID>

Once you have those credentials, you are effectively an authenticated user within the account. If the role attached to that identity pool has s3:ListBucket or secretsmanager:GetSecretValue, you have just bypassed the entire network perimeter.

Hardening the Environment

Defenders need to move toward a model where the perimeter is enforced at the organization level. Service Control Policies (SCPs) are your best tool for this. Use them to explicitly deny the creation of resources in unauthorized regions or to prevent the modification of critical security infrastructure.

For pentesters, the goal is to identify where these SCPs are absent. If you can create an S3 bucket in a region that the organization doesn't monitor, you have a perfect staging area for exfiltrated data.

Finally, never ignore the IMDSv2 requirement. If you find an instance that still allows IMDSv1, you can often pull metadata credentials even if the instance is behind a restrictive security group. Always check for this early in your engagement.

The cloud is a complex web of interconnected permissions. If you treat it like a flat network, you will miss the most critical vulnerabilities. Start by mapping the trust relationships between roles and accounts, and you will find that the "perimeter" is often just a suggestion.

Talk Type
talk
Difficulty
intermediate
Has Demo Has Code Tool Released


BSidesSLC 2025

24 talks · 2025
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in