Skip to content

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

fix(rules): match dd disk fills that put of= before if= (#1030)

Rudy Mizrahi Celeklibf9fc4ca7b6b
diff --git a/rules/resource-consumption/disk-fill-attempt.rule.yaml b/rules/resource-consumption/disk-fill-attempt.rule.yaml
index 659e6371..b92d50cf 100644
--- a/rules/resource-consumption/disk-fill-attempt.rule.yaml
+++ b/rules/resource-consumption/disk-fill-attempt.rule.yaml
@@ -1,11 +1,12 @@
id: disk-fill-attempt
-version: 1
+version: 2
title: Disk-fill primitive executed in a command
description: >
A command.executed event invokes a disk-fill primitive: writing an unbounded
- stream of /dev/zero or /dev/urandom to a real file via dd, fallocate/truncate
- with a large or unbounded size, yes piped to a file, or a write to a top-level
- mount point (/tmp, /var). A disk-fill attack is a resource-DoS primitive
+ stream of /dev/zero or /dev/urandom to a real file via dd (if= and of= in either
+ order), fallocate/truncate with a large or unbounded size, yes piped to a file, or
+ a write to a top-level mount point (/tmp, /var). A disk-fill attack is a
+ resource-DoS primitive
(OWASP LLM10) that exhausts filesystem capacity and is rarely a legitimate
agent action. The rule is anchored to a command boundary and only matches
the dangerous shapes (dd to a real target file, large fallocate, yes to a
@@ -21,6 +22,7 @@ taxonomy:
match: >
e.event.action == "command.executed" && (
e.command.command.matches("(?i)\\bdd\\b[^;&|]*\\bif\\s*=\\s*/dev/(zero|urandom)\\b[^;&|]*\\bof\\s*=\\s*[^\\s;&|]+") ||
+ e.command.command.matches("(?i)\\bdd\\b[^;&|]*\\bof\\s*=\\s*[^\\s;&|]+[^;&|]*\\bif\\s*=\\s*/dev/(zero|urandom)\\b") ||
e.command.command.matches("(?i)\\b(fallocate|truncate)\\b\\s+(-[ls]\\s+([0-9]+[KMGTP]|[0-9]+M|[0-9]+G)|--size\\s+[0-9]+[KMGTP])\\s+") ||
e.command.command.matches("(?i)\\byes\\b[^;&|]*>\\s*\\S+") ||
e.command.command.matches("(?i)>\\s*/(tmp|var)\\b")
@@ -65,6 +67,18 @@ tests:
event: { action: command.executed }
command: { command: "yes 'fill' > /tmp/flood" }
session: { id: s1 }
+ - name: dd_of_before_if
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "dd of=/srv/fill bs=1M if=/dev/zero" }
+ session: { id: s1 }
+ - name: dd_copy_real_file_of_first
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "dd of=/srv/passwd_copy if=/etc/passwd" }
+ session: { id: s1 }
- name: dd_copy_real_file_safe
verdict: no_match
events: