Skip to content
Leaked secrets Write-up Intermediate

Secrets That Survive Everything

Hardcoded Azure AD client secrets and APIM subscription keys were found in client-side JavaScript bundles, allowing an attacker to obtain bearer tokens and access user profile data. A second application used a CryptoJS-encrypted configuration blob with the decryption key hardcoded in the same file, exposing the same credential set.

infosecwriteups.com

Published on infosecwriteups.com

During a security assessment, I found credentials sitting in a client-side JavaScript bundle, visible to every visitor who opened DevTools.

Hemanth Gorijala, on infosecwriteups.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 secrets were injected into client-side bundles at build time or stored in client-side encrypted configuration with the decryption key alongside, so they were served to every visitor.

Impact

An attacker could authenticate as the application and access user profile data for any user, potentially leading to full account takeover, though the text notes the blast radius depends on the permissions granted to the application.

What the attacker needed

Access to the application's JavaScript bundle; no authentication required to view the bundle

The fix

The text says the findings were remediated and verified through retest, and recommends a Backend for Frontend pattern so credentials never reach the browser.

How it was found

  1. Open the production application's JavaScript bundle in the browser developer tools.
  2. Extract the Azure AD AppID, AppKey, Resource and APIM subscription key from the bundle.
  3. Call the Azure AD token endpoint with the client credentials to obtain a bearer token.
  4. Read the minified bundle to reconstruct API endpoint schemas.
  5. Call the API endpoints with the bearer token and subscription key to retrieve user profile data.

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.

Applications sometimes send their own secret passwords to the browser inside the code that runs on your computer. Anyone who opens the browser's developer tools can read those secrets and use them to log in as the application. Encrypting the secrets does not help if the key to decrypt them is sent in the same file.

What is Leaked secrets?

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

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.