Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

4.9 KB
Raw Blame
id: kernel-module-load
version: 2
title: Kernel module loaded, probed, or removed
description: >
  A kernel module was loaded (insmod), probed (modprobe), or removed
  (rmmod). Loading a kernel module from an agent session is a
  high-privilege primitive — a malicious module gains ring-0 access
  on the host, can hide processes and files (rootkit), and survives
  reboots via initramfs hooks. modprobe can also auto-resolve and
  load modules from a /etc/modprobe.d/ drop-in, which is a
  persistence primitive. rmmod is included because disabling a
  security module (e.g. apparmor, selinux, audit) is a defence-
  evasion signal. The rule is anchored on the modutils binary name
  (insmod, modprobe, rmmod, modinfo) at a command boundary, and
  excludes benign uses (kmod version, kmod list). The modprobe
  load signature requires a module-shaped basename (starts with a
  letter) or a `.ko`/`.ko.xz`/`.ko.gz` path, so read-only
  subcommands such as `--version`, `--help`, `-V`, and `-l` do not
  fire.
severity: high
status: experimental
posture: detect
taxonomy:
  beacon_category: risky-command
  owasp_llm: LLM06
  mitre_atlas: AML.T0011

match: >
  e.event.action == "command.executed" && (
    e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*insmod\\b") ||
    e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*modprobe\\b[^;&|]*(\\s-r\\b|\\s--remove\\b|\\s-[a-z]*f[a-z]*\\b|\\s+[a-zA-Z][a-zA-Z0-9_-]+\\.(ko|ko\\.xz|ko\\.gz)(\\s|$|[;&|])|\\s+[a-zA-Z][a-zA-Z0-9_-]+(\\s|$|[;&|]))") ||
    e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*rmmod\\b")
  )

emit:
  reason: "Kernel module loaded, probed, or removed (insmod / modprobe / rmmod) — rootkit or defence-evasion primitive"

tests:
  - name: insmod_explicit_module
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "sudo insmod /tmp/evil.ko" }
        session: { id: s1 }
  - name: modprobe_module
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe br_netfilter" }
        session: { id: s1 }
  - name: modprobe_remove
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "sudo modprobe -r apparmor" }
        session: { id: s1 }
  - name: rmmod
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "rmmod usb_storage" }
        session: { id: s1 }
  - name: modinfo_readonly
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "modinfo br_netfilter" }
        session: { id: s1 }
  - name: lsmod_readonly
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "lsmod" }
        session: { id: s1 }
  - name: ordinary_echo
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "echo modprobe is restricted" }
        session: { id: s1 }
  - name: modprobe_version_readonly
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe --version" }
        session: { id: s1 }
  - name: modprobe_help_readonly
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe --help" }
        session: { id: s1 }
  - name: modprobe_short_version_readonly
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe -V" }
        session: { id: s1 }
  - name: modprobe_list_readonly
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe -l" }
        session: { id: s1 }
  - name: modprobe_module_with_hyphen
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe usb-storage" }
        session: { id: s1 }
  - name: modprobe_force_module
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe -f br_netfilter" }
        session: { id: s1 }
  - name: modprobe_module_then_semicolon_command
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "sudo modprobe br_netfilter;sudo sysctl --system" }
        session: { id: s1 }
  - name: modprobe_module_then_command
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "sudo modprobe br_netfilter && echo loaded" }
        session: { id: s1 }
  - name: modprobe_module_with_parameter
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe nf_conntrack hashsize=1024" }
        session: { id: s1 }
  - name: modprobe_version_then_command
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "modprobe --version && echo ok" }
        session: { id: s1 }