All posts

9 min readPost 17

How backticks in release notes wiped our main checkout

During the 1.4.2 release, a patch command using a quoted Bash heredoc wiped our entire main checkout in under a minute—executed by a Markdown example (`find -delete`) inside the changelog itself. Here is the postmortem, why our first diagnosis was dead wrong, how 1.4.3's EmbeddedDeletion closes cross-shell quote corruption, and where a delete guard's protection ends.

On this page
  1. What happened: an afternoon warning echoed in the main checkout
  2. Recovering six days of private docs from accidental backups
  3. Why our first diagnosis was wrong
  4. 1.4.3: EmbeddedDeletion stops trusting quotes across shell handoffs
  5. Why we skipped the OS sandbox—and the true ceiling of a delete guard

At 22:57 on 19 November 2026, while preparing Obituary 1.4.2, a Codex worker ran a patch command using a single-quoted Bash heredoc to update our release notes. Within sixty seconds our entire main repository checkout vanished—.git, private docs-internal/, and untracked config alike—leaving ls -la printing total 0.

The command that wiped the directory was a Markdown code span written as documentation inside the changelog itself: `find -delete`.

For the first fifteen minutes after the incident, we assumed the fix was already sitting in 1.4.2 waiting to be installed. Checking the exact command against the code shattered that comfort: even if 1.4.2 had already been installed on that machine, the delete guard would have let the command straight through.

The failure was not a missing keyword. Between the moment the guard inspected the command and the moment the shell executed it sat a cross-shell handoff where quoting quietly broke.

Conceptual illustration of a person shining a flashlight through a first archway while orange light leaks through a second hidden door behind it
The delete guard stands at the first door and sees inert literal text; past the second door, another shell re-parses the text as live commands.

What happened: an afternoon warning echoed in the main checkout ​

Obituary's delete guard hooks into an AI agent's pre-execution step, parses incoming shell commands, and denies rm, rmdir, git clean, and Remove-Item (suggesting restorable obit equivalents where safe). In our workflow, Windows-hosted workers execute shell steps through WSL Bash.

Two things collided that day:

  • The afternoon warning: around 16:00 we saw reports of agents bypassing rm bans using find -delete, so we dispatched a worker in an isolated guard-find worktree to block find -delete, find -exec rm, and xargs rm (commit b131063, merged at 17:09). At 16:57 that worker had already wiped its own throwaway worktree when Bash snippets inside a test patch executed unexpectedly. Because the worktree was disposable, we did not dig all the way down to the cross-shell forwarding bug.
  • The evening release mistake: the 1.4.2 release worker operated directly inside the main checkout instead of an isolated worktree, applying release notes packed with Markdown backticks: `find -delete`, `find -exec rm`, `xargs rm`, `git clean`, `Remove-Item`, and `obit rm`.

At 22:54:27 the worker sent its patch wrapped in a quoted heredoc without cat and got Invalid patch. At 22:56:19 it added cat and retried:

bash
codex --codex-run-as-apply-patch "$(cat <<'PATCH'
*** Begin Patch
*** Update File: README.md
@@
-- **怕 agent 一句 `rm -rf`。** ...
+- ... Bash 的 `find -delete`、`find -exec rm` 和 `xargs rm` 也会被拦下,但要先核对目标再用 `obit rm` 下葬。
...
*** Update File: CHANGELOG.md
@@
 - Fix: the delete guard now denies Bash `find -delete`, `find -exec rm`, and `xargs rm`, and explains how to list the targets first and bury them with `obit rm`.
...
*** End Patch
PATCH
)"

Under Bash rules, a single-quoted <<'PATCH' heredoc is completely literal—backticks inside it never execute. Ten seconds later, stderr printed two chilling bursts:

text
fatal: clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean
/bin/bash: line 1: Remove-Item: command not found
/bin/bash: line 1: obit: command not found

Interrupting the process emitted find: missing argument to '-exec', rm: missing operand, fatal: not a git repository, and finally README.md: No such file or directory. By 22:57:02, the checkout returned only total 0. Remote main stayed untouched at 8a05e62, untagged and unpublished.

While no log captured the corrupted argv Bash ultimately received, the stderr order matched every Markdown backtick span executing as command substitution—including bare `find -delete` with no starting path, deleting downward from the repo root inside WSL Bash without touching the Windows Recycle Bin.

Recovering six days of private docs from accidental backups ​

At 22:58 we froze all writes to that drive. All public code was safe on GitHub, leaving private docs-internal/ as the biggest exposure: its last remote push was six days earlier (13 November at 15:51).

While evaluating disk recovery, we rebuilt all six days cleanly onto the system drive from three accidental sources:

  1. Local agent session logs retained full file contents from every read and write to docs-internal/.
  2. A worker had run git status at 20:17 that evening, proving exactly 9 files were added or modified since 13 November.
  3. Matching those 9 files against session transcripts and GitHub Release bodies reconstructed every single one.

By 23:15 both repos were freshly cloned, restored, and pushed; only a few old unpushed local branches and scratch worktrees were lost. Removing PowerShell was briefly raised during triage and dismissed—WSL Bash ran the deletion, and Windows PowerShell 5.1 is an OS component anyway. The danger was never a specific shell; it was giving an automated process write access to the sole local copy of a repository.

Why our first diagnosis was wrong ​

Minutes after the wipe, we initially thought shipping 1.4.2 would have caught the command. Re-checking the exact payload while shipping 1.4.2 from an isolated worktree disproved that immediately.

The delete guard runs before the command reaches the second shell and reads valid Bash where `find -delete` inside <<'PATCH' is inert text. Any standards-compliant Bash parser must allow it. 1.4.2 blocks direct find ./probe -name x -delete, yet rightly sees a quoted heredoc as safe text.

What turned prose into execution was Codex on Windows forwarding the command into WSL Bash: outer quoting broke in transit, turning the quoted heredoc unquoted so backticks executed as live command substitutions—entirely downstream of the guard. The same audit also revealed Claude Code on that machine was still running --notice-only, so we enabled --guard-rm there immediately.

1.4.3: EmbeddedDeletion stops trusting quotes across shell handoffs ​

Returning to our core guard principle—separate broad denial from narrow verbatim replacement—we shipped 1.4.3 (b6cae61) at 01:06 on 20 November with a Windows-Codex-scoped rule called EmbeddedDeletion making three deliberate choices:

  • Stop trusting quotes and heredoc boundaries: extract every backtick and $(...) span anywhere in the raw command—inside single quotes, double quotes, quoted heredocs, or comments—and deny if any span contains a deletion.
  • Parse every span as both Bash and PowerShell: our first draft parsed only Bash, and code review caught '$(Remove-Item -Recurse x)' slipping through. Because $(...) executes in both shells and the downstream shell cannot be trusted after forwarding, both parsers inspect every span.
  • Run before context resolution: ordinary guard rules resolve shell, cwd, and obit binary path to emit an exact equivalent, skipping whenever one is unknown. Because EmbeddedDeletion denies without suggesting a drop-in command, it runs before deleteGuardContext so POSIX working directories or missing paths can never bypass it.

Its plain ASCII denial explains that Windows Codex forwards commands through another shell where quoting can fail, directing agents to write backtick-heavy edits through file tools instead of shell commands.

Terminal test of 1.4.3 obit hook codex on Windows: plain quoted heredoc passes silently, adding backticked deletion text returns deny citing cross-shell quoting, and single-quoted $(Remove-Item -Recurse build) also returns deny
Real 1.4.3 hook output: an identical quoted heredoc passes without backticks, and returns deny the moment a backticked delete or single-quoted $(Remove-Item ...) appears.

Five new compile-time mutants covering scope, PowerShell parsing, and nested recursion were all caught, and replaying the incident command against released 1.4.3 returned deny on the spot.

Why we skipped the OS sandbox—and the true ceiling of a delete guard ​

Alongside 1.4.3, four operational rules took effect immediately: workers never enter the main checkout, backtick-bearing edits use file tools rather than shell commands, private docs push immediately after edits, and long-lived background processes launch from outside working directories.

We also tested Codex's built-in Windows OS sandbox. In a scratch repo it cleanly blocked out-of-bounds writes with Access is denied, yet broke linked worktrees—blocking git commit writes to the parent .git directory and cutting off network access even after custom allowlists. Fixing it required elevated Windows policy edits and abandoning WSL, so we held off.

Stacking every defense against that night's command makes the division of labor unmistakable:

DefenseAgainst that night's command
Workers confined to disposable worktreesHolds completely: worst case wipes a throwaway copy
Push private docs immediatelyHolds completely: recoverable from remote
File-edit tools instead of shell heredocsPrevents the class, relies on compliance
1.4.2 delete guardMisses: text sits inside a valid quoted heredoc
1.4.3 EmbeddedDeletionDenies before execution

The ceiling stays explicit: a delete guard only recognizes deletion commands. If broken quoting ever runs git reset --hard or truncates files with >, the guard will not intervene. Isolated worktrees and frequent remote pushes remain the primary defense; session transcripts are an accidental backup we refuse to rely on twice.

All posts