Detection: PHP Worker Segmentation Fault After Multipart POST

Description

This analytic pairs an Apache AH00051 worker segmentation-fault notice with the most recent logged request from that child PID on the same host and Apache instance. It looks for multipart POST requests within short time frame around the crash, a pattern that can occur during PHP2Shell exploitation. Captured access event is a candidate for the associated request that leads to crash. Yet, request that kills the worker may never reach the access log.

 1(
 2    `apache_access_logs` OR `apache_error_logs`
 3)
 4(
 5    (http_content_type="multipart/form-data*" AND http_method=POST)
 6    OR error_message="*exit signal Segmentation fault*"
 7)
 8
 9
10| rex field=error_message "child\s+pid\s+(?<child_pid>\d+)"
11
12
13| rex field=_raw "client\:?\s+(?<client>.*?)(?:,
14|\]
15|$)"
16
17| rex mode=sed field=client "s/\:\d+$//g"
18
19
20| eval pid=coalesce(child_pid,process_id,pid)
21
22| eval message=coalesce(error_message,message)
23
24| eval src=coalesce(client,src,src_ip)
25
26| eval dest=coalesce(server,dest,dest_ip)
27
28| eval uri_query=coalesce(uri_query,"")
29
30| eval uri_path=coalesce(uri_path,"")
31
32| eval uri=coalesce(uri_path.uri_query,uri)
33
34
35| stats count min(_time) as firstTime last(_time) as lastTime
36    dc(source) as dc_source
37    values(source) as source
38    dc(sourcetype) as dc_sourcetype
39    values(sourcetype) as sourcetype
40    values(http_method) as http_method
41    values(src) as src
42    values(dest) as dest
43    values(dest_port) as dest_port
44    values(site) as site
45    values(uri) as uri
46    values(url) as url
47    values(status) as status
48    values(memory_bytes) as memory_bytes
49    values(http_content_length) as http_content_length
50    values(http_content_type) as http_content_type
51    values(http_referrer) as http_referrer
52    values(http_user_agent) as http_user_agent
53    values(message) as message
54    by pid host
55
56| where dc_sourcetype>1
57
58
59| `security_content_ctime(firstTime)`
60
61| `security_content_ctime(lastTime)`
62
63| `php_worker_segmentation_fault_after_multipart_post_filter`

Data Source

Name Platform Sourcetype Source
Apache Error Log Web 'apache:error' '/var/log/apache2/error.log'
Apache Access Log Web 'apache:access:combined' '/var/log/apache2/access.log'

Macros Used

Name Value
apache_error_logs (source="/var/log/apache2/error.log" OR sourcetype IN ("apache:error", "apache_error"))
php_worker_segmentation_fault_after_multipart_post_filter search *
php_worker_segmentation_fault_after_multipart_post_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

CVE

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) No
Creates Intermediate Finding (Risk Event) Yes
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

Implementation

Ingest Apache (https://splunkbase.splunk.com/app/3186) access and error logs into Splunk using their default Splunk add-ons. Follow configuration instructions (https://splunk.github.io/splunk-add-on-for-apache-web-server/Configure/) to properly set up Apache access and error log format. In addition to default log formats, enable logging of worker PID (process ID) in both access and error logs. Make sure that you configure the apache_access_logs and apache_error_logs macros with the corresponding source and sourcetype patterns for your environment.

Known False Positives

Legitimate large multipart uploads, application bugs, or load tests can cause segmentation fault errors. Review the correlated access and PHP error events before classifying this activity as exploitation.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
Apache worker [$pid$] on [$host$] crashed after a multipart POST from [$src$] to [$url$]. host system 20

Threat Objects

Field Type
src ip_address
url url

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset /var/log/apache2/error.log apache:error
Integration ✅ Passing Dataset /var/log/apache2/error.log apache:error

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 1