Skip to content
File upload Write-up Intermediate

From Remote Code Execution to Data Base Pwnage

A profile picture upload accepted a PHP file containing a shell payload, which executed on the server and allowed the attacker to read database credentials. The attacker then connected to the MySQL server, created an admin user, and logged into the WordPress dashboard.

medium.com

Published on medium.com

Let’s Hack the University by RCE-ing… because education should be interactive, right?

Suprit Pandurangi, 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 the file upload feature did not validate file type or content, allowing a PHP script to be stored and executed by the web server.

Impact

An attacker could execute commands on the server, access the database, and create an admin account to take over the WordPress site.

What the attacker needed

A user account; access to profile settings

The fix

The upload feature should validate file type and content, store uploads outside the web root, and disable script execution in upload directories.

How it was found

  1. Log in and go to Profile Settings.
  2. Find the profile picture upload option.
  3. Upload a PHP file containing a shell payload instead of an image.
  4. Open the stored profile image link in a new tab.
  5. Run shell commands through the uploaded file.
  6. Use the enumerated credentials to connect to the MySQL server.

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.

The website let a user upload a file as a profile picture but did not check that it was really an image. Because the server ran PHP, the uploaded file could run commands on the server, and the attacker used that to reach the database and take over the site.

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.