nexu-io/open-design · error · SystemExit

path traversal detected in output_path for job {job_id}

Error message

path traversal detected in output_path for job {job_id}

What it means

Raised in the main loop after resolving output_path: the resolved destination is not inside run_dir. The script only writes generated images inside the run directory, so an output_path that escapes is rejected.

Source

Thrown at skills/hatch-pet/scripts/generate_pet_images.py:263

        states=parse_states(args.states),
        skip_base=args.skip_base,
        job_ids=args.job_id,
    )
    raw_dir = run_dir / "raw"

    completed = []
    for job in jobs:
        job_id = str(job.get("id"))
        prompt_raw = job.get("prompt_file")
        output_raw = job.get("output_path")
        if not isinstance(prompt_raw, str) or not isinstance(output_raw, str):
            raise SystemExit(f"job {job_id} is missing prompt_file or output_path")
        prompt_file = (run_dir / prompt_raw).resolve()
        output_image = (run_dir / output_raw).resolve()
        if not prompt_file.is_relative_to(run_dir):
            raise SystemExit(f"path traversal detected in prompt_file for job {job_id}")
        if not output_image.is_relative_to(run_dir):
            raise SystemExit(f"path traversal detected in output_path for job {job_id}")
        print(f"Generating {job_id} with secondary fallback")
        image_paths = path_list(run_dir, job)
        if image_paths:
            response = run_image_edit(
                model=args.model,
                prompt_file=prompt_file,
                image_paths=image_paths,
                output_json=raw_dir / f"{job_id}.response.json",
                size=args.size,
                api_key=api_key,
            )
        else:
            response = run_image_generation(
                model=args.model,
                prompt_file=prompt_file,
                output_json=raw_dir / f"{job_id}.response.json",
                size=args.size,
                api_key=api_key,

View on GitHub (pinned to 5be4028344)

Solutions

  1. Set output_path to a relative path under run_dir, e.g. decoded/<state>.png.
  2. If you need the image elsewhere, write inside run_dir then copy out after the run.
  3. Regenerate the manifest with prepare_pet_run.py.
  4. Rerun the job.

Example fix

// before (manifest)
"output_path": "/var/www/html/idle.png"

// after
"output_path": "decoded/idle.png"
Defensive patterns

Strategy: validation

Validate before calling

def safe_output_path(run_dir: Path, raw: str) -> Path:
    resolved = (run_dir / raw).resolve()
    if not resolved.is_relative_to(run_dir):
        raise SystemExit(f"output_path escapes run_dir: {raw}")
    return resolved

Type guard

def output_is_inside(run_dir: Path, raw: str) -> bool:
    return (run_dir / raw).resolve().is_relative_to(run_dir)

Prevention

When it happens

Trigger: A job's output_path is absolute or contains ../ that would write the decoded image outside run_dir (e.g. "/etc/cron.d/evil" or "../../../overwrite.png").

Common situations: Hand-editing output_path to point at a shared absolute dir; manifest copied from another machine with absolute output paths; an attempt to overwrite unrelated files via the manifest.

Related errors


AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12). Data as JSON: /api/errors/587367a107f633fc. Report an issue: GitHub.