T1051 Elastic Security · Elastic

Detect Shared Webroot in Elastic Security

Adversaries may add malicious content to an internally accessible website through an open network file share that contains the website's webroot or web content directory. By writing a malicious script (PHP, ASPX, JSP, etc.) to the shared webroot and then browsing to it, the adversary causes the web server process to execute the content — typically resulting in a webshell. This technique enables lateral movement to the system running the web server, as the code runs under the web server process context (IIS, Apache, nginx) which may have local system or administrative privileges. The attack chain: (1) discover open share pointing to webroot, (2) write malicious web script via SMB, (3) trigger execution via HTTP request. This technique has been deprecated by MITRE but the underlying behavior remains operationally relevant as a webshell deployment vector.

MITRE ATT&CK

Tactic
Lateral Movement
Canonical reference
https://attack.mitre.org/techniques/T1051/

Elastic Detection Query

Elastic Security (Elastic)
eql
any where
  (
    event.category == "file" and
    event.type in ("creation", "change") and
    file.path : (
      "*\\inetpub\\wwwroot\\*", "*\\xampp\\htdocs\\*", "*\\wamp\\www\\*",
      "*\\wamp64\\www\\*", "*\\Apache24\\htdocs\\*", "*\\nginx\\html\\*",
      "*\\tomcat\\webapps\\*", "*\\jetty\\webapps\\*", "*\\www\\html\\*",
      "*\\web\\wwwroot\\*", "*/var/www/html/*", "*/srv/www/*",
      "*/usr/share/nginx/html/*", "*/opt/tomcat/webapps/*"
    ) and
    file.name : (
      "*.php", "*.php5", "*.php7", "*.phtml", "*.asp", "*.aspx",
      "*.ashx", "*.asmx", "*.jsp", "*.jspx", "*.cfm", "*.cfml",
      "*.pl", "*.cgi", "*.shtml"
    ) and
    not process.name : (
      "w3wp.exe", "httpd.exe", "httpd2.exe", "nginx.exe", "msiexec.exe",
      "TrustedInstaller.exe", "MicrosoftEdgeUpdate.exe"
    )
  )
  or
  (
    event.category == "process" and
    event.type == "start" and
    process.parent.name : (
      "w3wp.exe", "httpd.exe", "httpd2.exe", "nginx.exe", "php.exe",
      "php-cgi.exe", "php-win.exe", "tomcat.exe", "tomcat9.exe",
      "java.exe", "iisexpress.exe", "UMWorkerProcess.exe"
    ) and
    process.name : (
      "cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe",
      "mshta.exe", "net.exe", "net1.exe", "whoami.exe", "ipconfig.exe",
      "systeminfo.exe", "nltest.exe", "certutil.exe", "bitsadmin.exe",
      "rundll32.exe", "regsvr32.exe", "msiexec.exe"
    )
  )
high severity medium confidence

Two-branch EQL detection for T1051 Shared Webroot abuse. Branch 1 fires on any web script file (PHP, ASPX, JSP, etc.) written to a known webroot directory by a non-web-server process, indicating a likely SMB-based webshell drop. Branch 2 fires when a web server process (IIS w3wp, Apache httpd, nginx, Tomcat java) spawns a suspicious child such as cmd.exe, PowerShell, or reconnaissance utilities, indicating active webshell execution. Deploy against Elastic Endpoint telemetry (ECS) or Winlogbeat with Sysmon. For correlated sequence detection (file drop then execution on the same host within 1h), replace 'any where ... or ...' with a sequence by host.name with maxspan=1h pairing the file event and process event blocks.

Data Sources

Elastic Endpoint SecurityWinlogbeat + SysmonFilebeat Auditd Module (Linux)

Required Tables

logs-endpoint.events.file-*logs-endpoint.events.process-*winlogbeat-*

False Positives & Tuning

  • CI/CD deployment pipelines (Jenkins, GitHub Actions self-hosted runners) pushing PHP or ASPX application code to a shared webroot via service account — high volume, predictable paths and naming conventions; baseline deployer process names and account SIDs
  • WordPress, Drupal, or Joomla auto-update and plugin-install routines: the PHP interpreter or web server process writes updated .php files directly to the webroot as part of CMS self-update workflows
  • IIS Web Deploy (MSDeploy) and Azure DevOps release pipelines that use msdeploy.exe or Web Management Service (wmsvc.exe) to publish ASPX applications, causing file creation events in wwwroot that appear unsigned or from unexpected parent processes
  • Tomcat hot-deploy dropping new WAR-extracted JSP files into webapps/ directories as part of scheduled application refreshes, with java.exe as the initiating process
  • Legitimate developers with mapped SMB drives to dev/staging webroot shares editing PHP files directly in their IDE — the editor process writes the file from a non-web-server context
Download portable Sigma rule (.yml)

Other platforms for T1051


Testing Methodology

Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Drop PHP Webshell via SMB Network Share to Webroot

    Expected signal: Windows Security Event ID 5140: Network share \\TARGET_WEBSERVER\wwwroot accessed from source workstation. Windows Security Event ID 4624: Network logon (Type 3) to TARGET_WEBSERVER using webadmin credentials. Sysmon Event ID 11 on TARGET_WEBSERVER: FileCreate for df00tech-test-shell.php in C:\inetpub\wwwroot\, InitiatingProcess will be System (SMB kernel write). DeviceFileEvents on TARGET_WEBSERVER: FileCreated for df00tech-test-shell.php with folder path containing wwwroot.

  2. Test 2Trigger Webshell Execution via HTTP GET Request

    Expected signal: Sysmon Event ID 1 on TARGET_WEBSERVER: Process Create where ParentImage is php-cgi.exe (or w3wp.exe for ASPX), Image is cmd.exe or whoami.exe, CommandLine contains 'whoami'. DeviceProcessEvents: InitiatingProcessFileName=php-cgi.exe spawning FileName=cmd.exe. IIS access log entry for GET /df00tech-test-shell.php with query string cmd=whoami, HTTP 200 response.

  3. Test 3Drop ASPX Webshell to IIS Webroot via Local File Copy

    Expected signal: Sysmon Event ID 11: FileCreate for df00tech-test-shell.aspx in C:\inetpub\wwwroot\, InitiatingProcess=cmd.exe. DeviceFileEvents: FileCreated, FileName=df00tech-test-shell.aspx, FolderPath=C:\inetpub\wwwroot\, InitiatingProcessFileName=cmd.exe. Security Event ID 4663 if object-level SACL auditing is configured on the wwwroot directory.

  4. Test 4Enumerate Accessible Webroot Network Shares

    Expected signal: Windows Security Event ID 5140 on TARGET_WEBSERVER: Network share \\TARGET_WEBSERVER\wwwroot accessed. Windows Security Event ID 5156: Windows Filtering Platform allowed inbound connection on port 445. Sysmon Event ID 3 on attacker host: outbound network connection to TARGET_WEBSERVER:445. Windows Security Event ID 4624: Type 3 (Network) logon to TARGET_WEBSERVER.

  5. Test 5PHP File Drop Simulating CMS Plugin Install Gone Wrong

    Expected signal: Sysmon Event ID 11: FileCreate for df00tech-update.php in C:\inetpub\wwwroot\uploads\, InitiatingProcess=powershell.exe. DeviceFileEvents: FileCreated, FileName=df00tech-update.php, FolderPath=C:\inetpub\wwwroot\uploads\, InitiatingProcessFileName=powershell.exe. PowerShell ScriptBlock Log Event ID 4104 with Set-Content command writing PHP content.

Unlock Pro Content

Get the full detection package for T1051 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections