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.
Query · spl
`zeek_http_post_body`
method="POST"
truncated=false
body IN ("*DOCTYPE*", "*\\x00*")
| eval normalized_body=replace(body,"(?i)\\\\x(?:00|ff|fe)","")
| where match(normalized_body,"(?is)<!DOCTYPE.{0,2048}<!ENTITY")
AND match(normalized_body,"(?is)<[^>]+\s[A-Za-z_:][A-Za-z0-9_.:-]*\s*=\s*[\"'][^\"']*&(?!(?:amp|lt|gt|quot|apos);)(?:[A-Za-z_][A-Za-z0-9_.:-]*);")
| eval src=coalesce(src,'id.orig_h'),
dest=coalesce(dest,'id.resp_h'),
dest_port=coalesce(dest_port,'id.resp_p')
| stats min(_time) as firstTime
max(_time) as lastTime
values(uri) as url
max(body_bytes) as body_bytes
by uid src dest dest_port
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `php_soap_dtd_entity_reference_in_attribute_filter`
Implementation guide
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.
Analyst notes
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.