Skip to content
Threat Feed
low advisory

Detection of Malicious Binfmt Configuration File Creation

Detection rule monitoring for the creation of binfmt configuration files which can be abused by threat actors to execute arbitrary code or maintain persistence on Linux systems.

The binfmt_misc kernel module in Linux is designed to allow the kernel to recognize and execute arbitrary binary formats by associating them with a specific user-space interpreter. While intended for legitimate functionality such as cross-platform execution (e.g., QEMU static binaries) or language-specific interpreters, this mechanism is a potent vector for threat actors. By creating a malicious configuration file within designated directories or directly writing to the /proc/sys/fs/binfmt_misc/register interface, an attacker can designate a malicious script or backdoor as the handler for specific file types. Whenever a file matching that format is accessed, the kernel automatically executes the attacker-controlled handler, facilitating persistence or privilege escalation. This brief details detection logic for identifying anomalous file creation events within these sensitive paths.

Impact

Successful abuse of the binfmt_misc mechanism allows threat actors to establish stealthy persistence, as the execution of the malicious handler is triggered by the kernel upon interaction with target file types. This technique can lead to arbitrary code execution with the privileges of the binfmt registration process or the kernel, potentially resulting in full system compromise, exfiltration of sensitive data, or deep-seated backdoors that survive standard reboots.

Recommendation

Deploy the provided detection logic to monitor all file creation and write operations directed at binfmt-related configuration paths.

  • Enable file system auditing (e.g., auditd, eBPF-based monitoring, or Elastic Defend) for the following directories: /etc/binfmt.d/, /run/binfmt.d/, /usr/lib/binfmt.d/, and /proc/sys/fs/binfmt_misc/.
  • Investigate any process other than systemd-binfmt that writes to these paths, as these are high-fidelity indicators of potential persistence attempts.
  • Review existing binfmt configurations in your environment to establish a baseline of legitimate handlers and remove unauthorized entries.

Immediate actions

Deploy the Sigma rule to monitor for suspicious binfmt modifications

Detection Engineering 72h

Threat Hunt

Audit existing files in /etc/binfmt.d/ and /usr/lib/binfmt.d/ for unauthorized entries

T1546 medium high confidence hunt now

Data: Filesystem contents

Detection coverage 1

Detect Binfmt Configuration File Creation

low

Detects the creation of configuration files or direct registration of handlers within binfmt directories, potentially indicating persistence attempts.

sigma tactics: persistence techniques: T1546 sources: file_event, linux

Detection queries are available on the platform. Get full rules →