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.
This commit is contained in:
Claude 2026-07-06 00:21:27 +00:00
parent 52aa18b019
commit d0ae2926e6
1 changed files with 5 additions and 1 deletions

View File

@ -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)