Skip to content
Info disclosure Write-up Intermediate

How I Leaked the Environment Variables of a Django Web App on Azu

A Django app had DEBUG mode enabled and its ALLOWED_HOSTS list only contained the custom domain, so requesting the underlying Azure Front Door hostname triggered a 500 error page that disclosed environment variables and library versions. The author used the leaked secrets to access the app's message broker.

Zain Follow

Published on medium.com

I recently conducted a security assessment and was able to leak the environment variables of a Django web app. This is a blog post explaining how I did it, and I hope you’ll learn something new.

Zain, 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 DEBUG was left enabled in production and ALLOWED_HOSTS did not include the Azure Front Door hostname, so a request to that hostname raised a DisallowedHost error whose debug page exposed settings and environment variables.

Impact

The error page disclosed environment variables and library versions, and the leaked secrets let the author access the app's message broker.

What the attacker needed

App deployed behind Azure Front Door; DEBUG left enabled; Front Door hostname resolvable via DNS

The fix

DEBUG should be set to False in public-facing apps and ALLOWED_HOSTS should be hardened to include the Front Door hostname.

How it was found

  1. Request a random path on the site and notice DEBUG mode is on and the app is Django.
  2. Try malformed requests to trigger a 500 error, but exception handling blocks it.
  3. Notice the app runs behind Azure Front Door.
  4. Resolve the site's A record to find the Front Door hostname.
  5. Send a request directly to the Front Door hostname to trigger a 500 error page.
  6. Read the leaked environment variables and library versions from the error page.

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.

Django is a framework for building websites. When a website hits an unexpected error, Django can show a detailed debug page, but only if a setting called DEBUG is turned on. Here it was on, and the site only trusted its normal domain name, so asking for the hidden cloud address behind it produced that detailed error page and spilled secrets.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.