dcg

Core Filesystem

core.filesystem

Protects against recursive rm commands and equivalent filesystem destruction outside literal temp subdirectories

  • 39blocking rules
  • 39safe patterns
  • 25Critical
  • 14High

Always on. Core packs can’t be removed from evaluation, though each rule’s mode can be changed in [policy.rules].

Evaluated when a command contains rm, find, unlink, truncate, shred, tar, dd, mv, cp, ln.

Recorded verdicts

  • rm -rf ./srcBlockedcore.filesystem:rm-rf-general
  • rm -rf ~Blockedcore.filesystem:rm-rf-root-home
  • rm -rf "$BUILD_DIR/"*Blockedcore.filesystem:rm-rf-general
  • echo ssh-ed25519 AAAA... > ~/.ssh/authorized_keysBlockedcore.filesystem:credential-file-write
  • rm -r'f' ~Blockedcore.filesystem:rm-rf-root-home
  • RM -rf ~Blockedcore.filesystem:rm-rf-root-home
  • {rm,-rf,~}Blockedcore.filesystem:rm-rf-root-home
  • rm${IFS}-rf${IFS}~Blockedcore.filesystem:rm-rf-root-home
  • echo 'rm -rf ~' | bashBlockedcore.filesystem:rm-rf-root-home
  • find ~ -exec rm -rf {} +Blockedcore.filesystem:rm-rf-general
  • alias x='rm -rf ~'; xBlockedcore.filesystem:rm-rf-root-home
  • Remove-Item -Recurse -Force C:\srcBlockedcore.filesystem:powershell-remove-item-recursive

Blocking rules

Each rule ID is core.filesystem:<name>. Use it in allowlists and [policy.rules].

  1. clear-disk

    Critical

    PowerShell Clear-Disk removes a disk's partitions and data.

    Explanation
    `Clear-Disk -RemoveData` deletes all partitions and data from a disk. There is no undo. Safer alternatives: - Inspect the disk first: `Get-Disk`. - Add `-WhatIf` to preview without changing anything.
  2. cp-sensitive-then-delete

    Critical

    archive copy of a sensitive path into temp followed by forced recursive deletion is a cross-segment data-loss bypass. EXTREMELY DANGEROUS.

    Explanation
    `cp -al /etc /tmp/x && rm -rf /tmp/x` is a propagation variant of the relocate-then-delete bypass: the copy segment is allowed, and the temp delete segment is normally safe, but the compound command can destroy sensitive content or hide irreversible deletion behind a temp path. Safer alternatives: - Copy beside the original or into a named backup path and verify with `diff -r`. - Do not combine sensitive-source propagation and forced deletion in one command. - Use `rm -ri` if a derived temp tree genuinely needs manual cleanup.
  3. credential-file-write

    Critical

    writing a credential, private-key, login-shell startup, or system authentication file (`~/.ssh/*`, `~/.aws/credentials`, `~/.netrc`, `~/.git-credentials`, `~/.npmrc`, `~/.pypirc`, `~/.docker/config.json`, `~/.kube/config`, `~/.gnupg/*`, `~/.config/gh/hosts.yml`, the token stores of cargo, gem, Vault, Terraform, gcloud, Azure, s3cmd/boto, pass and hub, `~/.pgpass`, `~/.my.cnf`, the shell rc files and `~/.bashrc.d`/`~/.zshrc.d`, `/etc/sudoers*`, `/etc/passwd`, `/etc/shadow`, `/etc/group`, `/etc/ssh/*`) with `>`, `>>`, `tee`, `cp`/`mv`/`install`/`ln`, `dd of=`, or `sed -i` — or, from PowerShell or Cmd, `Add-Content`, `Set-Content`, `Clear-Content`, `Out-File`, `Tee-Object`, `New-Item`, `Copy-Item`, `Move-Item`, `copy`, or `move` — installs persistent access or replaces the trust this machine runs on, whether or not the file exists yet. Reads and `chmod`/`chown` are unaffected; appending to `~/.ssh/known_hosts` stays allowed.

    Explanation
    These files decide who can log in, which keys and tokens act as this user, and what code every new shell runs. Writing one of them — even creating it where it did not exist — is not data loss in the `rm -rf` sense; it is persistence: an authorized_keys line grants login, a `.zshrc` line runs on every shell start, an `.npmrc`/`.netrc` entry publishes and pulls as this user, a sudoers drop-in changes who becomes root. The write is judged by the path the shell will open, so quoted, escaped, `$HOME`, `~user`, `/home/<user>`, and `$ZDOTDIR`-style spellings are all recognised, and a brace, glob, or alternation that could still expand into one of these paths is treated as if it did. A PowerShell or Cmd payload is read with that shell's own quoting and variables (`$env:USERPROFILE`, `%USERPROFILE%`, `C:\Users\<user>`), whichever host dcg runs on. What stays allowed: - Reading them (`cat`, `grep`, `diff`, `ssh -F`, `source`). - `chmod 600` / `chown` on them. - `>>` (or `tee -a`) to `~/.ssh/known_hosts`, which is what `ssh` itself does; truncating or replacing that trust store is still denied. - Writing `~/.ssh/*.pub` and every file that is not on the list. Safer alternatives: - Show the user the exact line or file you want to add and let them apply it. - Write the proposed content to a scratch file under `/tmp/<subdir>/` and point the user at it. - For a one-off the user has approved, use `dcg allow-once`. - For a project that must manage one of these files, allowlist `core.filesystem:credential-file-write` in that project's dcg config with a reason.
  4. dd-overwrite-root-home

    Critical

    dd of=<sensitive-path> overwrites file contents in place. EXTREMELY DANGEROUS on a system or home file.

    Explanation
    `dd if=/dev/zero of=<file>` and `dd if=/dev/urandom of=<file>` overwrite the file's contents in place — the `truncate -s 0` equivalent at the dd layer. On a sensitive system file (`/etc/passwd`, `/etc/shadow`, `/etc/sudoers`) or a home-directory key/credential the result is irrecoverable. Even without an explicit input source (`dd of=<file>` reads from stdin), the file's content is destroyed. There is NO recovery without backups. Safer alternatives: - Make a backup first: `cp <file> <file>.bak && dd if=/dev/zero of=<file>`. - For read-only verification: `dd if=<file> of=/dev/null` (output discarded). - For temp scratch: `dd if=/dev/zero of=/tmp/<subdir>/scratch` is allowed. Device-level dd (`dd of=/dev/sda`) is governed by the `system.disk` pack — enable it for partition-table protection.
  5. find-delete-root-home

    Critical

    find ... -delete naming root, home, or a system directory requires explicit approval. dcg gates on the paths the command names, not on the -name/-maxdepth filters that may narrow what it deletes. This command will NOT be executed.

    Explanation
    `find <path> -delete` removes every file the predicate matches beneath `<path>`, and with `-depth` implied it removes matched directories too. Rooted at `/`, `~`, `$HOME`, or a top-level system directory (`/etc`, `/usr`, `/var`, `/home`, `/boot`, `/dev`, `/proc`, `/sys`, `/lib`, `/lib64`, `/opt`, `/root`), the unfiltered form destroys the operating system or the user's data exactly as `rm -rf` would, and there is NO recovery without backups. It is also the most common way an agent works around a blocked `rm -rf`. This rule fires on a sensitive path appearing anywhere between `find` and `-delete`, and it is deliberately coarse in two ways. It does not evaluate `-name`, `-maxdepth`, `-type`, or any other predicate, so a narrowly filtered delete under home is gated like an unfiltered one — a predicate is easy to get wrong, and the blast radius of a wrong one is the whole subtree. It also does not require the sensitive path to be the search root, so `find /tmp/x -newer /etc/passwd -delete` is gated even though only `/tmp/x` is searched. So a denial here is NOT a measurement of what this particular command would have removed. It reports which paths the command names. To delete inside root or home, pick one: find /tmp/<subdir> -delete # literal temp roots are allowed dcg allow-once <code> # one-shot, from the code in this denial dcg allowlist add-command '<exact command>' -r "reviewed" --user Re-rooting under a more specific subdirectory does NOT lift this rule while that subdirectory is still under root or home. Always preview first: find <path> -type f | head -20
  6. fork-bomb

    Critical

    This is a fork bomb: it recursively spawns processes until the system is unusable.

    Explanation
    A fork bomb defines a function that pipes itself into itself in the background and then calls it. Process count grows exponentially until the kernel can no longer schedule anything; the machine typically needs a hard reboot, losing all unsaved work in every application. There is no legitimate reason to run this shape. If you are testing process limits, use `ulimit -u` in a disposable VM or container.
  7. format-volume

    Critical

    PowerShell Format-Volume erases a volume and everything on it.

    Explanation
    `Format-Volume` reformats a volume, destroying every file on it with no undo. Under an agent hook this must be run by a human who has confirmed the target drive. Safer alternatives: - Confirm the volume first: `Get-Volume`. - Add `-WhatIf` to report what would happen without doing it.
  8. git-internals-write

    Critical

    writing inside a `.git` directory with `tee`, `sponge`, `cp`/`mv`/`install`, `sed -i`, `perl -i`, `dd of=`, or an embedded-code sink rewrites repository state: `.git/config` carries remotes, `insteadOf` rewrites and credential helpers, `.git/hooks/*` run on ordinary git commands, and refs and objects are the history itself. Reads are unaffected, and `.gitignore`, `.gitattributes`, `.gitmodules` and `.github/` are not this rule.

    Explanation
    `.git` is not a secret, it is the repository. Three of its contents change what later commands do rather than what they see: `config` names the remotes a push reaches and can install a credential helper or an `insteadOf` rewrite that silently redirects a fetch; `hooks/*` execute on commit, push and checkout, so writing one is arbitrary code execution at the next ordinary git command; refs and objects are the history, and rewriting them by hand loses work in a way `git reflog` cannot always recover. The write is judged by the path the shell will open, so a checkout-relative `.git/config`, a nested `repo/.git/config`, and a quoted or escaped spelling are all recognised. What stays allowed: - Reading anything under `.git/` (`cat`, `grep`, `git config --list`). - Every git porcelain command; this rule never sees them. - `.gitignore`, `.gitattributes`, `.gitmodules`, `.github/` — none of these are inside `.git/`. Safer alternatives: - `git config <key> <value>` edits config with git's own validation. - `git remote set-url` changes a remote without touching the file. - Show the user the exact change and let them apply it, or use `dcg allow-once` for a one-off. - For a project that genuinely manages `.git` files, allowlist `core.filesystem:git-internals-write` with a reason.
  9. Critical

    symlink from a sensitive path into temp followed by forced recursive deletion can traverse and destroy the target. EXTREMELY DANGEROUS.

    Explanation
    `ln -s /etc /tmp/x && rm -rf /tmp/x/.` can turn an apparently safe temp cleanup into deletion through a symlink. The temp path does not make the operation safe once it points back at a sensitive tree. Safer alternatives: - Inspect symlinks with `readlink` and `ls -la` before removing anything. - Remove only the link itself with `unlink /tmp/<link>` when that is the intent. - Avoid combining symlink creation and recursive deletion in one command.
  10. mv-sensitive-source-root-home

    Critical

    mv touching a sensitive system or home path is the cross-segment recursive-force-delete bypass. EXTREMELY DANGEROUS.

    Explanation
    `mv /etc /tmp/x && rm -rf /tmp/x` is the canonical cross-segment bypass: each segment is individually allowed (mv-to-tmp is benign; rm-rf-in-tmp is safe) but the pair destroys `/etc`. The same shape closes via `mv /etc /dev/null`, `mv $HOME /tmp/x`, or any "relocate then delete" chain. Any mv that mentions a sensitive path (source OR destination — `/etc`, `/usr`, `/var`, `/home`, `~`, `$HOME`, ...) blocks here, including in-place renames within /etc. Safer alternatives: - Rename or move within one home subtree — allowed, quoted or not: `mv ~/Documents/<a> ~/Documents/<b>` (both sides at least two components below the home root, no dotfile tree, no `..`). - Soft-delete into the platform Trash (recoverable; allowed for a source under a home directory, under a temp directory, or a relative path, not for any other absolute path): `mv <path> ~/.Trash/` on macOS, `mv <path> ~/.local/share/Trash/` on Linux. - Soft-delete via in-place rename: `mv <file> <file>.deleted-YYYYMMDD`. - Copy first and verify, then delete the copy's source only with explicit approval: `cp -a <source> <source>.bak && diff -r <source> <source>.bak` (the recursive delete of a home or system source stays gated). - Pure tmp-to-tmp moves: `mv /tmp/<a> /tmp/<b>` is allowed. - Moving a home root, a top-level home directory, or a dotfile tree anywhere but the Trash is still gated: use `dcg allow-once` for those. The Trash move above accepts any source below the home root, including `~/Documents` and `~/.ssh`, because it stays recoverable and deleting from the Trash is gated on its own. The home root itself (`mv ~ ~/.Trash/`) stays gated.
  11. redirect-append-git-internals-relative

    Critical

    shell appending redirect into a .git directory adds repository configuration or hook code that git runs on its next invocation.

    Explanation
    `>> .git/<path>` leaves the existing contents in place and adds to them, which is what makes it useful against a repository rather than what makes it safe: - A `[url "…"] insteadOf` or `[credential] helper` section appended to `.git/config` redirects the next fetch or hands over a token; the sections already there keep working, so nothing looks broken. - `[core] pager`, `[core] editor` and `[alias]` entries name commands git runs, so appending one is code execution on the next git invocation. - A line appended to `.git/hooks/**` runs on the next commit, merge or checkout just as a rewritten hook would. Truncating the same file is already denied. Appending to it reaches the same end state by a route that preserves the evidence. Safer alternatives: - Add configuration through git, which validates the key and writes atomically: `git config <key> <value>`, `git remote add <name> <url>`. - Install a hook from a reviewed file rather than by appending lines. - To inspect rather than extend, read it: `cat .git/config`.
  12. redirect-truncate-git-internals-relative

    Critical

    shell truncating redirect into a .git directory rewrites repository internals; a relative spelling names the same file an absolute one does.

    Explanation
    `> .git/<path>` opens the file with O_WRONLY|O_CREAT|O_TRUNC, so the previous contents are gone before anything is written. Inside `.git` that means repository state, not a working file: - `.git/config` carries remotes, hooks configuration and credentials helpers. - `.git/HEAD` and `.git/refs/**` decide which commits are reachable; truncating them can orphan history that only the reflog still names. - `.git/hooks/**` is executed by git, so a write there is code execution on the next commit, merge or checkout. The absolute spelling of this same path is already denied; naming it relatively does not make it a different file. Safer alternatives: - Change configuration through git, which writes atomically and validates: `git config <key> <value>`, `git remote set-url <name> <url>`. - Move a ref with `git update-ref <ref> <sha>` rather than by writing the file. - To inspect rather than replace, read it: `cat .git/config`. - If a file genuinely must be rewritten, write it beside the repository and copy it in after review: `… > /tmp/<subdir>/config && cp /tmp/<subdir>/config .git/config`.
  13. redirect-truncate-root-home

    Critical

    shell truncating redirect (including arbitrary numeric, named, and PowerShell all-stream forms) to an existing sensitive system or home path destroys the previous file contents. A currently absent literal target under the home directory with an existing parent is allowed (creation, not truncation — the same thing `>>` would do); existing files, dynamic paths, symlinks, missing parents, system paths, and .git internals stay blocked.

    Explanation
    `> /etc/passwd` (or `: > /etc/passwd`, `echo > /etc/passwd`, etc.) opens the target file with O_WRONLY|O_CREAT|O_TRUNC — the contents are destroyed before any write happens. This applies equally to `>|` (force-overwrite), `&>` / `>&` (stdout+stderr to file), and numbered FD forms (`1>`, `2>`, `1>|`, `2>|`). All of these are silent, immediate, irrecoverable. There is NO recovery without backups. Safer alternatives: - Use append (`>>`) to preserve existing content: `echo line >> <file>`. - A literal, currently absent destination under your home directory whose parent directory exists is allowed (nothing to truncate). Existing files, symlinks, dynamic paths, missing parents, system paths, and `.git` internals remain blocked. - For race-free exclusive creation, resolve a literal path and use: `producer | dcg create-new <path>` (existing files, directories, and symlinks are refused). - Make a backup, then write via a temp file: `cp <file> <file>.bak && echo data > /tmp/<subdir>/out && cp -f /tmp/<subdir>/out <file>` (a truncating redirect straight back onto a home/system path is denied by this same rule). - For temp scratch: `> /tmp/<subdir>/scratch` is allowed. - Read redirects (`< <file>`) are not affected — they don't truncate.
  14. rm-r-f-separate-root-home

    Critical

    rm with separate -r -f flags targeting root or home is EXTREMELY DANGEROUS.

    Explanation
    Separate `-r -f` flags on `/` or `~` have identical effect to `rm -rf /`: recursive, forced, silent deletion of the entire filesystem or home directory. There is NO recovery without backups. Run only if truly intended. For a specific directory, preview first, then either delete interactively or move the tree aside (dcg allows both forms): ls -la /path/to/directory rm -ri /path/to/directory # needs a terminal; with stdin closed it deletes nothing and exits 0 mv /path/to/directory /tmp/delete-me-<literal-timestamp>
  15. rm-recursive-force-root-home

    Critical

    rm --recursive --force targeting root or home is EXTREMELY DANGEROUS.

    Explanation
    The long-flag form has identical effect to `rm -rf /`: recursive, forced, silent deletion. Run only if truly intended. For a specific directory, preview first, then either delete interactively or move the tree aside (dcg allows both forms): ls -la /path/to/directory rm -ri /path/to/directory # needs a terminal; with stdin closed it deletes nothing and exits 0 mv /path/to/directory /tmp/delete-me-<literal-timestamp>
  16. rm-rf-root-home

    Critical

    rm -rf on root or home paths is EXTREMELY DANGEROUS. This command will NOT be executed. Ask the user to run it manually if truly needed.

    Explanation
    This command would recursively delete files starting from the root filesystem (/) or home directory (~). This is catastrophic and will destroy: - Your entire operating system - All installed applications and libraries - All user data, documents, and configurations - Boot files, making the system unbootable There is NO recovery without backups. Even with backups, full restoration takes hours to days. dcg auto-allows recursive deletion only for literal temp paths: rm -rf /tmp/<subdir>/scratch For any other directory, preview first, then either delete interactively or move the tree aside. dcg allows all three forms, the Trash move only for a source under a home directory, under a temp directory, or a relative path, not for any other absolute path (`mv /opt/<x> ~/.Trash/` stays denied by `mv-sensitive-source-root-home`): find /path/to/directory -type f | head -20 rm -ri /path/to/directory # needs a terminal; with stdin closed it deletes nothing and exits 0 mv /path/to/directory ~/.Trash/ # macOS soft-delete, recoverable mv /path/to/directory ~/.local/share/Trash/ # Linux soft-delete, recoverable Under a home directory, prefer the Trash move: relocating into /tmp is itself denied there (`mv-sensitive-source-root-home`), because relocate-then-delete is the bypass that rule exists to stop.
  17. rsync-delete-sensitive-dest

    Critical

    rsync --delete into a system directory or home root mirror-deletes its contents. EXTREMELY DANGEROUS.

    Explanation
    rsync --delete makes the destination match the source, so it DELETES every file in the destination that is not present in the source. Aimed at /, /etc, /usr, a home root, or another system path, an empty or wrong source empties that directory — the same catastrophe as `rm -rf` on it, with no undo. Safer alternatives: - Preview first: add `--dry-run` (or `-n`) and read the deletion list. - Drop `--delete` to copy without removing extra destination files. - Mirror into a dedicated, non-system directory you own. - Back the destination up before a real mirror into it.
  18. rsync-sensitive-then-delete

    Critical

    rsync archive of a sensitive path into temp followed by forced recursive deletion is a cross-segment data-loss bypass. EXTREMELY DANGEROUS.

    Explanation
    `rsync -a /etc/ /tmp/dest/ && rm -rf /tmp/dest` is the rsync form of the sensitive-source propagation bypass. Archive mode preserves enough structure that the later temp cleanup should require human review. Safer alternatives: - Run rsync and inspect the destination in a separate step. - Use `--dry-run` for rsync previews. - Use `rm -ri` for manual cleanup of derived temp trees.
  19. shred-root-home

    Critical

    shred on a sensitive system or home path destroys data beyond forensic recovery. EXTREMELY DANGEROUS.

    Explanation
    `shred` overwrites file content with random data (DoD-style multi-pass by default). With `-u`/`--remove`/`-fzu` the file is also unlinked. On a sensitive system file (`/etc/passwd`, `/etc/shadow`, `/etc/sudoers`) or a home-directory key/credential the result is unrecoverable even with specialised forensics — that is shred's entire design intent. There is NO recovery without backups. Safer alternatives: - Verify the path with `ls -la <file>` first. - Make a backup: `cp <file> <file>.bak && shred -u <file>`. - For temp scratch: `shred -u /tmp/<subdir>/scratch` is allowed. - For modern SSDs, single-pass is sufficient: `shred -n 1 -u <file>`.
  20. tar-remove-files-root-home

    Critical

    tar --remove-files on a sensitive system or home path is recursive deletion masquerading as an archive operation. EXTREMELY DANGEROUS.

    Explanation
    `tar --remove-files -cf <archive> <source>` first archives the source paths into <archive>, then deletes the originals. With a sensitive source (`/etc`, `/usr`, `/var`, `/home/<user>`, `~`, `$HOME`, ...) the result is bytewise-equivalent to `rm -rf <source>`. With `-cf /dev/null` the archive is discarded entirely, making this a pure recursive delete with no audit trail. There is NO recovery without backups. Safer alternatives: - Drop `--remove-files`: `tar -cf out.tar <source>` (sources preserved). - Two-step with confirmation: `tar -cf out.tar <source> && rm -ri <source>`. - Verify the source first: `ls -la <source>`. - Allowed for temp dirs: `tar --remove-files -cf out.tar /tmp/<subdir>`.
  21. truncate-zero-root-home

    Critical

    truncate with a potentially shrinking size on a sensitive system or home path destroys data. EXTREMELY DANGEROUS.

    Explanation
    `truncate -s 0 <file>` zeros a file in place. `truncate -s -<N> <file>` shrinks a file by N bytes (destroying the trailing data). On a sensitive system file (`/etc/passwd`, `/etc/shadow`, `/etc/sudoers`) or a home-directory key/credential the result is irrecoverable. There is NO recovery without backups. Safer alternatives: - Make a backup first: `cp <file> <file>.bak && truncate -s 0 <file>`. - For growth (NOT shrink): `truncate -s +<N>` is allowed (no data loss). - For temp scratch: `truncate -s 0 /tmp/<subdir>/scratch` is allowed.
  22. Critical

    unlink on a sensitive system or home path is one-shot data destruction with no recovery. EXTREMELY DANGEROUS.

    Explanation
    `unlink <file>` is the raw POSIX unlink(2) primitive: it removes a single directory entry without prompting, without trash, without backup. On a sensitive system file (`/etc/passwd`, `/etc/shadow`, `/etc/sudoers`) or a home-directory key (`~/.ssh/id_ed25519`, `$HOME/.gnupg/...`) the result is irrecoverable. There is NO recovery without backups. Safer alternatives: - `mv <file> <file>.deleted-YYYYMMDD` then verify nothing breaks, then `unlink <file>.deleted-...` after a few days. - `cp <file> <file>.bak && unlink <file>` to keep an explicit backup. - `unlink /tmp/<subdir>/scratch` is allowed (temp dirs).
  23. vssadmin-delete-shadows

    Critical

    vssadmin delete shadows destroys Volume Shadow Copies (System Restore and backups).

    Explanation
    `vssadmin delete shadows /all` removes the Volume Shadow Copies that System Restore and many backup tools depend on — a hallmark of ransomware, because it destroys the local means of recovery. Safer alternatives: - List them first: `vssadmin list shadows`. - Manage restore points through System Protection instead.
  24. wmi-shadowcopy-delete

    Critical

    Deleting Win32_ShadowCopy instances destroys Volume Shadow Copies.

    Explanation
    Piping `Win32_ShadowCopy` into `Remove-WmiObject` / `Remove-CimInstance`, or calling `.Delete()` on its instances, removes Volume Shadow Copies: the same recovery-destroying operation as `vssadmin delete shadows`, through PowerShell. Safer alternatives: - List them first: `Get-CimInstance Win32_ShadowCopy` or `vssadmin list shadows`.
  25. wmic-shadowcopy-delete

    Critical

    wmic shadowcopy delete destroys Volume Shadow Copies.

    Explanation
    `wmic shadowcopy delete` removes Volume Shadow Copies — the same recovery-destroying operation as `vssadmin delete shadows`, through a different tool. Safer alternatives: - List them first: `vssadmin list shadows`.
  26. dd-overwrite-general

    High

    dd with of=<file> overwrites file contents and requires human approval.

    Explanation
    `dd of=<file>` overwrites the file's contents (with the input from `if=` or stdin if no input source is given). While not as broad as `rm -rf`, a typo in the target path destroys an unintended file with no possibility of undo. Safer alternatives: - Verify the path first: `ls -la <file>`. - Make a backup: `cp <file> <file>.bak && dd if=/dev/zero of=<file>`. - Read-only verification: `dd if=<file> of=/dev/null`. - For temp scratch: `dd if=/dev/zero of=/tmp/<subdir>/scratch` is allowed. - For device writes: enable the `system.disk` pack.
  27. find-delete-general

    High

    find ... -delete is destructive (bytewise-equivalent to rm -rf on the matched tree) and requires human approval.

    Explanation
    `find ... -delete` recursively deletes every path matched by the find expression. The action flag `-delete` implies `-depth` (so directories are deleted after their contents). With no path predicate it deletes the entire starting tree. Common pitfalls: - `find . -delete` deletes the current working directory's contents. - `find <path> -delete` with a wide -name glob matches more than expected. - `-delete` errors are silent by default — failures don't stop the walk. Safer alternatives: - Drop -delete to preview: `find <path> ...` (just lists matches) - Add -print -delete to log each deletion as it happens - Use `find /tmp/<subdir> ... -delete` (allowed under temp dirs) - For a few files: `find ... | xargs -t -p rm -i` for confirmation
  28. mv-dynamic-path

    High

    mv with a shell-expanded or escaped path cannot be verified before execution.

    Explanation
    Shell variables and command substitutions are controlled by the calling environment and may resolve to `/`, `/etc`, a home directory, or another persistent tree. Backslash escapes can also hide traversal from lexical path checks, so dcg cannot safely classify this move. Safer alternatives: - Resolve and inspect every path before moving it. - Use an explicit literal `/tmp/<subdir>` or `/var/tmp/<subdir>` path. - Use `dcg allow-once` only after verifying the resolved source and destination.
  29. redirect-truncate-dynamic-path

    High

    shell redirect to a dynamic or escaped path may truncate a sensitive file and requires human approval.

    Explanation
    The redirect target is expanded by the shell at runtime, so dcg cannot prove where it points before the file is opened with O_TRUNC. Safer alternatives: - Resolve and inspect the target path first. - Use a literal `/tmp/<subdir>/scratch` path for disposable output. - Use append (`>>`) when preserving existing content is acceptable.
  30. rm-glob-home

    High

    rm with an unexpanded glob under a home directory deletes an unbounded, shell-chosen file set and requires human approval.

    Explanation
    The glob is expanded by the shell at execution time, so the author cannot review the exact file set being deleted: `rm -f ~/Downloads/*.md` removes every matching file, exactly like the already-blocked recursive forms. Safer alternatives: - Preview the expansion first: `ls ~/Downloads/*.md` - Delete explicitly named files: `rm ~/Downloads/one-file.md` - Move to trash instead: `mv ~/Downloads/*.md ~/.Trash/` on macOS, `mv ~/Downloads/*.md ~/.local/share/Trash/` on Linux
  31. rm-r-f-separate

    High

    rm with separate -r -f flags is destructive and requires human approval.

    Explanation
    rm with separate -r and -f flags has the same effect as rm -rf: recursive forced deletion without confirmation. Common variations that are all equivalent: - rm -r -f path - rm -f -r path - rm -r -f -v path (verbose but still forced) All carry the same risks as rm -rf: immediate, silent, irreversible deletion. This rule matches the -r/-f flag PAIR, not a filesystem path, so it also fires when `rm` is another tool's subcommand (`git rm -r -f`, `bq rm -r -f`). The recursive-force semantics still apply, but to that tool's objects — tracked files and index entries for git, a dataset and everything in it for bq — not to a directory tree. Enable that tool's pack for guidance written for it; this rule is the backstop when it is not. Safer approach for temporary directories: - rm -r -f /tmp/mydir # Allowed - temp directories are safe - Resolve and inspect $TMPDIR before using it as a deletion root For other paths, prefer: rm -ri /path # Interactive confirmation
  32. rm-recursive-force-long

    High

    rm --recursive --force is destructive and requires human approval.

    Explanation
    rm --recursive --force is the long-form equivalent of rm -rf. While more readable, it carries identical risks: silent, recursive, irreversible deletion. The long flags may appear in: - Scripts aiming for clarity - Generated code from build tools - Cross-platform compatibility scenarios All standard rm -rf precautions apply: - Verify the path before running - Use absolute paths to avoid ambiguity - Consider using trash-cli for recoverable deletion Preview command: find /path -maxdepth 2 -ls | head -30 Forms dcg accepts instead: rm --recursive --force /tmp/<subdir> # literal temp paths are allowed rm -ri /path/to/directory # needs a terminal; with stdin closed it deletes nothing and exits 0 mv /path/to/directory /tmp/delete-me-<literal-timestamp>
  33. rm-rf-general

    High

    rm -rf is destructive and requires human approval. Explain what you want to delete and why, then ask the user to run the command manually.

    Explanation
    rm -rf recursively removes files and directories without confirmation prompts. The -f (force) flag suppresses all warnings, making accidental deletions silent and immediate. Why this is dangerous: - Deleted files bypass the trash - they're gone immediately - Typos in paths can delete unintended directories - Wildcards can expand to match more than expected - No undo mechanism exists Safe alternatives: - rm -ri: Interactive mode, confirms each file. Needs a terminal: with stdin closed, as under an agent hook, it prompts, deletes nothing, and exits 0 - mv <path> /tmp/delete-me-<literal-timestamp>: Move the tree aside instead of deleting it (dcg allows this form) - trash-cli (Linux) or mv <path> ~/.Trash/ (macOS): Moves files to trash instead of deleting - rm -rf in literal /tmp or /var/tmp subdirectories: Allowed - Variable-rooted paths such as $TMPDIR: Reviewed because the environment may point anywhere Preview what would be deleted: find /path/to/delete -type f | wc -l # Count files ls -la /path/to/delete # List contents
  34. sed-exec-unverified

    High

    GNU sed executes shell input that dcg cannot statically verify.

    Explanation
    Use a literal sed replacement or inspect the fully rendered shell command before allowing execution. Backreferences, '&', and an empty `e` command depend on runtime input.
  35. shred-general

    High

    shred destroys file content beyond recovery and requires human approval.

    Explanation
    `shred` overwrites file content with random data; `-u`/`--remove` adds an unlink step. The whole point is that the data cannot be recovered. While not as broad as `rm -rf`, a typo in the target path destroys an unintended file with no possibility of undo. Safer alternatives: - Verify the path with `ls -la <file>` first. - Make a backup: `cp <file> <file>.bak`. - For temp scratch: `shred -u /tmp/<subdir>/scratch` is allowed. - On modern SSDs `shred` may not actually overwrite the underlying flash cells; use `cryptsetup erase` or vendor secure-erase utilities instead.
  36. tar-exec-unverified

    High

    GNU tar executes a helper whose command or executable input dcg cannot statically verify.

    Explanation
    Inspect the fully resolved tar helper and any archive data it executes before using an exact-command allow-once review. Prefer literal helper commands; archive bytes are not verified shell or database input.
  37. tar-remove-files-general

    High

    tar --remove-files deletes source paths after archiving and requires human approval.

    Explanation
    `tar --remove-files <source>` deletes the source paths once they have been archived. While not as broad as `rm -rf`, a typo or wide glob in the source list destroys files the agent did not intend to remove. With `-cf /dev/null` the archive itself is discarded — the operation becomes a pure delete. Safer alternatives: - Drop `--remove-files` to preserve sources after archiving. - Verify the source list with `ls -la` before running. - For temp scratch: `tar --remove-files -cf out.tar /tmp/<subdir>` is allowed.
  38. truncate-zero-general

    High

    truncate with an absolute or shrinking size can destroy file content and requires human approval.

    Explanation
    `truncate -s 0 <file>` zeros a file in place; `truncate -s -<N> <file>` shrinks it by N bytes. Both destroy data without confirmation, without trash, without backup. While not as broad as `rm`, a typo in the target path destroys an unintended file. Safer alternatives: - Verify the size first: `wc -c <file>`. - Make a backup: `cp <file> <file>.bak && truncate -s 0 <file>`. - For growth: `truncate -s +<N>` (allowed; non-destructive). - For temp scratch: `truncate -s 0 /tmp/<subdir>/scratch` is allowed.
  39. High

    unlink is destructive (POSIX equivalent of rm on a single file) and requires human approval.

    Explanation
    `unlink <file>` removes a single directory entry without confirmation, without trash, without backup. While not as broad as `rm -rf`, a typo in the target path destroys an unintended file. Safer alternatives: - Verify the path with `ls -la <file>` first. - Make a backup: `cp <file> <file>.bak`. - For temp scratch: `unlink /tmp/<subdir>/scratch` is allowed. - Use `mv <file> /tmp/quarantine-<file>` if you want a delayed delete.

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • storage-whatif
  • rm-rf-tmp
  • rm-fr-tmp
  • rm-rf-var-tmp
  • rm-fr-var-tmp
  • rm-r-f-tmp
  • rm-f-r-tmp
  • rm-r-f-var-tmp
  • rm-f-r-var-tmp
  • rm-recursive-force-tmp
  • rm-force-recursive-tmp
  • rm-recursive-force-var-tmp
  • rm-force-recursive-var-tmp
  • find-delete-tmp
  • find-delete-var-tmp
  • find-exec-rm-tmp
  • find-exec-rm-var-tmp
  • unlink-tmp
  • unlink-var-tmp
  • unlink-help
  • truncate-help
  • truncate-grow
  • truncate-tmp
  • truncate-var-tmp
  • shred-help
  • shred-tmp
  • shred-var-tmp
  • tar-remove-files-tmp
  • tar-remove-files-var-tmp
  • dd-tmp
  • dd-var-tmp
  • dd-help
  • mv-tmp
  • mv-var-tmp
  • mv-help
  • mv-to-trash
  • mv-to-trash-quoted
  • mv-within-home
  • mv-relative-into-home