File with Suspicious Double Extension Created by Web Server

This rule detects when a web server process creates a file with a double extension, where the real extension is a non-web extension. This is a common technique used by attackers to bypass security measures and to hide the true nature of the file.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/09/07"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2026/09/07"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule detects when a web server process creates a file with a double extension, where the
 11real extension is a non-web extension. This is a common technique used by attackers to bypass security
 12measures and to hide the true nature of the file.
 13"""
 14from = "now-9m"
 15index = ["logs-endpoint.events.file*"]
 16language = "eql"
 17license = "Elastic License v2"
 18name = "File with Suspicious Double Extension Created by Web Server"
 19note = """## Triage and analysis
 20
 21> **Disclaimer**:
 22> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 23
 24### Investigating File with Suspicious Double Extension Created by Web Server
 25
 26This rule identifies Linux web server processes creating files whose names combine a web-executable suffix with a misleading image, archive, script, or binary extension, a pattern often used to conceal malicious content and bypass upload controls. For example, an attacker exploiting an upload endpoint may write `shell.php.jpg` into a served directory, then rely on a permissive or manipulated server configuration to execute it as a web shell for persistent remote access.
 27
 28### Possible investigation steps
 29
 30- Record the file’s full path, ownership, permissions, timestamps, cryptographic hash, MIME type, and magic bytes, then safely inspect its contents for obfuscated code, command execution, credential theft, or web-shell functionality.
 31- Review virtual-host, handler, rewrite, and directory configuration to determine whether the file is web-accessible or interpreted as executable content despite its final extension.
 32- Correlate the creation time with HTTP access, application, proxy, and authentication logs to identify the originating request, source address, user session, upload endpoint, and related reconnaissance or exploitation attempts.
 33- Examine the creating process lineage and subsequent activity for spawned shells, interpreters, system utilities, outbound connections, privilege escalation, persistence changes, or additional file writes.
 34- Hunt across endpoints and web logs for the file hash, naming pattern, source address, request indicators, and similar artifacts, and isolate the server while preserving evidence if malicious activity is confirmed.
 35
 36### False positive analysis
 37
 38- A legitimate upload or content-management workflow may preserve a user-supplied filename such as `template.php.jpg`; verify the associated HTTP request, authenticated user, expected upload path, file MIME type, and application behavior.
 39- A deployment, backup, or testing process run through a web application may generate files such as `page.jsp.zip` or `handler.cgi.sh`; verify the change record, process lineage, file contents, ownership, and whether the destination is expected and non-executable.
 40
 41### Response and remediation
 42
 43- Isolate the affected web server from untrusted networks, restrict administrative access, preserve the suspicious file and relevant logs, and block identified source addresses, hashes, domains, and URLs.
 44- Remove the double-extension file and any related web shells, unauthorized accounts, SSH keys, cron jobs, systemd units, startup scripts, modified web-server handlers, and attacker-created files after preserving forensic copies.
 45- Rotate exposed application, database, service-account, API, and administrative credentials, revoke active sessions and tokens, and replace potentially compromised TLS or SSH keys.
 46- Escalate immediately to incident response if the web server spawned shells, made suspicious outbound connections, accessed credentials, gained elevated privileges, or produced evidence of lateral movement or additional compromised hosts.
 47- Rebuild the server from a known-good image or restore verified clean application content and configuration, patch the exploited web application or server component, and validate integrity before returning it to service.
 48- Prevent recurrence by enforcing upload allowlists and content validation, storing uploads outside executable web roots, disabling script execution in upload directories, applying least-privilege permissions, and monitoring for similar filenames and web-process child activity.
 49"""
 50risk_score = 73
 51rule_id = "5fc7e978-4fa0-47e9-a8e0-bad853c8d09b"
 52setup = """## Setup
 53
 54This rule requires data coming in from Elastic Defend.
 55
 56### Elastic Defend Integration Setup
 57Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 58
 59#### Prerequisite Requirements:
 60- Fleet is required for Elastic Defend.
 61- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 62
 63#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 64- Go to the Kibana home page and click "Add integrations".
 65- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 66- Click "Add Elastic Defend".
 67- Configure the integration name and optionally add a description.
 68- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 69- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 70- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 71- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
 72For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 73- Click "Save and Continue".
 74- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
 75For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 76"""
 77severity = "high"
 78tags = [
 79    "Domain: Endpoint",
 80    "OS: Linux",
 81    "Use Case: Threat Detection",
 82    "Use Case: Vulnerability",
 83    "Tactic: Persistence",
 84    "Tactic: Initial Access",
 85    "Tactic: Lateral Movement",
 86    "Data Source: Elastic Defend",
 87    "Rule Type: Event Correlation (EQL)",
 88    "Resources: Investigation Guide"
 89]
 90timestamp_override = "event.ingested"
 91type = "eql"
 92query = '''
 93file where host.os.type == "linux" and event.action != "deletion" and
 94(
 95  process.name in (
 96    "nginx", "apache2", "httpd", "caddy", "lighttpd", "httpd.worker", "httpd-worker", "httpd-prefork",
 97    "php-cgi", "php-fcgi", "php-cgi.cagefs", "frankenphp", "lshttpd", "litespeed", "openlitespeed",
 98    "fcgiwrap", "uwsgi", "daphne", "uvicorn", "hypercorn", "granian", "waitress-serve", "flask", "puma",
 99    "unicorn", "unicorn_rails", "thin", "rackup", "mongrel_rails", "starman", "plackup", "twiggy",
100    "hypnotoad", "starlet", "unitd", "unitd-debug", "java", "node", "nodejs", "varnishd"
101  ) or
102  process.name like (
103    "php-fpm*", "lsphp*", "gunicorn*", "*.cgi", "*.fcgi", "mono*", "xsp*", "mod-mono-server*",
104    "fastcgi-mono-server*", "python*", "ruby*", "perl*", "lua*"
105  )
106) and
107file.name like~ (
108  "*.php.*", "*.php3.*", "*.php4.*", "*.php5.*", "*.php7.*", "*.php8.*", "*.phtml.*", "*.pht.*",
109  "*.asp.*", "*.aspx.*", "*.ashx.*", "*.asmx.*", "*.jsp.*", "*.jspx.*", "*.cfm.*", "*.cfc.*",
110  "*.cshtml.*", "*.razor.*", "*.cgi.*", "*.fcgi.*", "*.php;*", "*.asp;*", "*.aspx;*", "*.jsp;*"
111) and
112file.extension in~ (
113  "jpg", "jpeg", "png", "gif", "webp", "bmp", "ico", "tif", "tiff", "svg", "zip",
114  "sh", "elf"
115)
116'''
117
118[[rule.threat]]
119framework = "MITRE ATT&CK"
120
121  [rule.threat.tactic]
122  name = "Persistence"
123  id = "TA0003"
124  reference = "https://attack.mitre.org/tactics/TA0003/"
125
126  [[rule.threat.technique]]
127  id = "T1505"
128  name = "Server Software Component"
129  reference = "https://attack.mitre.org/techniques/T1505/"
130
131    [[rule.threat.technique.subtechnique]]
132    id = "T1505.003"
133    name = "Web Shell"
134    reference = "https://attack.mitre.org/techniques/T1505/003/"
135
136[[rule.threat]]
137framework = "MITRE ATT&CK"
138
139  [rule.threat.tactic]
140  name = "Initial Access"
141  id = "TA0001"
142  reference = "https://attack.mitre.org/tactics/TA0001/"
143
144  [[rule.threat.technique]]
145  name = "Exploit Public-Facing Application"
146  id = "T1190"
147  reference = "https://attack.mitre.org/techniques/T1190/"
148
149[[rule.threat]]
150framework = "MITRE ATT&CK"
151
152  [[rule.threat.technique]]
153  id = "T1210"
154  name = "Exploitation of Remote Services"
155  reference = "https://attack.mitre.org/techniques/T1210/"
156
157  [rule.threat.tactic]
158  id = "TA0008"
159  name = "Lateral Movement"
160  reference = "https://attack.mitre.org/tactics/TA0008/"

Triage and analysis

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

Investigating File with Suspicious Double Extension Created by Web Server

This rule identifies Linux web server processes creating files whose names combine a web-executable suffix with a misleading image, archive, script, or binary extension, a pattern often used to conceal malicious content and bypass upload controls. For example, an attacker exploiting an upload endpoint may write shell.php.jpg into a served directory, then rely on a permissive or manipulated server configuration to execute it as a web shell for persistent remote access.

Possible investigation steps

  • Record the file’s full path, ownership, permissions, timestamps, cryptographic hash, MIME type, and magic bytes, then safely inspect its contents for obfuscated code, command execution, credential theft, or web-shell functionality.
  • Review virtual-host, handler, rewrite, and directory configuration to determine whether the file is web-accessible or interpreted as executable content despite its final extension.
  • Correlate the creation time with HTTP access, application, proxy, and authentication logs to identify the originating request, source address, user session, upload endpoint, and related reconnaissance or exploitation attempts.
  • Examine the creating process lineage and subsequent activity for spawned shells, interpreters, system utilities, outbound connections, privilege escalation, persistence changes, or additional file writes.
  • Hunt across endpoints and web logs for the file hash, naming pattern, source address, request indicators, and similar artifacts, and isolate the server while preserving evidence if malicious activity is confirmed.

False positive analysis

  • A legitimate upload or content-management workflow may preserve a user-supplied filename such as template.php.jpg; verify the associated HTTP request, authenticated user, expected upload path, file MIME type, and application behavior.
  • A deployment, backup, or testing process run through a web application may generate files such as page.jsp.zip or handler.cgi.sh; verify the change record, process lineage, file contents, ownership, and whether the destination is expected and non-executable.

Response and remediation

  • Isolate the affected web server from untrusted networks, restrict administrative access, preserve the suspicious file and relevant logs, and block identified source addresses, hashes, domains, and URLs.
  • Remove the double-extension file and any related web shells, unauthorized accounts, SSH keys, cron jobs, systemd units, startup scripts, modified web-server handlers, and attacker-created files after preserving forensic copies.
  • Rotate exposed application, database, service-account, API, and administrative credentials, revoke active sessions and tokens, and replace potentially compromised TLS or SSH keys.
  • Escalate immediately to incident response if the web server spawned shells, made suspicious outbound connections, accessed credentials, gained elevated privileges, or produced evidence of lateral movement or additional compromised hosts.
  • Rebuild the server from a known-good image or restore verified clean application content and configuration, patch the exploited web application or server component, and validate integrity before returning it to service.
  • Prevent recurrence by enforcing upload allowlists and content validation, storing uploads outside executable web roots, disabling script execution in upload directories, applying least-privilege permissions, and monitoring for similar filenames and web-process child activity.

Related rules

to-top