CriticalCVE-2017-9841

    PHPUnit Command Injection Vulnerability (CVE-2017-9841)

    Published In CISA KEV since Sources: CVE.org, OSV

    What is affected, what to do

    Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP code via HTTP POST data beginning with a "<?php " substring, as demonstrated by an attack on a site with an exposed /vendor folder, i.e., external access to the /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php URI.

    The vulnerability is being actively exploited; treat it as a priority. Update PHPUnit Project PHPUnit to version 5.6.3. Immediate actions, mitigation and detection rules are in the runbook below.

    Affected
    • PHPUnit Project PHPUnit lte *..4.8.27
    • PHPUnit Project PHPUnit lt 5.0.0..5.6.3
    • Oracle Communications Diameter Signaling Router (DSR) lte 8.0.0..8.5.0
    Fixed in
    • PHPUnit Project PHPUnit 5.6.3

    Not sure whether and how you are affected? Ask a question about this vulnerability

    Metrics

    9.8

    Priority

    XIEM Effective CVSS: highest available CVSS rating from NVD and vendor data.

    Source: NVD, CVSS v3

    9.8

    CVSS v3

    Severity Critical on the scale from 0 to 10.

    Source: CVE.org, OSV

    —

    EPSS score

    No value is available for this vulnerability.

    Show all metrics
    Severity
    Critical
    Priority (0–325)

    The priority score is a consolidated metric that condenses several individual signals into a single, action-guiding ranking: technical severity (CVSS), exploitation likelihood (EPSS), known-exploited status (KEV) and the context of the affected asset. The aim is to answer the only truly important question in vulnerability management: what first?

    Read in glossary
    228.98 Methodology
    Exploit maturity

    An exploit is code or a technique that specifically uses a concrete vulnerability to force unintended behaviour — such as executing code or escalating privileges. It is the tool that turns a theoretical flaw into a practical attack.

    Read in glossary
    actively exploited
    XIEM Effective CVSS

    XIEM® is the tiered managed-security operating model from NEOSEC and a registered trademark of NEOSEC GmbH. It extends classic SIEM — the central collection, normalisation and correlation of security-relevant events — with endpoint forensics, network visibility and deception technology, and consolidates them into three building tiers: Sentry, Orchestrate and Command.

    Read in glossary
    9.8 Methodology
    CVSS v3

    CVSS is the globally established, open standard for assessing the technical severity of a vulnerability on a scale from 0 to 10. It describes how easily a flaw can be exploited and what damage it can cause — but not how likely its actual exploitation is. CVSS and the complementary EPSS deliberately answer different questions.

    Read in glossary
    9.8
    EPSS percentile

    The EPSS percentile is the relative position of a vulnerability within all EPSS-scored CVEs, expressed as a value between 0 and 1. A percentile of 0.90 means „this CVE has a higher EPSS score than 90 % of all other scored CVEs“. Unlike the EPSS score, it is not a probability — but a positioning within a ranking.

    Read in glossary
    99.99
    Critical — this CVE ranks in the top fifth of all CVEs scored today (rank ≥ 80%).
    KEV status

    The KEV catalogue is a list maintained by the US authority CISA of vulnerabilities for which active exploitation in the wild has been confirmed. It answers not the question „how severe?“ but „is it already being attacked?“ — thereby sharply prioritising patching.

    Read in glossary
    Actively exploited
    Published
    In CISA KEV since

    The KEV catalogue is a list maintained by the US authority CISA of vulnerabilities for which active exploitation in the wild has been confirmed. It answers not the question „how severe?“ but „is it already being attacked?“ — thereby sharply prioritising patching.

    Read in glossary
    CISA assessment (SSVC)
    Exploitation: active · automatable · Technical impact: total
    Source: CISA Vulnrichment, as of 7 February 2025
    CWE

    CWE is a catalogue of typical weakness types in software and hardware — such as flawed input validation, unsafe memory handling or poor authentication. Where a CVE names a concrete vulnerability in a concrete product, a CWE describes the underlying class of defect.

    Read in glossary
    CWE-94

    Response and mitigation

    Why act now?

    Prioritisation rationale

    This flaw is network-reachable without authentication or user interaction and yields full code execution as the web server user from a single HTTP request, which is why it consistently ranks among the CVEs most likely to be exploited and is hammered by mass scanners and botnets looking to drop webshells and cryptominers or harvest credentials from .env files. The typical victim is a PHP application (Laravel, Drupal, WordPress plugins, in-house code) deployed with dev dependencies and a web-accessible vendor/ directory. For any internet-facing PHP application where the file is present, remediation is top priority — hours, not days; if eval-stdin.php is absent from production or vendor/ is unreachable over HTTP, residual risk drops sharply, but a retrospective log review for past exploitation is still mandatory.

    1. Runbook step 1

      Immediate response (0-24 h)

      • Find exposed instances: Sweep all web servers for the vulnerable file: find / -path '*phpunit/src/Util/PHP/eval-stdin.php' 2>/dev/null. Any hit inside a web root (e.g. /var/www/html/vendor/...) is critical. Check the installed version with composer show phpunit/phpunit.
      • Patch: Upgrade PHPUnit to 4.8.28 (4.x branch) or 5.6.3 or later (5.x branch). Better still, keep PHPUnit as a dev-only dependency and redeploy production with composer install --no-dev so the file never ships.
      • Fastest fix without a redeploy: Delete eval-stdin.php — or the entire vendor/phpunit directory — from production hosts. PHPUnit serves no purpose at runtime.
      • Oracle Communications Diameter Signaling Router 8.0.0 to 8.5.0: Patch available from the vendor — look up the exact version in the Oracle advisory (Critical Patch Update); until applied, restrict HTTP access to the management interface to admin networks only.
      • Start a compromise assessment: Search access logs (at least 90 days back) for POSTs to eval-stdin.php. Treat any HTTP 200 response as a confirmed compromise: isolate, preserve evidence, and rotate every secret in .env/config files (database, API keys, cloud credentials, SMTP).
    2. Runbook step 2

      Mitigation layers

      • Web server configuration: Deny all access to vendor/. nginx: location ~* /vendor/ { deny all; return 404; }. Apache: <DirectoryMatch "/vendor/"> Require all denied </DirectoryMatch>. Long term, point the document root at a public/ subdirectory so vendor/ sits outside it.
      • WAF/IPS rule: Block any request whose URI contains eval-stdin.php, regardless of path prefix — scanners probe variants such as /laravel/vendor/..., /lib/phpunit/..., /admin/vendor/.... Also block POST bodies starting with <?php sent to PHP endpoints. Suricata example: alert http any any -> $HTTP_SERVERS any (msg:"CVE-2017-9841 PHPUnit eval-stdin"; flow:established,to_server; http.uri; content:"eval-stdin.php"; nocase; sid:1000001; rev:1;).
      • Endpoint hardening: Add system,exec,shell_exec,passthru,proc_open,popen to disable_functions in php.ini where the application tolerates it; constrain open_basedir to the app directory. Remove write permissions for the web server user on the document root to hinder webshell drops.
      • Network segmentation: Apply egress filtering on web servers so they can only reach required destinations — this breaks second-stage payload downloads (miners, bot agents) and reverse shells.
      • Build/deploy pipeline: Fail CI/CD builds whose production artefact contains phpunit; make software composition analysis (composer audit) a mandatory gate.
    3. Runbook step 3

      Detection rules

      • Web access logs: POST requests with eval-stdin.php in the URI. SPL: index=web uri_path="*eval-stdin.php*" | stats count by src_ip, uri_path, status. KQL (IIS): W3CIISLog | where csUriStem has "eval-stdin.php" | summarize count() by cIP, csUriStem, scStatus. A 200 instead of a 404 is a strong compromise indicator.
      • EDR process ancestry: php-fpm, php-cgi, httpd, apache2 or nginx spawning sh, bash, curl, wget, perl, python or base64. Sigma shape: ParentImage|endswith: ['/php-fpm*','/apache2','/httpd'] AND Image|endswith: ['/sh','/bash','/curl','/wget'].
      • Linux auditd: execve events under the web server UID (www-data, apache, nginx); rule: -a always,exit -F arch=b64 -S execve -F euid=33 -k web_exec.
      • File integrity: New or modified .php files in the web root outside deployment windows (FIM, Sysmon for Linux EID 11), especially under vendor/, uploads/ or tmp/.
      • Network telemetry (Zeek): Outbound connections from web servers to unfamiliar hosts or mining-pool ports shortly after an inbound POST to eval-stdin.php; filter http.log on uri containing eval-stdin.

    Detection rules

    No NEOSEC detection rule is available for this vulnerability yet.

    Classification under NIS2 and CRA

    Rule-based classification from exploitation status and severity. It does not replace a case-by-case assessment.

    NIS2

    NIS2 is EU Directive (EU) 2022/2555 to raise the level of cybersecurity across the Union. It substantially broadens obligations compared with the first NIS directive: more sectors, mandatory risk management, staged reporting duties and personal accountability of senior management.

    Read in glossary
    Actively exploited: treat the vulnerability as a priority in vulnerability handling under Art. 21(2)(e) NIS2. If it is exploited in your environment, check the reporting obligation under Art. 23 (early warning within 24 hours).
    CRA

    The CRA is EU Regulation (EU) 2024/2847 setting horizontal cybersecurity requirements for „products with digital elements“ — from industrial controllers and software to connected consumer devices. For the first time manufacturers must ensure security across the entire product lifecycle, handle vulnerabilities and provide security updates.

    Read in glossary
    Since 11.09.2026, manufacturers of affected products with digital elements must report actively exploited vulnerabilities under Art. 14 CRA, with an early warning within 24 hours via ENISA's single reporting platform.
    ISO/IEC 27001

    ISO/IEC 27001 is the internationally leading standard for an information security management system (ISMS). It describes a risk-based, process-oriented framework to systematically plan, implement, review and improve information security.

    Read in glossary
    Control A.8.8, management of technical vulnerabilities: assess relevance to your systems, plan remediation and keep evidence.

    Description

    Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP code via HTTP POST data beginning with a "<?php " substring, as demonstrated by an attack on a site with an exposed /vendor folder, i.e., external access to the /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php URI.

    Source: NVD (NIST), OSV (Open Source Vulnerabilities), cvelistv5, CISA KEV Catalog, CVE.org (MITRE)

    Affected products

    The following versions are affected. Older releases of the same product line are also vulnerable unless stated otherwise.

    Affected products
    Affected versionsFixed in
    oraclecommunications_diameter_signaling_router
    • 8.0.0 – ≤ 8.5.0
    • —
    phpunit_projectphpunit
    • ≤ 4.8.27
    • 5.0.0 – < 5.6.3
    • —
    • 5.6.3
    packagistphpunit/phpunit
    • 5.4.3
    • 5.2.4
    • 5.6.0
    • 5.2.9
    • 5.2.11
    • 5.1.3
    • 5.4.0
    • 5.4.5
    • 5.2.2
    • 5.1.2
    • 5.2.0
    • 5.3.0
    • 5.2.1
    • 5.3.4
    • 5.2.8
    • 5.1.0
    • 5.1.6
    • 5.4.1
    • 5.1.1
    • 5.5.4
    • 5.4.7
    • 5.5.2
    • 5.2.10
    • 5.2.6
    • 4.8.22
    • 5.3.2
    • 5.5.5
    • 5.2.3
    • 4.8.25
    • 5.3.5
    • 5.5.3
    • 5.4.8
    • 4.8.24
    • 4.8.20
    • 4.8.19
    • 5.2.12
    • 5.6.2
    • 5.4.4
    • 5.2.5
    • 4.8.23
    • 5.6.1
    • 5.5.0
    • 4.8.21
    • 5.0.10
    • 5.4.2
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —
    • —

    Vendors and products

    Weakness classes (CWE)

    • CWE-94Improper Control of Generation of Code ('Code Injection')

      Base

      The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.

      Entry at MITRE CWE-94

    Public exploit references

    Publicly reported proof-of-concepts, exploit modules and detection templates for this vulnerability. NEOSEC links to the original sources only and does not provide any exploit code.

    Public exploit references
    CISA KEV CatalogCISA Known Exploited Vulnerability (opens in a new tab)cisa.govactively exploited
    PoC-in-GitHub (nomi-sec)vulhub-phpunit-cve-2017-9841 (opens in a new tab)github.comPoC (publicly reported)reported, not verified
    PoC-in-GitHub (nomi-sec)CVE-2017-9841 (opens in a new tab)github.comPoC (publicly reported)reported, not verified
    PoC-in-GitHub (nomi-sec)CVE-2017-9841-PHPUnit-Remote-Code-Execution-RCE-PoC (opens in a new tab)github.comPoC (publicly reported)reported, not verified

    References & sources

    • NVD (NIST)vuln/detail/CVE-2017-9841advisory
    • github.comsebastianbergmann/phpunit/pull/1955web
    • github.comsebastianbergmann/phpunit/pull/1956web, x_refsource_MISC, Patch, Third-party advisory
    • github.comsebastianbergmann/phpunit/commit/284a69fb88a2d0845d23f42974a583…web, x_refsource_MISC, Patch, Third-party advisory
    • github.comsebastianbergmann/phpunit/commit/3aaddb1c5bd9b9b8d070b4cf120e71…web
    • github.comFriendsOfPHP/security-advisories/blob/master/phpunit/phpunit/CV…web
    • github.comsebastianbergmann/phpunitpackage
    • security.gentoo.orgGLSA-201711-15web, Vendor advisory, x_refsource_GENTOO, Third-party advisory
    • cisa.govknown-exploited-vulnerabilities-catalog?field_cve=CVE-2017-9841web, government-resource, US government resource
    • oracle.comsecurity-alerts/cpuoct2021.htmlweb, x_refsource_MISC, Patch, Third-party advisory
    • web.archive.orgweb/20170701212357/http://phpunit.vulnbusters.comweb
    • securityfocus.com101798web, Vulnerability database, x_refsource_BID, Broken link
    • securitytracker.com1039812web, Vulnerability database, x_refsource_SECTRACK, Broken link
    • web.archive.orgweb/20170701212357/http://phpunit.vulnbusters.comx_refsource_MISC, Third-party advisory

    Linked advisories

    Embed badge

    Show the severity and KEV status of this vulnerability on your site – with a link back here. The image is updated hourly.

    Badge preview for CVE-2017-9841
    <a href="https://intel.neosec.eu/en/cve/CVE-2017-9841"><img src="https://intel.neosec.eu/badge/cve/CVE-2017-9841.svg?lang=en" alt="CVE-2017-9841 – NEOSEC Intel" height="20"></a>