Website Source Code Analysis To AWS Account Takeover
AWS access and secret keys were hardcoded in a JavaScript file on an admin subdomain. An attacker who found them could authenticate to AWS, list S3 buckets, and access sensitive documents and SQL backups.
Published on kailashbohara.com.np
Security engineer with 9 years of experience in penetration testing, security architecture, cloud security, zero trust implementation, and threat hunting.
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, AWS credentials were hardcoded in client-side JavaScript, exposing them to anyone who viewed the page source.
Impact
The keys were valid, allowing the attacker to list all S3 buckets and access sensitive documents and SQL backups, potentially leading to full AWS account takeover.
What the attacker needed
Access to the admin subdomain; a browser with TruffleHog extension; AWS CLI installed
The fix
Secrets should not be hardcoded in client-side code; they should be rotated and bucket ACLs configured properly.
How it was found
- Browse the corporate website and scan for subdomains with subfinder.
- Visit the admin subdomain and notice a TruffleHog browser extension alert about exposed keys.
- Open the referenced JavaScript file and search for AWS keys.
- Configure the AWS CLI with the found access and secret keys.
- List S3 buckets and check caller identity.
- Visit the S3 bucket URL directly and find documents and SQL backup files.
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 website's JavaScript file contained secret login keys for Amazon Web Services (AWS), the cloud platform the company uses. Anyone who viewed that file could copy the keys and use them to access the company's cloud storage, where they found private files and database backups.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.