From d0ae2926e66c2935330504c07c56669b9ed95203 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Jul 2026 00:21:27 +0000 Subject: [PATCH] Add explicit path-containment check to kanban_task_path The regex allow-list alone wasn't enough for CodeQL's path-injection sanitizer recognition. Resolve the candidate path and verify it's still a direct child of the resolved kanban directory before returning it, which is the pattern CodeQL's py/path-injection query recognizes as clearing taint. --- server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index f67dada..41bfe56 100644 --- a/server.py +++ b/server.py @@ -780,7 +780,11 @@ def kanban_task_path(task_id: str) -> Path: """Resolve a task id to its file path, rejecting anything that isn't a plain generated id.""" if not KANBAN_ID_RE.fullmatch(task_id or ""): raise HTTPException(400, "Invalid task id") - return KANBAN_DIR / f"{task_id}.json" + base = KANBAN_DIR.resolve() + candidate = (base / f"{task_id}.json").resolve() + if candidate.parent != base: + raise HTTPException(400, "Invalid task id") + return candidate def save_kanban_task(task: dict): ensure_dir(KANBAN_DIR)