Skip to content
RCE Write-up Intermediate

Dumping Source Code And Accessing Internal Databases Via A Phpunit Vulnerability

An exposed PHPUnit eval-stdin.php file allowed arbitrary PHP code execution, but disabled functions blocked a shell. The attacker used PHP file-read and database-query payloads to dump source code, find database credentials, and access internal databases.

Aman Singh Gill Follow

Published on systemweakness.com

During routine exploration of vulnerable servers, I discovered the presence of CVE-2017–9841 on a target domain using Nuclei with the http/cves/2017/CVE-2017-9841.yaml template. The scanner flagged an exposed PHPUnit utility script under the /vendor tree.

Aman Singh Gill, on systemweakness.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 web server exposed the vendor directory containing a vulnerable PHPUnit script, and configuration files with database credentials were stored in plain text within the web root.

Impact

The attacker could read the application source code and access internal databases, potentially exposing sensitive data, though direct command execution was blocked by disabled functions.

What the attacker needed

Web-accessible vendor directory; PHPUnit before 4.8.28 or 5.x before 5.6.3; no authentication on eval-stdin.php

The fix

The vulnerable PHPUnit file was fixed in patched releases, and the report recommends removing development tooling from production, blocking web access to vendor directories, storing secrets outside the web root, and segmenting internal networks.

How it was found

  1. Scan the target with Nuclei and find the exposed PHPUnit eval-stdin.php file.
  2. Send PHP code in a POST body to the eval-stdin.php endpoint to execute it.
  3. Discover that command-execution functions are disabled via phpinfo().
  4. Use PHP payloads to list directories and read files, then download the source code.
  5. Find database credentials in configuration files within the downloaded source.
  6. Use PHP database-connection payloads from the web host to query the internal database.

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 developer tool called PHPUnit was left on a public web server, and it had a feature that let anyone run PHP code on the server. The attacker could not run system commands because they were turned off, but they could still read files and talk to databases, so they stole source code and database data.

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 Aman Singh Gill

View all

8 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.