Abusing Windows Container Isolation Framework to avoid detection by security products

Researchers demonstrated how attackers can abuse the Windows Container Isolation Framework to bypass endpoint security solutions.

Researcher Daniel Avinoam at the recent DEF CON hacking conference demonstrated how attackers can abuse the Windows Container Isolation Framework to bypass endpoint security solutions.

The expert explained that Windows OS separates the file system from each container to the host and avoids duplication of system files. To avoid duplication, each container is using a dynamically generated image, which points to the original using the reparse points.

The result is images that contain “ghost files,” which store no actual data, but link to another volume on the file system. Then the researchers attempted to use this redirection mechanism to obfuscate the file system operations and deceive security products.

“This does not escape the container from within but intentionally uses this feature while executing on the host.” reads a report published by Avinoam.

The researcher explained that mini-filter drivers were designed to simplify the I/O filtering process for developers.

The Windows Container Isolation FS (wcifs) mini-filter driver enables the file system separation between Windows containers and their host. The driver handles the ghost files redirection by parsing their attached reparse points.

The researcher discovered that this driver is loaded by default on every Windows OS starting from Windows 10. He also noticed that the driver is loaded by default, even when the “containers” option is turned off in the Windows features menu.

The researchers ran the current process inside a fabricated container and used a mini-filter to handle their I/O requests such that it can create, read, write, and delete files on the file system using kernel primitives and avoiding security product detection.

“Our driver sits at a lower altitude (189900, which can be even lower if changed manually) than security vendors’ drivers (320000 – 329999), meaning we can create, read, write, and delete files on the file system without their callbacks triggering — bingo!” continues the report.

“To combat these threats [ransomware, wiper], security vendors tend to use their own mini-filter drivers to monitor the system’s I/O activity. Algorithms based on this log source look for certain patterns to detect file system-based malware and prevent them before any irreversible damage is done. For example, a process that opens many existing files and writes to them will be classified as ransomware/wiper, depending on the data written.” continues the report. “This is where our driver comes into play. Because we can override files using the IO_REPARSE_TAG_WCI_1 reparse tag without the detection of antivirus drivers, their detection algorithm will not receive the whole picture and thus will not trigger.”

The researchers published examples of simple wiping and ransomware algorithms using the driver.

The experts pointed out that administrative permissions are required for communicating with the wcifs driver and that it is not possible to set reparse points to files without WRITE primitives, meaning system files cannot be altered. The driver must be attached to any volume it works with (source or target).

Below are the mitigation to detect malicious usage of wcifs:

  • Detect calls to DeviceIoControl + FSCTL_SET_REPARSE_POINT + IO_REPARSE_TAG_WCI_1 / and check for the IO_REPARSE_TAG_WCI_1 tag in the PRE_WRITE callback. Scan files with the tag in the PRE_CLEANUP function even if they were not altered.
  • Check if wcifs’ communication port is opened by processes that are not valid system processes.
  • Check if a container is opened where the source volume is equal to the destination volume.
  • Check if wcifs is attached by a user process and not the system, or if it is attached when the containers feature is deactivated.

The experts also published a POC tool source code on a GitHub repo.

Follow me on Twitter: @securityaffairs and Facebook and Mastodon

Pierluigi Paganini

(SecurityAffairs – hacking, Windows Container Isolation Framework)

The post Abusing Windows Container Isolation Framework to avoid detection by security products appeared first on Security Affairs.