Skip to content
Leaked secrets Write-up Beginner

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.

Kailash Bohara Follow

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.

Kailash Bohara, on kailashbohara.com.np

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

  1. Browse the corporate website and scan for subdomains with subfinder.
  2. Visit the admin subdomain and notice a TruffleHog browser extension alert about exposed keys.
  3. Open the referenced JavaScript file and search for AWS keys.
  4. Configure the AWS CLI with the found access and secret keys.
  5. List S3 buckets and check caller identity.
  6. 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.

More by Kailash Bohara

View all

7 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.