Amazon EC2 (Elastic Compute Cloud) provides virtual servers in AWS. While EC2 instances look like regular servers, they have cloud-specific attack surfaces: instance metadata for credentials, security groups as firewalls, and instance profiles for IAM access. Understanding EC2 security is fundamental to cloud penetration testing.
EC2 attacks often combine traditional server exploitation with cloud-specific techniques. A web application vulnerability might lead to command execution, which leads to metadata access, which provides IAM credentials, which compromises the entire AWS account. It's the cloud version of "one vuln to rule them all."
EC2 = Traditional + Cloud
EC2 Security Model
EC2 Enumeration
User Data Contains Secrets
Security Group Attacks
Instance Metadata Exploitation
Check User Data First
EBS Snapshot Attacks
Systems Manager (SSM) Attacks
SSM Bypasses Network Security
EC2 Privilege Escalation
EC2 Persistence
EC2 Attack Methodology
EC2 Security Assessment
Knowledge Check
Challenges
Key Takeaways
- EC2 combines traditional server security with cloud-specific vectors
- Instance metadata (169.254.169.254) provides IAM credentials from inside
- User data scripts often contain hardcoded credentials
- Security groups open to 0.0.0.0/0 are major vulnerabilities
- SSM provides shell access without inbound ports
- EBS snapshots may contain sensitive data and can be mounted elsewhere