Skip to content
RCE Write-up Intermediate

Chain the bugs to pwn an organisation LFI unrestricted file upload to RCE

An image server had a local file inclusion endpoint that let an attacker read server files, and a profile photo upload feature had an extension parameter with weak validation that allowed uploading a Perl reverse shell. By combining the two, the attacker executed the uploaded file through the LFI and obtained a reverse shell.

Armaan Pathan Follow

Published on medium.com

Hi everyone, After completing my OSCP certification I thought to give a try to bug bounty, as OSCP has sharpened my exploitationSkills.

Armaan Pathan, 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 LFI endpoint did not restrict which files could be included, and the upload feature validated the file extension via a tamperable parameter instead of enforcing a strict allowlist.

Impact

An attacker could read local server files and, by chaining the LFI with the unrestricted upload, execute code and obtain a reverse shell on the server.

What the attacker needed

Access to the image server; profile photo upload feature; attacker-controlled public IP

How it was found

  1. Enumerate the application and find an image server domain.
  2. Discover an endpoint that allows calling local server files.
  3. Find the profile photo upload feature that stores images on the image server.
  4. Tamper with the extension parameter to upload a Perl reverse shell.
  5. Use the LFI to call the uploaded file and receive a 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 local file inclusion (LFI) bug lets an attacker make the server read files it should not, like system password files. Separately, the photo upload feature trusted a value that said what file type was allowed, so the attacker could upload a script instead of an image. By using the LFI to run that uploaded script, the attacker got a remote shell on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Armaan Pathan

View all

9 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.