Sacrificial CoW: Breaking Linux EDR’s File-Backed Memory Assumption

Many of the stealthy Linux reflective loaders used in implants today have a predictable failure point: reliance on anonymous executable memory.

The dynamically allocated anonymous executable memory is what the attacker usually needs to remain stealthy. The common pattern goes something like this:

  • Ship a reflective loader in the implant
  • Send a staged capability in the form of a beacon object file (BOF) over the network to keep the payload off disk
  • Allocate anonymous mapping
  • Set correct execution permissions
  • Relocate and execute the BOF.

Most evasion and situational awareness flows revolve around the detection of the TTPs launching execution from anonymous allocation (e.g. memfd, ul_exec). These are well understood by the defense and mostly detected by telemetry via operating on the anonymous memory segment.

However, if an attacker needs the dynamic executable Virtual Memory Area (VMA) as a base case, and the anonymous memory is what gets her there - are there other ways dynamic exec memory allocation can be done to help the operator? The bigger question is, “What is the fundamental problem with the anonymous executable memory allocated by the loaders via Linux kernel, as viewed by the defense? Does it have to be anonymous, and can the loader bypass some of the fundamental assumptions telemetry is making on Linux endpoints today?”

This article dives deeper into the design and operation of the anonymous executable memory regions on Linux as it pertains to Linux reflective loaders via a new technique we called ‘Sacrificial CoW’. This technique allows an attacker to grab a dynamic executable memory region without marking it as anonymous, which allows implants to undermine telemetry assumptions on payload data provenance and stay under the radar of current EDRs for longer. This article also introduces ideas for detecting the Sacrificial CoW TTP.

Want the full methodology?

Get every input, every worked example, and the documentation standard your assessor will expect to see.

Download the research