Skip to content
RCE Write-up Intermediate

Four-Way PHP Domino-Fall: Unchecked Input to Full Root Compromise

The application included a file based on an unsanitised GET parameter, allowing remote file inclusion, and also passed unsanitised input to a system command, enabling command injection. An attacker could chain these to execute arbitrary commands and escalate to root by writing a setuid binary.

medium.com

Published on medium.com

A single, seemingly innocent HTTP endpoint can form a critical business-impact chain when multiple structural PHP weaknesses are stitched together. This write-up details a four-stage architectural exploit chain — progressing from unchecked parameters to complete server takeover — followed by a production-ready…

Xia0checkmate, 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 application concatenated user input directly into file include and system command calls without validation or escaping.

Impact

An attacker could achieve full root compromise, leading to data exfiltration and compliance failure.

What the attacker needed

Allow_url_include enabled; web server user has write access to /usr/local/bin/

The fix

The application should validate and sanitise all user input, use allow-lists for file inclusion, escape command arguments, and apply least-privilege principles to the web server user.

How it was found

  1. Send a request to download.php with a template parameter pointing to an external URL hosting a malicious payload.
  2. The remote file is included and executed in the application context.
  3. Use the command injection in system/exec.php to run arbitrary OS commands as the web-server user.
  4. Write a setuid binary to /usr/local/bin/ to escalate privileges to root.

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 users choose which file to load by putting a file path in the web address. Because it did not check the path, an attacker could make the server load a file from their own computer, which then ran harmful code. Separately, another part of the site passed user input directly to a system command, letting an attacker run their own commands 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.

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.