The Debug Flag That Opened the Door: A Journey From Django Debug Mode to Critical RCE
A Django application left debug mode enabled in production, leaking filesystem paths that revealed a shared-hosting setup. A profile upload feature with weak validation stored files in a publicly accessible location, and because the server also executed PHP, an uploaded PHP file led to remote code execution.
Published on medium.com
I am an independent security researcher who enjoys learning how applications work and exploring security from different perspectives. This write-up is a small attempt to share my learning journey with the community.
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 mode was left on in production and the upload feature accepted and publicly served executable file types on a server that also processed PHP.
Impact
An attacker could upload a PHP file that the hosting environment executed, achieving remote code execution on the server.
What the attacker needed
Debug mode enabled in production; a file upload feature; server also executes PHP
The fix
Debug mode should be disabled in production and uploads should be validated and stored outside any location the web server will execute.
How it was found
- Notice the application shows a Django debug page in production.
- Read the leaked filesystem path from the debug output.
- Check whether the domain responds on the cPanel hosting panel port.
- Find a profile upload feature that accepts files with weak validation.
- Upload a PHP file and confirm it is stored in a publicly accessible location.
- Request the uploaded file and observe code execution.
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.
Debug mode is a developer setting that shows detailed error pages, including internal file paths. Here those paths hinted the site ran on a shared hosting panel, and a file upload feature let the researcher place a file where the web server would run it. Because the server also understood PHP, that file ran as code on the server, giving the attacker control of it.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.