Detection: Ruby Repeated Legacy Sharp S Bytes in POST Body

Description

This analytic finds a run of at least 21 escaped single-byte sharp S characters in an HTTP POST body. Case conversion of this input in affected Ruby versions can overflow a heap buffer. Review the target's Ruby version, request handling, and nearby worker or process activity.

 1`zeek_http_post_body`
 2method="POST"
 3body="*xdf*"
 4body_bytes>=21
 5
 6
 7| where match(body,"([\\\\]xdf){21,}")
 8
 9
10| eval src=coalesce(src,'id.orig_h'),
11       dest=coalesce(dest,'id.resp_h'),
12       dest_port=coalesce(dest_port,'id.resp_p')
13
14
15| stats min(_time) as firstTime
16        max(_time) as lastTime
17        values(uri) as url
18        max(body_bytes) as body_bytes
19        by uid src dest dest_port
20
21
22| `security_content_ctime(firstTime)`
23
24| `security_content_ctime(lastTime)`
25
26| `ruby_repeated_legacy_sharp_s_bytes_in_post_body_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
zeek_http_post_body sourcetype="zeek:http_post_body:json"
ruby_repeated_legacy_sharp_s_bytes_in_post_body_filter search *
ruby_repeated_legacy_sharp_s_bytes_in_post_body_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 described in the Zeek HTTP POST Body data source and forward http_post_body.log. This script is not included with ESCU or the TA for Zeek. Set KV_MODE=json for its sourcetype and configure the zeek_http_post_body macro for the correct index and sourcetype. Confirm that the parsed body field retains escaped non-UTF-8 bytes as \xdf, and that method, body_bytes, uid, uri, id.orig_h, id.resp_h, and id.resp_p are extracted. The sensor must see plaintext HTTP. Limit captured bodies and review their retention policy because they may contain sensitive values. Investigate matches on servers running affected Ruby versions, especially if the request is followed by a worker crash or shell execution. Tune the 21-byte threshold if legitimate legacy-encoded content is common.

Known False Positives

Applications that accept long runs of legacy-encoded sharp S characters can match without being vulnerable. Confirm the Ruby version and whether the input reaches case conversion.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
Repeated legacy sharp S bytes were sent from $src$ to $dest$ in an HTTP POST body. 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