Skip to content
Crypto Write-up Intermediate

How I Broke Encrypted Requests by Reading Frontend JavaScript

The application encrypted API requests with AES-CBC using a hardcoded key and IV embedded in publicly accessible JavaScript. An attacker could extract these secrets and decrypt sensitive API traffic outside the browser, breaking confidentiality.

medium.com

Published on medium.com

I’ve heard this sentence many times during security assessments. And technically, it’s often true.

Amit Pal | amitpxl, on medium.com

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 the encryption key and IV were hardcoded in client-side JavaScript, so anyone could extract them and decrypt the traffic.

Impact

The attacker could decrypt sensitive API responses, exposing internal hierarchy data, business objects, IDs, and metadata, and could also encrypt arbitrary payloads to forge requests if the backend trusts encrypted data.

What the attacker needed

Access to the web application; ability to capture API traffic

The fix

Client-side encryption should not be used as a security control; rely on TLS for transport security and avoid hardcoding secrets in frontend code.

How it was found

  1. Fetch the homepage and list JavaScript bundle URLs.
  2. Beautify the main JavaScript bundle for easier reading.
  3. Search for crypto-related keywords to find encryption functions.
  4. Follow imports to other JavaScript chunks that contain the actual AES logic.
  5. Search those chunks for the encryption key and IV.
  6. Use the extracted key and IV in a Python script to decrypt captured ciphertext.

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.

The website scrambled its data before sending it, like locking a box. But it left the key to the lock inside the website's code, which anyone can read. So an attacker could copy the key and open the box to see the secret data.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.