Write Up – Private Bug Bounty: RCE In EC2 Instance Via SSH With Private Key Exposed On Public Github Repository – $xx,000 USD
A private SSH key and connection config were committed to a public GitHub repository, allowing anyone to log in to an EC2 instance. The reporter used the key to gain root access and run commands on the server.
Published on omespino.com
3.- Once I got access I executed sudo su and id in order to confirm the admin privileges and we got root:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an employee committed SSH credentials and configuration to a public GitHub repository, exposing the private key.
Impact
An attacker could gain access to the EC2 instance and perform arbitrary commands as root.
What the attacker needed
Public GitHub repository with SSH key; network access to the EC2 host
How it was found
- Search GitHub with dorks to find a public repository containing SSH configuration and a private key.
- Download the private key and set its file permissions so the SSH client accepts it.
- Connect to the host listed in the config using the key and the ec2-user account.
- Run sudo su and id to confirm root privileges, then log out.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A private key is like a password file that proves who you are when connecting to a server over SSH, a secure remote login protocol. Because the key was left in a public code repository, anyone could download it and log in as the server's user. The reporter then used a normal command to become the all-powerful root user.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.