This rule detects potential memory corruption or buffer overflow attempts where data extends beyond the expected image size, a technique often used by adversaries to execute arbitrary code or escalate privileges. Proactively hunting for this anomaly in Azure Sentinel allows the SOC to identify stealthy exploitation attempts or malformed payloads that may bypass standard integrity checks before they lead to a full system compromise.
rule IsBeyondImageSize : PECheck
{
meta:
author = "_pusher_"
date = "2016-07"
description = "Data Beyond ImageSize Check"
condition:
// MZ signature at offset 0 and ...
uint16(0) == 0x5A4D and
// ... PE signature at offset stored in MZ header at 0x3C
uint32(uint32(0x3C)) == 0x00004550 and
for any i in (0..pe.number_of_sections-1):
(
(pe.sections[i].virtual_address+pe.sections[i].virtual_size) > (uint32(uint32(0x3C)+0x50)) or
(pe.sections[i].raw_data_offset+pe.sections[i].raw_data_size) > filesize
)
}
This YARA rule can be deployed in the following contexts:
ImageSize due to dynamic heap expansion or specific loader behaviors.
ImageSize is less than 10MB and the parent process is a known application server (e.g., java.exe, dotnet.exe, w3wp.exe).ImageSize suggests, especially in complex microservices.
dotnet.exe or coreclr.exe if the parent process is a standard web server or API gateway (e.g., k8s.io, nginx.exe, iisexpress.exe).ImageSize check.
vmtoolsd.exe, vmnet.exe, crowdagent.exe, carbonblack.exe) if the parent process is a system service (services.exe) or a known agent service.ImageSize calculation.
dockerd.exe, containerd-shim.exe, kubelet.exe)