Skip to content
File upload Write-up Beginner

From PNG to Shell: The Chatbot That Helped Me Hack Itself

The chatbot allowed uploading files with a .png extension but did not validate the actual content, and the server executed the file as PHP. An attacker could upload a PHP reverse shell disguised as a PNG and gain remote code execution on the server.

medium.com

Published on medium.com

My eyes widened. My hacker brain didn’t see “images.” It saw execution.

Muthu, 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

The server relied solely on the file extension for validation and stored uploads in a web-accessible directory where they were executed as PHP.

Impact

An attacker could execute arbitrary code on the server, potentially leading to full compromise.

What the attacker needed

No authentication required; Chatbot accepts file uploads

How it was found

  1. Rename a PHP reverse shell file to have a .png extension.
  2. Upload the renamed file through the chatbot's file upload feature.
  3. The server accepts the file and returns a public URL.
  4. Start a Netcat listener on the attacker's machine.
  5. Access the uploaded file's URL to trigger the reverse shell.

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.

A chatbot let people upload pictures, but it only looked at the file name ending (like .png) and not what was inside. The server then ran the file as a program, so an attacker could upload a malicious script and take control of the server.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.