Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
screen Wan 2.2 checkpoint indexes too, since accelerate will not fix GHSA-4j2p-28q2-5m79
[._.]/ Adam Eivy3db7edbcdc12
diff --git a/scripts/_checkpoint_index_guard.py b/scripts/_checkpoint_index_guard.pynew file mode 100644index 0000000000..648d5ef6ba--- /dev/null+++ b/scripts/_checkpoint_index_guard.py@@ -0,0 +1,87 @@+"""Sharded-checkpoint index guard shared by the diffusers-backed CUDA runners.++Mitigates GHSA-4j2p-28q2-5m79 (CVE-2026-69112): `accelerate` trusts the shard+names it reads out of a `*.index.json` `weight_map`, so a checkpoint can point a+shard at `../../etc/passwd` to read an arbitrary file, or at a FIFO to block the+loader forever. Upstream has declined to fix it (huggingface/accelerate#4067 —+"not a real security threat" under their SECURITY.md, which treats checkpoints+as trusted input), so there is no version to upgrade to: every runner that hands+accelerate a downloaded snapshot validates the indexes itself, first.++Stdlib-only at import time, like `_runner_common.py`, so each runner's venv+reaches it through the same-directory `sys.path.insert` idiom without growing a+dependency. Runners that load weights from explicit per-file paths rather than+from an index (`generate_ltx25_cuda.py`) do not need it.+"""++from __future__ import annotations++import json+import ntpath+import os+from pathlib import Path+++def validate_checkpoint_indexes(snapshot: Path) -> None:+ """Reject shard entries that escape their component or are not regular files.++ Check lexical containment, preserving HF snapshot file symlinks into blobs,+ and refuse non-regular files before a loader can block opening a FIFO.+ Scan all component indexes, including ones already cached outside repoFiles.+ """+ def fail_walk(error):+ raise error++ snapshot_abs = os.path.abspath(snapshot)+ allowed_roots = {os.path.realpath(snapshot_abs)}+ # Hugging Face snapshots normally link files into the sibling `blobs/`+ # directory. Keep that supported link shape, but do not let an arbitrary+ # symlink turn a checkpoint shard into a read of another local file.+ for ancestor in Path(snapshot_abs).parents:+ if ancestor.name == "snapshots":+ allowed_roots.add(os.path.realpath(ancestor.parent / "blobs"))++ def is_under(path, root):+ try:+ return os.path.commonpath((path, root)) == root+ except ValueError:+ return False++ for folder, directories, files in os.walk(snapshot, onerror=fail_walk):+ # HF caches symlink FILES, not component directories. Do not silently+ # skip an index hidden behind a directory symlink during this walk.+ if any((Path(folder) / name).is_symlink() for name in directories):+ raise ValueError("Checkpoint component directories must not be symlinks.")+ for name in files:+ if not name.endswith(".index.json"):+ continue+ index_path = Path(folder) / name+ if not index_path.is_file():+ raise ValueError("Checkpoint index must be a regular file.")+ with index_path.open(encoding="utf-8") as handle:+ index = json.load(handle)+ if not isinstance(index, dict):+ raise ValueError("Checkpoint index must contain a weight map.")+ weight_map = index.get("weight_map", index)+ if not isinstance(weight_map, dict) or not weight_map:+ raise ValueError("Checkpoint weight map must be a non-empty object.")+ root = os.path.abspath(folder)+ for shard in weight_map.values():+ # Reject Windows drive/UNC/rooted paths on every host, as well+ # as backslashes: repository filenames use POSIX separators.+ if (not isinstance(shard, str) or not shard or "\x00" in shard+ or "\\" in shard or ntpath.splitdrive(shard)[0]+ or ntpath.isabs(shard)):+ raise ValueError("Checkpoint shard must be a relative filename.")+ target = os.path.abspath(os.path.join(root, shard))+ if os.path.commonpath((root, target)) != root:+ raise ValueError("Checkpoint shard escapes its component directory.")+ # An unused, partially cached component may lack shards. Leave+ # missing-file reporting to the loader, but never open a FIFO,+ # directory, device, or dangling symlink that DOES exist.+ if os.path.lexists(target):+ resolved_target = os.path.realpath(target)+ if not any(is_under(resolved_target, root) for root in allowed_roots):+ raise ValueError("Checkpoint shard symlink escapes the model cache.")+ if not os.path.isfile(target):+ raise ValueError("Checkpoint shard must be a regular file.")diff --git a/scripts/generate_minimax_h3_cuda.py b/scripts/generate_minimax_h3_cuda.pyindex 047f40fafd..5741ffaaa4 100644--- a/scripts/generate_minimax_h3_cuda.py+++ b/scripts/generate_minimax_h3_cuda.py@@ -29,13 +29,11 @@ cannot hold this model says so in seconds rather than being killed an hour in.from __future__ import annotationsimport argparse-import json-import ntpath-import osimport sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).resolve().parent))+from _checkpoint_index_guard import validate_checkpoint_indexes # noqa: E402from _runner_common import emit_runtime_fingerprint, establish_process_group, heartbeat # noqa: E402from _minimax_h3_common import ( # noqa: E402FPS, add_h3_common_args, emit_result, enforce_system_memory, load_keyframes,@@ -164,72 +162,6 @@ def resolve_offload_profile(requested: str) -> tuple[str, float]:return affordable[0], total_gb-def validate_checkpoint_indexes(snapshot: Path) -> None:- """Mitigate GHSA-4j2p-28q2-5m79 before any component loads weights.-- Accelerate 1.14.0 (and 1.15.0) trusts shard names from checkpoint indexes.- Check lexical containment, preserving HF snapshot file symlinks into blobs,- and refuse non-regular files before a loader can block opening a FIFO.- Scan all component indexes, including ones already cached outside repoFiles.- """- def fail_walk(error):- raise error-- snapshot_abs = os.path.abspath(snapshot)- allowed_roots = {os.path.realpath(snapshot_abs)}- # Hugging Face snapshots normally link files into the sibling `blobs/`- # directory. Keep that supported link shape, but do not let an arbitrary- # symlink turn a checkpoint shard into a read of another local file.- for ancestor in Path(snapshot_abs).parents:- if ancestor.name == "snapshots":- allowed_roots.add(os.path.realpath(ancestor.parent / "blobs"))-- def is_under(path, root):- try:- return os.path.commonpath((path, root)) == root- except ValueError:- return False-- for folder, directories, files in os.walk(snapshot, onerror=fail_walk):- # HF caches symlink FILES, not component directories. Do not silently- # skip an index hidden behind a directory symlink during this walk.- if any((Path(folder) / name).is_symlink() for name in directories):- raise ValueError("Checkpoint component directories must not be symlinks.")- for name in files:- if not name.endswith(".index.json"):- continue- index_path = Path(folder) / name- if not index_path.is_file():- raise ValueError("Checkpoint index must be a regular file.")- with index_path.open(encoding="utf-8") as handle:- index = json.load(handle)- if not isinstance(index, dict):- raise ValueError("Checkpoint index must contain a weight map.")- weight_map = index.get("weight_map", index)- if not isinstance(weight_map, dict) or not weight_map:- raise ValueError("Checkpoint weight map must be a non-empty object.")- root = os.path.abspath(folder)- for shard in weight_map.values():- # Reject Windows drive/UNC/rooted paths on every host, as well- # as backslashes: repository filenames use POSIX separators.- if (not isinstance(shard, str) or not shard or "\x00" in shard- or "\\" in shard or ntpath.splitdrive(shard)[0]- or ntpath.isabs(shard)):- raise ValueError("Checkpoint shard must be a relative filename.")- target = os.path.abspath(os.path.join(root, shard))- if os.path.commonpath((root, target)) != root:- raise ValueError("Checkpoint shard escapes its component directory.")- # An unused, partially cached component may lack shards. Leave- # missing-file reporting to the loader, but never open a FIFO,- # directory, device, or dangling symlink that DOES exist.- if os.path.lexists(target):- resolved_target = os.path.realpath(target)- if not any(is_under(resolved_target, root) for root in allowed_roots):- raise ValueError("Checkpoint shard symlink escapes the model cache.")- if not os.path.isfile(target):- raise ValueError("Checkpoint shard must be a regular file.")--def load_pipeline(snapshot: Path, profile: str):"""Load the `fl2va` workflow under one of the documented memory recipes.diff --git a/scripts/generate_wan22_cuda.py b/scripts/generate_wan22_cuda.pyindex 84dd68d515..11da97ef3c 100644--- a/scripts/generate_wan22_cuda.py+++ b/scripts/generate_wan22_cuda.py@@ -9,6 +9,7 @@ import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).resolve().parent))+from _checkpoint_index_guard import validate_checkpoint_indexes # noqa: E402from _runner_common import emit_runtime_fingerprint, establish_process_group, heartbeat # noqa: E402@@ -53,6 +54,10 @@ def main() -> None:snapshot = snapshot_download(repo_id=args.model_repo, revision=args.model_revision, local_files_only=True)except Exception as exc:raise RuntimeError("The pinned Wan 2.2 snapshot is incomplete. Use Download or Repair in Video Gen.") from exc+ # accelerate trusts shard names from a sharded checkpoint index, and has no+ # fixed release (GHSA-4j2p-28q2-5m79) — screen the snapshot before diffusers+ # hands it over.+ validate_checkpoint_indexes(Path(snapshot))import torchfrom diffusers import AutoencoderKLWan, WanPipelinefrom diffusers.utils import export_to_videodiff --git a/scripts/generate_wan22_cuda.test.js b/scripts/generate_wan22_cuda.test.jsnew file mode 100644index 0000000000..5f177411e8--- /dev/null+++ b/scripts/generate_wan22_cuda.test.js@@ -0,0 +1,71 @@+import { execFileSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { dirname, join } from 'node:path';+import { describe, expect, it } from 'vitest';+import { resolveTestPython } from '../server/lib/testHelper.js';++const script = join(dirname(fileURLToPath(import.meta.url)), 'generate_wan22_cuda.py');++// Probe for an interpreter that actually RUNS rather than assuming a name. On+// Windows a box with no Store-installed Python still has `python` on PATH as an+// alias STUB: it exists, exits non-zero, and prints "Python was not found", so a+// name-only choice passes here and then every case dies with an opaque "Command+// failed". Null when there is genuinely none, so the suite skips.+const pyBin = resolveTestPython();+const runPython = (source) => execFileSync(pyBin, ['-c', source, script], {+ encoding: 'utf8',+ timeout: 10_000,+});++// Import the runner as a module without executing main(). Every heavy import+// (torch, diffusers) is deferred inside main(), which is what makes this+// possible in a bare interpreter — no CUDA runtime is installed here.+const importRunner = [+ 'import importlib.util, sys',+ 'from pathlib import Path',+ 'script = Path(sys.argv[1])',+ 'spec = importlib.util.spec_from_file_location("generate_wan22_cuda", script)',+ 'runner = importlib.util.module_from_spec(spec)',+ 'spec.loader.exec_module(runner)',+].join('\n');++describe.skipIf(!pyBin)('generate_wan22_cuda.py', () => {+ // The guard itself is `_checkpoint_index_guard.py`, exercised through+ // generate_minimax_h3_cuda.test.js. What is only true here is that this+ // runner calls it at all — diffusers hands the snapshot straight to+ // accelerate, which has no fixed release for GHSA-4j2p-28q2-5m79, so a+ // missing call is a silent arbitrary-file-read.+ it('screens the snapshot index before diffusers can load it', () => {+ const output = runPython(`${importRunner}\n${[+ 'import argparse, json, tempfile, types',+ 'with tempfile.TemporaryDirectory() as temp:',+ ' snapshot = Path(temp) / "snapshot"',+ ' snapshot.mkdir()',+ ' (Path(temp) / "outside.safetensors").write_text("not a checkpoint")',+ ' (snapshot / "model.safetensors.index.json").write_text(',+ ' json.dumps({"weight_map": {"layer.weight": "../outside.safetensors"}}))',+ ' sys.modules["huggingface_hub"] = types.SimpleNamespace(',+ ' snapshot_download=lambda **kw: str(snapshot))',+ ' def unreachable(*a, **kw):',+ ' raise AssertionError("diffusers reached with an unsafe checkpoint index")',+ ' sys.modules["torch"] = types.SimpleNamespace(cuda=types.SimpleNamespace(',+ ' is_available=unreachable), float32="f32", bfloat16="bf16", Generator=unreachable)',+ ' sys.modules["diffusers"] = types.SimpleNamespace(',+ ' AutoencoderKLWan=types.SimpleNamespace(from_pretrained=unreachable),',+ ' WanPipeline=types.SimpleNamespace(from_pretrained=unreachable))',+ ' sys.modules["diffusers.utils"] = types.SimpleNamespace(export_to_video=unreachable)',+ ' runner.parse_args = lambda: argparse.Namespace(',+ ' model_repo="example/wan", model_revision="main", prompt="p", negative_prompt="",',+ ' width=640, height=640, num_frames=41, fps=24, steps=8, guidance=5.0, seed=1,',+ ' output=str(Path(temp) / "out.mp4"))',+ ' try:',+ ' runner.main()',+ ' except ValueError as exc:',+ ' assert "escapes its component directory" in str(exc), exc',+ ' print("rejected before loading")',+ ' else:',+ ' raise AssertionError("Unsafe index reached the loader")',+ ].join('\n')}`);+ expect(output.trim()).toBe('rejected before loading');+ });+});diff --git a/scripts/requirements-minimax-h3-cuda.txt b/scripts/requirements-minimax-h3-cuda.txtindex 042d144e57..d0087af647 100644--- a/scripts/requirements-minimax-h3-cuda.txt+++ b/scripts/requirements-minimax-h3-cuda.txt@@ -22,9 +22,11 @@ torchao==0.18.0# Qwen3VLForConditionalGeneration + the transformers-side TorchAoConfig.transformers==5.15.0-# GHSA-4j2p-28q2-5m79 has no verified upstream fix (1.15.0 is still affected).-# generate_minimax_h3_cuda.py validates checkpoint indexes before loading.-# Keep the alert open until a verified patched release can replace this pin.+# GHSA-4j2p-28q2-5m79 will NOT be fixed upstream: huggingface/accelerate#4067 was+# closed with "not a real security threat", and both fix PRs were rejected, so+# there is no patched version to move to (1.15.0 is still affected). Every runner+# that hands accelerate a downloaded snapshot screens the checkpoint indexes+# itself first — scripts/_checkpoint_index_guard.py. Do not un-pin expecting a fix.accelerate==1.14.0huggingface_hub==1.27.0