Skip to content
Info disclosure Write-up Intermediate

Django debug mode to RCE in Microsoft acquisition

A Django application on a Microsoft-acquired domain had debug mode enabled, so a crafted request that triggered a 500 error exposed a traceback containing credentials such as MongoDB, Redis and Azure storage URIs. The author connected to the Redis instance and notes that Redis access can be turned into remote code execution.

Syed Abuthahir Follow

Published on medium.com

{{media:0}}

Syed Abuthahir, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

This is a short account of a recon-driven find on a Django application sitting on a Microsoft acquisition domain. The researcher, Syed Abuthahir, was hunting for hosts running Django with debug mode left on. When Django runs with DEBUG = True and an unhandled exception occurs, the framework returns a technical 500 page containing the traceback, the settings that Django considers safe to show, and the local variables of each frame in the stack. That page is the feature at the centre of this write-up: it is meant to help developers during development, and it is not meant to be reachable on a public host.

Setup

The only tooling described is passive discovery and manual request manipulation:

  1. Censys (https://censys.io/) and Shodan (https://www.shodan.io/) for finding candidate hosts.
  2. A browser to open the domains returned by those searches.
  3. Burp Suite to change the HTTP method of a request.

No accounts, roles or product-specific versions are mentioned.

Finding it

The researcher ran the usual recon pass with Censys and Shodan, looking specifically for Django debug pages exposed to the internet. The queries used were:

Text
censys -  443.https.get.body: "URLconf defined"shodan -  html:"URLconf defined" 404

Opening the main domains from the results one by one, the researcher noticed that one of them redirected to a Microsoft acquisition domain. Opening the Django IP address directly returned a response that showed Django debug mode was enabled.

Syed Abuthahir
Syed Abuthahir From the original on medium.com

Exploitation

Step 1: provoke a 500 response

The debug page only renders on an unhandled exception, so the first problem was how to make the application return a 500. The researcher, a Django developer, knew that a 500 leaks sensitive information but could not trigger one through ordinary requests. After trying many approaches without success, the idea was HTTP verb tampering: change the method from GET to POST with Burp Suite and send the request to the /admin path. That produced a 500 response.

The important part is the method change on a path that normally expects a GET.

Step 2: read the traceback

With the debug page in hand, the researcher read the traceback for sensitive information. Django hides some settings values behind asterisks, but other credentials were shown in clear, including a MongoDB URI, a Redis URI and an Azure storage queue URI.

Step 3: use the leaked connection strings

  1. MongoDB: the researcher connected to the MongoDB instance using the leaked URI. The connection succeeded, but the database held only development dummy data and nothing sensitive.
  2. Redis: the researcher connected to the Redis cache using the leaked URI, and the connection succeeded.

From prior reading on Redis exploitation, the researcher notes that access to a Redis server can be turned into remote code execution by writing crontab files to obtain a reverse connection. The reference given for that technique is https://medium.com/@knownsec404team/rce-exploits-of-redis-based-on-master-slave-replication-ef7a664ce1d0. The write-up stops at confirmed access; it does not show a crontab write, a reverse shell or any command executed on the host.

Root cause

Two mistakes combine here. The first is configuration: the Django application was deployed with debug mode enabled, so unhandled exceptions returned the full technical error page to anyone on the internet. The verb tampering on /admin is only the trigger; the disclosure comes from the debug page itself. Why the unexpected POST raised an unhandled exception rather than a handled 4xx is not explained in the report.

Impact

The direct impact is information disclosure: anyone who can provoke an exception on the host can read the traceback, the application's configuration and the credentials that Django does not mask. In this case the leaked URIs gave working access to a MongoDB database and a Redis cache. The MongoDB instance contained only development dummy data. Redis access is described as a route to remote code execution through crontab writes, but that step was not carried out here. The report does not state what the Azure storage queue URI granted access to.

Fix

The issue was reported to MSRC and is fixed now.

Variants to test

  1. Search for other Django debug pages with the same body string, for example html:"URLconf defined" in Shodan or 443.https.get.body: "URLconf defined" in Censys. A positive result is a host returning the technical error page with a traceback.
  2. On a host that returns 404 for normal requests, try other HTTP verbs on existing paths, such as POST, PUT, PATCH, DELETE, OPTIONS and TRACE, and on paths like /admin. A positive result is a 500 with the debug page instead of a handled error.
  3. Try malformed input on parameters, headers and paths to provoke unhandled exceptions. A positive result is a traceback that names the framework and shows local variables.
  4. When a traceback is obtained, look for connection strings and credentials in the settings and frame variables, particularly database, cache and cloud storage URIs. A positive result is a URI that connects successfully from outside.
  5. For any Redis instance reached this way, check whether it is reachable and writable from an untrusted network, since that is the precondition for the crontab technique described in the reference.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

A security researcher was looking for websites built with a particular tool called Django that had been left in a careless state. Django is a framework, meaning a set of ready-made building blocks that programmers use to build websites quickly. When Django is in its normal, careful state, a mistake on the site shows the visitor a short, generic error message. But Django has a special setting called debug mode, meant only for programmers working on their own computer. In debug mode, a mistake produces a long, detailed page that explains exactly what went wrong, including private details about how the site is configured.

That detailed page is useful to a developer and dangerous to everyone else. The researcher found one such page on a domain belonging to a company that Microsoft had acquired. By sending an unusual kind of request, he made the site produce that detailed error page. Reading it, he found connection details for three other services the site used: a MongoDB database, a Redis cache and an Azure storage queue. He used two of those details to connect to the services directly. The database only held test data, but the Redis connection worked, and he knew from other articles that access to Redis can sometimes be turned into full control of the server. He reported it to Microsoft's bug bounty programme, and the issue was fixed.

A bug bounty programme is a scheme where a company pays people for reporting security problems responsibly instead of exploiting them. This article walks through the same steps for someone who has never done security work before.

The background: what Django debug mode is

When you visit a website, your browser sends a request to a server, and the server sends back a response. A response carries a status code, a three-digit number that tells the browser roughly what happened. You have probably seen 404, which means "page not found". A 500 means "internal server error": the server tried to handle the request and something went wrong.

Django, when it hits an error it does not know how to handle, can respond in two ways:

  1. With debug mode off, it sends a plain, generic 500 page. The visitor learns nothing.
  2. With debug mode on, it sends a technical page containing a traceback. A traceback is the list of steps the program was taking when it crashed, like the last few lines of a recipe before something burned. It also shows the values of variables at each step, and parts of the site's configuration.

Django deliberately hides some configuration values behind asterisks, but not all of them. The researcher, who works as a Django developer, knew this. The whole find rests on that one feature being reachable from the public internet.

How the site was found

Before attacking anything, a researcher does reconnaissance, usually shortened to recon: gathering information about what exists, without touching it in a harmful way. Two websites make this easy. Censys (https://censys.io/) and Shodan (https://www.shodan.io/) are search engines, but instead of indexing web pages for reading, they index internet-connected servers and record what those servers say about themselves. You can search them for a phrase that appears in a server's response.

The researcher searched both for a phrase that only appears on Django's debug error page. The queries were:

Text
censys -  443.https.get.body: "URLconf defined"shodan -  html:"URLconf defined" 404

Line by line, in plain words:

  • censys - is just a label saying the next part is the Censys query.
  • 443.https.get.body: "URLconf defined" asks Censys for servers where, on port 443 (the standard port for secure HTTPS traffic), the body of the page returned to a normal GET request contains the exact phrase URLconf defined.
  • shodan - is the label for the Shodan query.
  • html:"URLconf defined" 404 asks Shodan for pages whose HTML contains the same phrase and which returned a 404 status.

A GET request is the ordinary kind of request your browser makes when you type an address or click a link. It means "give me this page".

Opening the main domains from the results one by one, the researcher noticed that one of them redirected to a Microsoft acquisition domain. Opening the Django server's address directly showed that Django debug mode was enabled.

Syed Abuthahir
Syed Abuthahir From the original on medium.com

The image shows the author of the write-up, Syed Abuthahir, whose Medium profile heads the article.

Step 1: making the site show its error page

The detailed page only appears when the site hits an error it cannot handle. So the first problem was how to cause a 500. The researcher tried many ordinary approaches and none worked. The idea that finally did was HTTP verb tampering.

A verb, in this context, is the word at the start of a request that says what kind of action you want. GET means "give me this page". POST means "here is some data, please process it", and it is what a login form uses when you press submit. A website is built expecting certain verbs on certain addresses. Verb tampering means sending a verb the site did not expect.

To do this, the researcher used Burp Suite, a tool that sits between your browser and a website and lets you look at and edit each request before it is sent. He changed the request from GET to POST and sent it to the /admin path, the address normally used for the site's administration area. That produced a 500 response.

Line by line:

  • POST is the verb: instead of asking for the page, the request claims to be submitting data.
  • /admin is the path being requested, the administration area of the site.
  • HTTP/1.1 states the version of the protocol being spoken, the common language browsers and servers use to exchange requests and responses.

The important part is the change of verb on a path that normally expects a GET. The report does not explain why the unexpected POST raised an unhandled error rather than a handled one.

Step 2: reading the traceback

With the debug page in hand, the researcher read the traceback looking for sensitive information. Django hides some configuration values behind asterisks, but other credentials were shown in clear, including a MongoDB URI, a Redis URI and an Azure storage queue URI.

A URI (uniform resource identifier) is an address for a resource, and in this case it is effectively a connection string: an address plus the username and password needed to reach a service. Think of it as a full set of directions to a locked building, with the key taped to the door. The three services named are:

  • MongoDB: a database, a place where a website stores its data in an organised way.
  • Redis: an in-memory cache, a very fast temporary store used to speed up a site by keeping frequently needed data close at hand.
  • Azure storage queue: a message queue in Microsoft's cloud, a holding area where one part of a system leaves messages for another part to pick up later.

Step 3: using the leaked connection strings

  1. MongoDB: the researcher connected to the MongoDB instance using the leaked URI. The connection succeeded, but the database held only development dummy data, meaning test data left over from building the site, with nothing sensitive in it.
  2. Redis: the researcher connected to the Redis cache using the leaked URI, and the connection succeeded.

From earlier reading on Redis exploitation, the researcher notes that access to a Redis server can be turned into remote code execution by writing crontab files to obtain a reverse connection. Remote code execution means running your own commands on someone else's machine. A crontab is a schedule file on a Linux system that says which programs should run automatically and when. A reverse connection is when the compromised machine reaches out to the attacker instead of the attacker reaching in, which often slips past network defences.

The reference given for that technique is https://medium.com/@knownsec404team/rce-exploits-of-redis-based-on-master-slave-replication-ef7a664ce1d0. The write-up stops at confirmed access: it does not show a crontab write, a reverse shell or any command executed on the host.

Why it worked

Two mistakes combine here. The first is configuration: the Django application was deployed with debug mode enabled, so unhandled errors returned the full technical page to anyone on the internet. The verb tampering on /admin is only the trigger; the disclosure comes from the debug page itself.

What the impact was

The direct impact is information disclosure: anyone who can provoke an error on the server can read the traceback, the site's configuration and the credentials Django does not mask. In this case the leaked URIs gave working access to a MongoDB database and a Redis cache. The MongoDB instance contained only development dummy data. Redis access is described as a route to remote code execution through crontab writes, but that step was not carried out here.

The fix

The issue was reported to MSRC, Microsoft's Security Response Center, the team that handles security reports for Microsoft. It is fixed now.

Things to try yourself

  1. Search for other Django debug pages with the same body string, for example html:"URLconf defined" in Shodan or 443.https.get.body: "URLconf defined" in Censys. A positive result is a server returning the technical error page with a traceback.
  2. On a server that returns 404 for normal requests, try other verbs on existing paths, such as POST, PUT, PATCH, DELETE, OPTIONS and TRACE, and on paths like /admin. A positive result is a 500 with the debug page instead of a handled error.
  3. Try malformed input on parameters, headers and paths to provoke unhandled errors. A positive result is a traceback that names the framework and shows local variables.
  4. When you get a traceback, look for connection strings and credentials in the settings and in the variables shown, particularly database, cache and cloud storage URIs. A positive result is a URI that connects successfully from outside.
  5. For any Redis instance reached this way, check whether it is reachable and writable from an untrusted network, since that is the precondition for the crontab technique described in the reference.

Glossary

  • Bug bounty programme: a scheme where a company rewards people for reporting security problems responsibly.
  • Cache: a fast temporary store that keeps frequently used data close at hand to speed a site up.
  • Censys: a search engine that indexes internet-connected servers and what they report about themselves.
  • Connection string: an address plus the credentials needed to reach a service, usually written as a URI.
  • Crontab: a Linux schedule file listing programs to run automatically at set times.
  • Debug mode: a Django setting that shows detailed technical error pages, meant for development only.
  • Django: a framework, a set of building blocks, for building websites in the Python language.
  • GET: the ordinary request verb meaning "give me this page".
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTP verb: the word at the start of a request saying what action is wanted, such as GET or POST.
  • Information disclosure: a flaw where private information is revealed to someone who should not see it.
  • MongoDB: a database, an organised store for a website's data.
  • MSRC: Microsoft Security Response Center, the team that handles Microsoft security reports.
  • Path: the part of a web address after the domain, such as /admin.
  • POST: a request verb meaning "here is data, please process it".
  • Recon (reconnaissance): gathering information about what exists before doing anything else.
  • Redis: a fast in-memory store often used as a cache.
  • Remote code execution (RCE): running your own commands on someone else's machine.
  • Reverse connection: when a compromised machine reaches out to the attacker rather than the other way round.
  • Shodan: a search engine that indexes internet-connected servers and their responses.
  • Status code: a three-digit number in a response saying roughly what happened, such as 404 or 500.
  • Traceback: the list of steps a program was taking when it crashed, with variable values.
  • URI: an address for a resource; here, a connection string including credentials.
  • URLconf: Django's name for the file mapping web addresses to the code that handles them.
  • Verb tampering: sending an HTTP verb a site did not expect on a given path.

More from Microsoft

View all

The newest disclosed reports for this program.

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.