Answer security round 1: 0 🔴, 1 🟡 (0 misread); refuse a Grep with a glob over a folder holding an ignored env-file, and file item 370 for recursive Bash searches
CI / tests (pull_request) Successful in 2m36s

This commit is contained in:
2026-11-13 21:12:38 +01:00
parent b4b84a4280
commit 60a1f5c385
4 changed files with 11 additions and 4 deletions
+3 -2
View File
@@ -27,7 +27,8 @@ def reads(call: Call, path: pathlib.Path, home: str) -> bool:
return names(resolved(call.cwd, text(call.given, "file_path"), home), path)
if call.tool == "Grep":
searched = resolved(call.cwd, text(call.given, "path") or ".", home)
return names(searched, path) or holds(searched, path) and not ignored(path)
# ripgrep's --glob overrides its ignore files, so an ignored file is skipped only by a Grep without one.
return names(searched, path) or holds(searched, path) and (bool(text(call.given, "glob")) or not ignored(path))
command = text(call.given, "command")
relative = os.path.relpath(path, home)
spellings = "|".join(re.escape(spelling) for spelling in (str(path), *(f"{prefix}/{relative}" for prefix in ("~", "$HOME", "${HOME}"))))
@@ -51,5 +52,5 @@ def holds(folder: str, path: pathlib.Path) -> bool:
def ignored(path: pathlib.Path) -> bool:
"""Whether the checkout holding path ignores it: Grep runs ripgrep, which skips such a file in a folder it searches."""
"""Whether the checkout holding path ignores it: Grep runs ripgrep, which skips such a file in a folder it searches unless a glob names it."""
return not isinstance(guarded_git(str(path.parent), "check-ignore", "--quiet", path.name), Failure)
+1 -1
View File
@@ -38,7 +38,7 @@ RULES: dict[RuleName, Rule] = {
# A marker would let the credentials into the transcript all the same, so no marker waives it.
"env-file-read": Rule(
"an agent never reads ~/.claude/.env or a project's env-file, the file of credentials its config names, since a value it reads lands in its transcript, which loop-claude archives and the backups copy; a tool that needs a credential reads the file itself, and `project-config env-file` prints the file's path",
"a Read of the file, a Grep of the file or of a folder that holds it where no checkout ignores it, and a Bash command that spells the file's path or names it from the directory `cd` left the command in, against ~/.claude/.env and the env-file of every config under ~/.claude-projects",
"a Read of the file, a Grep of the file, or of a folder that holds it where the Grep sets a glob or no checkout ignores the file, and a Bash command that spells the file's path or names it from the directory `cd` left the command in, against ~/.claude/.env and the env-file of every config under ~/.claude-projects",
overridable=False,
),
"ignorefile-sorted": Rule(
+1
View File
@@ -405,6 +405,7 @@ class EnvFileRead(unittest.TestCase):
subprocess.run(["git", "init", "--quiet", str(self.home / ".claude")], check=True, env=isolated_env())
(self.home / ".claude" / ".gitignore").write_text(".env\n")
self.assertEqual(self.breached("Grep", {"pattern": "TOKEN", "path": f"{self.home}/.claude"}), [])
self.assertEqual(self.breached("Grep", {"pattern": "TOKEN", "path": f"{self.home}/.claude", "glob": "*"}), ["env-file-read"], "a glob overrides ripgrep's ignore files")
self.assertEqual(self.breached("Grep", {"pattern": "TOKEN", "path": f"{self.home}/code"}), [])
def test_a_command_naming_the_file_is_refused(self):
+6 -1
View File
@@ -6,12 +6,13 @@
`Bar = 0.1`
`Next ID = 370`
`Next ID = 371`
## Items
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 370 | 0.11.0 | | security | **Refuse a Bash command that searches a folder holding an env-file recursively, as `grep -r` or `rg` do, so no credential reaches a transcript.** | 2 | 2 | 4 | 6 | 2 | 4 by 3 | 4.2 |
| 354 | 0.11.0 | | | **Read and write the decisions, score anchors, comprehension history, reading cost and changelog each through the backend its project's config names, with markdown files as one backend.** | 3 | 2 | 3 | 6 | 6 | 1.6 by 4, code health by 1 | 1.2 |
| 364 | 0.11.0 | 354 | | **Read a client repo's own `CLAUDE.md` and `AGENTS.md`, propose to its team each change that aligns them with this setup, and record each conflict left as a decision in the project's records.** | 2 | 2 | 2 | 4 | 2 | 1.6 by 4, 1.2 by 2 | 2.2 |
| 360 | 0.11.0 | | | **Make `chunk-pr merge` wait for the human approvals a project's config requires, as part of the gate, before it merges.** | 2 | 2 | 3 | 5 | 3 | 1.6 by 5 | 1.6 |
@@ -86,6 +87,10 @@
## Details
### 370. Refuse a Bash command that searches a folder holding an env-file recursively, as `grep -r` or `rg` do, so no credential reaches a transcript.
The env-file-read rule refuses a Grep of a folder that holds `~/.claude/.env` or a config's env-file, but a Bash command only where it spells or names the file itself. A worker that runs `grep -r TOKEN ~/.claude-projects`, or `rg --no-ignore` over `~/.claude`, still prints the credential lines into its transcript, which loop-claude archives under `~/.claude/loop-claude-transcripts` and the backups copy. README suggests keeping the env-file at `~/.claude-projects/<key>.env`, a folder agents search often. Extend `bin/rule_hook/env_file.py` to refuse a `grep -r`/`-R`, `rg` or `ag` whose folder operand, or the directory `cd` left it in when it names none, holds a guarded file that the tool doesn't skip. A test must show the refusal for each tool. The security pass of item 369's chunk raised it.
### 354. Read and write the decisions, score anchors, comprehension history, reading cost and changelog each through the backend its project's config names, with markdown files as one backend.
lilleman's call, 2026-11-12: each record has its own backend setting, so a client project can keep, say, decisions and changelog in Confluence and anchors and comprehension history as files. Which goes where is asked per client at setup. Every tool and agent that reads or writes a record goes through the interface: the judge's records, `rank_todo.py`'s decision check, `todo-item finish --changelog`, larv-review's scoring and places, `score-outcomes`, `rules/decisions.md`. The plan store's contract suite has a twin for records, on fakes. R is above 5, so this item ships alone.