Potential API Call via ROP Cleanup Gadget
Description
Identifies Windows Native API calls where ROP cleanup gadgets are present in trailing bytes, and the call originates from an unusual or undetermined Microsoft-signed module. This behavior may indicate post-execution ROP cleanup after in-memory code execution or stealthy memory manipulation. The detection focuses on ROP teardown patterns, differentiating them from standard compiler epilogues.
Query · eql
api where process.Ext.api.behaviors == "image_rop" and process.Ext.api.behaviors == "proxy_call" and
process.Ext.api.name in ("VirtualAlloc", "VirtualProtect", "WriteProcessMemory", "SetThreadContext", "SuspendThread", "VirtualProtectEx") and
not process.thread.Ext.call_stack_final_user_module.name in ("Kernel", "Unbacked") and
process.thread.Ext.call_stack_summary like "ntdll.dll|kernelbase.dll|*" and process.thread.Ext.call_stack_final_user_module.name == "Undetermined" and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.callsite_trailing_bytes regex """5[8-9a-f]c3.+""")