title: PHP2Shell - PHP File Written to a Web Root by a Web Server or PHP Process
id: 3c8e6b29-7a1d-4f52-b0e4-1d9a7c3f5e41
status: experimental
description: |
  Detects creation of .php / .phtml / .phar files under common Linux web roots by a PHP or web server process
  or a shell/download tool, a common web shell persistence step after code execution as the web worker.
  Run this hunt on every host that ran a vulnerable PHP build while exposed, even after patching.
references:
  - https://github.com/php/php-src/security/advisories/GHSA-w8hw-w9fx-j79w
  - https://github.com/php/php-src/security/advisories/GHSA-6wmf-4rv5-p3rp
  - https://www.cisa.gov/news-events/alerts/2026/10/21/critical-vulnerabilities-php-require-immediate-patching
author: Cybaverse
date: 2026-10-26
tags:
  - attack.persistence
  - attack.t1505.003
  - cve.2026-109618
  - cve.2026-109619
logsource:
  product: linux
  category: file_event
detection:
  webroot:
    - TargetFilename|startswith:
        - '/var/www/'
        - '/srv/www/'
        - '/srv/http/'
        - '/usr/share/nginx/html/'
    - TargetFilename|contains:
        - '/public_html/'
        - '/htdocs/'
  ext:
    TargetFilename|endswith:
      - '.php'
      - '.phtml'
      - '.phar'
      - '.php5'
      - '.php7'
      - '.phps'
  writer:
    Image|endswith:
      - '/php-fpm'
      - '/php-cgi'
      - '/lsphp'
      - '/frankenphp'
      - '/httpd'
      - '/apache2'
      - '/sh'
      - '/bash'
      - '/dash'
      - '/curl'
      - '/wget'
      - '/busybox'
  writer_versioned:
    Image|contains:
      - '/php-fpm'
      - '/php8'
      - '/php7'
  condition: webroot and ext and (writer or writer_versioned)
falsepositives:
  - CMS core, plugin and theme updates performed through the web UI (for example WordPress auto-updates)
  - Template caches that compile to .php (Twig, Blade, Smarty)
level: medium
