Detection: PHP SOAP DTD Entity Reference in Attribute

Description

This analytic finds SOAP requests containing a DTD declaration and an entity reference inside an XML attribute value.

 1`zeek_http_post_body`
 2method="POST"
 3truncated=false
 4body IN ("*DOCTYPE*", "*\\x00*")
 5
 6
 7| eval normalized_body=replace(body,"(?i)\\\\x(?:00
 8|ff
 9|fe)","")
10
11
12| where match(normalized_body,"(?is)<!DOCTYPE.{0,2048}<!ENTITY")
13    AND match(normalized_body,"(?is)<[^>]+\s[A-Za-z_:][A-Za-z0-9_.:-]*\s*=\s*[\"'][^\"']*&(?!(?:amp
14|lt
15|gt
16|quot
17|apos);)(?:[A-Za-z_][A-Za-z0-9_.:-]*);")
18
19
20| eval src=coalesce(src,'id.orig_h'),
21       dest=coalesce(dest,'id.resp_h'),
22       dest_port=coalesce(dest_port,'id.resp_p')
23
24
25| stats min(_time) as firstTime
26        max(_time) as lastTime
27        values(uri) as url
28        max(body_bytes) as body_bytes
29        by uid src dest dest_port
30
31
32| `security_content_ctime(firstTime)`
33
34| `security_content_ctime(lastTime)`
35
36| `php_soap_dtd_entity_reference_in_attribute_filter`

Data Source

Name Platform Sourcetype Source
Zeek HTTP POST Body Web 'zeek:http_post_body:json' 'http_post_body.log'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
php_soap_dtd_entity_reference_in_attribute_filter search *
php_soap_dtd_entity_reference_in_attribute_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

Install the custom Zeek HTTP POST Body script from https://gist.github.com/nasbench/4cd18a938056cbfbc8a9832edb26f4c4 and forward http_post_body.log. This script is not included with ESCU or the TA for Zeek. Set KV_MODE=json for the custom sourcetype on the search head and configure zeek_http_post_body for its index and sourcetype. Confirm that body, truncated, uid, method, and the connection IP and port fields are extracted. The sensor must see plaintext HTTP traffic. Capture enough of each body to include the DTD and referencing attribute, and use only truncated=false events.

Known False Positives

SOAP integrations that intentionally permit DTDs and entity references in attributes can match. Review the endpoint and expected XML schema before alerting.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
SOAP DTD entity reference in an attribute sent from [$src$] to [$dest$]. dest system 25

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset not_applicable zeek:http_post_body:json
Integration ✅ Passing Dataset not_applicable zeek:http_post_body:json

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