Skip to content

Commit a653394

Browse files
committed
fix(security): seed_project purges the domain it checked, not the raw argument (GHSA-7848-qh48-mx2w)
The guard checked the domain remember writes under (the directory wins over the argument) while the purge ran on the raw domain argument. A session in beta calling seed_project({'domain': 'alpha'}) from its own directory passed the check and deleted alpha's seeded memories. The purge now targets the checked domain; a regression test fails without the fix. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_018kyZYsWnKSjpX4oNV19PCF
1 parent a0cd381 commit a653394

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ adheres to [Semantic Versioning](https://semver.org/).
1919
detector infers without it is kept local and reported (`global_reason`). `anchor`,
2020
`supersedes_id`, curation merges and memory-replica refreshes never change another
2121
project's or a global memory without that allowance, and `seed_project` checks the
22-
domain `remember` will use before it purges anything.
22+
domain `remember` will use before it purges anything, and purges that domain,
23+
never the raw `domain` argument.
2324
- `record_session_end` no longer writes an ADR task record outside the wiki root
2425
(GHSA-5w3v-7v7h-q9x4, reported and fixed by kasparovabi). An explicit `domain`
2526
goes through `domain_id_from_label`, and the writer refuses a path that resolves

‎mcp_server/handlers/seed_project.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ async def handler(args: dict[str, Any] | None = None) -> dict[str, Any]:
194194
}
195195

196196
purged = 0
197+
# GHSA-7848-qh48-mx2w: purge the domain seeding writes under (the directory wins
198+
# over the argument), the one `_parse_args` checked, never the raw argument.
197199
if not dry_run:
198200
# source: ADR-0445
199-
purged = _get_store().delete_memories_by_tag("seeded", domain=domain)
201+
purged = _get_store().delete_memories_by_tag(
202+
"seeded", domain=_remember_domain(str(root), domain)
203+
)
200204

201205
all_discoveries = collect_all_discoveries(root, max_bytes)
202206

‎tests_py/handlers/test_ghsa_7848_cross_project_write.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,33 @@ def test_seed_project_refuses_another_projects_directory(projects):
203203
assert str(error) == _refusal("seed_project")
204204

205205

206+
@pytest.mark.asyncio
207+
async def test_seed_project_purges_the_domain_it_checked_not_the_argument(
208+
projects, monkeypatch
209+
):
210+
"""A session in beta seeding its directory with domain=alpha never purges alpha."""
211+
from mcp_server.handlers import seed_project
212+
213+
purged = []
214+
215+
class Store:
216+
def delete_memories_by_tag(self, tag, domain=None):
217+
purged.append((tag, domain))
218+
return 0
219+
220+
async def stored(*args):
221+
return 0, 0, []
222+
223+
# pytest's tmp_path is a transient root, which seed_project refuses.
224+
monkeypatch.setattr(seed_project, "is_transient_seed_root", lambda _path: False)
225+
monkeypatch.setattr(seed_project, "_get_store", lambda: Store())
226+
monkeypatch.setattr(seed_project, "collect_all_discoveries", lambda *a: [])
227+
monkeypatch.setattr(seed_project, "_store_discoveries", stored)
228+
monkeypatch.chdir(projects / "beta")
229+
await seed_project.handler({"domain": "alpha"})
230+
assert purged == [("seeded", "beta")]
231+
232+
206233
@pytest.mark.asyncio
207234
async def test_ingest_prd_refuses_before_writing(projects, monkeypatch):
208235
from mcp_server.handlers import ingest_prd

0 commit comments

Comments
 (0)