Skip to content

AdamsCodeAndProjects/EC2-S3-Attack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

EC2-S3-Attack

Cloud Security Vulnerability Test and Hardening Project

Overview

This project demonstrates a hands-on cloud security assessment and remediation using AWS services. It includes:

  • Setting up an AWS EC2 instance and an S3 bucket with intentional misconfigurations.
  • Simulating an attack by exploiting a publicly accessible S3 bucket and an open EC2 SSH port.
  • Performing basic post-exploitation actions to understand the attack surface.
  • Implementing Blue Team defenses to secure the environment and mitigate risks.

Project Components

1. Vulnerability Setup (Red Team Phase)

  • Created an S3 bucket with public read access.
  • Uploaded a dummy sensitive file to the S3 bucket.
  • Launched an EC2 instance with open SSH access (0.0.0.0/0).
  • Demonstrated access to the sensitive file via public URL.
  • Demonstrated SSH access and scanning possibilities on EC2.

2. Defense and Hardening (Blue Team Phase)

  • Made the S3 bucket private by enabling "Block all public access" and removing open bucket policies.
  • Restricted EC2 SSH access to only my personal IP address via Security Group inbound rules.
  • Rotated EC2 key pairs by terminating the vulnerable instance and launching a new instance with a new key pair.
  • Installed and enabled UFW firewall on the EC2 instance to restrict unauthorized access.
  • (Optional) Created and attached an IAM role with least privilege policy for EC2 access to S3.

Tools and Technologies Used

  • AWS EC2 and S3
  • AWS IAM for access control
  • Linux terminal with ssh, curl, and AWS CLI
  • UFW firewall on Ubuntu EC2
  • Basic scripting for file creation and upload

Screenshots

Screenshots of each step are included below. Sensitive information such as IP addresses and personal usernames have been blurred to protect privacy.


Lessons Learned

  • Understanding how misconfigured cloud resources can lead to data exposure.
  • Practical experience with AWS Security Groups, IAM policies, and key management.
  • Importance of network restrictions and firewall configurations.
  • Value of rotating credentials post-incident.
  • Basic Linux security tools installation and usage.

Future Work

  • Implement automated monitoring and alerts (e.g., AWS GuardDuty).
  • Explore more advanced IAM policies and roles.
  • Set up logging and audit trails for compliance.

EC2 instance created - Launched a vulnerable EC2 instance using a public key and open SSH access from all IPs (0.0.0.0/0).

ec2-instance-created

Created S3 Bucket - Created an S3 bucket with misconfigured public access to simulate a real-world data exposure scenario.

created-s3

Created a sensitive file -- Generated a dummy "sensitive" file (e.g., password.txt) to demonstrate potential data leakage if exposed.

Edit-Secret-data

Uploaded the fake sensitive file to the S3 bucket while public access was still enabled.

Upload-sens-complete

Demonstrated unauthorized access to the file using a simple curl command without authentication.

hacked-sensitive-data

Hardened the EC2 instance by modifying the security group to allow SSH only from my IP.

new-ec2-rules

Now Blocking ALL public access

Screenshot 2025-07-02 at 5 49 10 PM

Simulated credential rotation by terminating the original instance and launching a new EC2 with a fresh key pair. new created key pair

Status - Installed and enabled UFW firewall on EC2, allowing only SSH connections for further internal hardening.

ufw status

About

Misconfigure S3 bucket to find vulnerabilities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published