Skip to content
RCE Write-up Intermediate

PHP disable_functions Bypass via proc_open(): From Web Shell to Cross-Account Data Exposure

A SQL injection in a login form led to admin panel access, where an unrestricted file upload allowed uploading a PHP web shell. The shell's command execution was limited by disabled PHP functions, but proc_open was still enabled, allowing full command execution and reading of another user's Laravel log file that contained database credentials.

Mahmoud El Manzalawy Follow

Published on is4curity.medium.com

Hello folks, I’m Mahmoud El manzalawy, penetration tester and bug bounty hunter

Mahmoud El Manzalawy, on is4curity.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 multiple issues: unsanitised input in the login query, missing file type validation on upload, and an incomplete disable_functions list that omitted proc_open.

Impact

An attacker could execute system commands, read files belonging to other accounts on the shared server, and obtain database credentials, potentially exposing other websites' data.

What the attacker needed

Access to the login page; ability to upload files via admin panel; shared hosting with multiple accounts

How it was found

  1. Enter a single quote in the email field and observe a database error.
  2. Use SQLmap to extract data, then brute-force the password hash to log in as admin.
  3. Upload a PHP file through the image upload feature in the rich text editor.
  4. Access the uploaded PHP file in the browser to run code.
  5. Check disable_functions and open_basedir, then use proc_open to run system commands.
  6. Search for world-readable files and read another user's Laravel log to obtain database credentials.

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 login page put user input directly into a database query, so a special character caused an error that revealed the injection point. After logging in as admin, the image upload accepted a PHP script, which the server then ran as code. Even though many dangerous PHP functions were turned off, one called proc_open was left on, letting the attacker run system commands and read another user's log file that held database passwords.

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 Mahmoud El Manzalawy

View all

1 more disclosed report, 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.