Skip to content

Fix unsafe shard-path loading in pinned Diffusers runtimes #34

Open

Description

@pirumpi

Summary

Research/reproduction date: 2026-09-06. Tapioca revision: efe7a55d6e4641daecf7b35c9e04201c96c29f78 (v0.12.0).

The image runtime pins Diffusers 0.39.0 and the video runtime permits >=0.38,<0.40, excluding the released upstream fix for unsafe shard filenames in checkpoint indexes. Both Tapioca entry scripts load local model directories through from_pretrained(..., local_files_only=True); local-only loading does not prevent this path traversal.

This is dependency/loader hardening for existing image and video support, not a request to add new models. No malicious catalog model, user-file disclosure, network exfiltration or successful exploit against a running Tapioca app was observed.

Official sources and exact affected artifacts

Affected data is weight_map in a sharded checkpoint index such as diffusion_pytorch_model.safetensors.index.json. No particular first-party weight artifact is alleged to be malicious. Diffusers itself is Apache-2.0 and publicly accessible; existing model-specific licenses remain unchanged.

Safe reproduction

Extracted the actual _get_checkpoint_shard_files function from official v0.39.0 source and invoked it with a fully mocked filesystem and an in-memory checkpoint index. No model weights or outside files were read. For model directory /demo/model with local_files_only=True:

  • ../outside.safetensors returned /demo/model/../outside.safetensors (escapes the model directory).
  • /demo/outside.safetensors returned that absolute outside path.
  • shard-00001.safetensors returned an ordinary path inside the model directory.

The same harness against official v0.40.0 rejects both unsafe inputs with ValueError while accepting the ordinary filename. This verifies the pinned dependency defect and the upstream correction; it is not an end-to-end exploit demonstration.

Implementation plan

  1. Qualify a fixed released Diffusers version for both image and video runtimes, or apply an auditable narrow backport if an existing pipeline blocks the upgrade.
  2. Add fail-closed shard-index validation before loading, with appropriate containment/symlink handling for supported platforms. Preserve supported Hub-cache layouts; do not assume any symlink is malicious.
  3. Ensure already-created runtime environments receive the fix. Merely changing a requirements file is insufficient if installation is skipped for an existing venv; revise runtime cache versioning or dependency-health migration as needed.
  4. Keep the current model catalog/defaults unchanged during this security qualification. Review 0.40's API/dependency/LoRA behavior changes before a broad pin bump.

Acceptance tests

  • Parent-directory, absolute and cross-platform separator cases fail before any outside checkpoint read.
  • Normal sharded models and legitimate cache layouts still load offline.
  • Both a fresh runtime and an existing pre-upgrade runtime use the fixed loader.
  • CUDA image/video and Apple MPS image regressions cover currently advertised pipelines; generated outputs remain valid.
  • Catalog manifest/checksum, catalog/adapter tests and runtime tests remain green.

Platforms, architecture and hardware

Scope: diffusers image on NVIDIA CUDA (Windows x64/Linux), diffusers-mps image on Apple Silicon, and diffusers-video on NVIDIA CUDA. The bug is checkpoint-loader logic independent of model architecture and GPU capacity. A CPU-only mock test is sufficient for the regression; existing model-specific hardware tiers apply for generation qualification. llama.cpp, MLX/mflux, ONNX/DirectML and managed-ComfyUI H3 are not asserted to be affected by these particular pins.

Risks, evidence limits and duplicate check

Loading an attacker-controlled or tampered model/index is the relevant precondition. This audit does not claim arbitrary files can be exported or code executed solely through this defect. Follow upstream evidence and validate application-level reachability during the fix.

Reddit evidence: not applicable to proof; the official upstream security fix and direct loader reproduction are authoritative. Searched all open/closed Tapioca issues for Diffusers, shard, path traversal and likely symptom. Historical #29 is ecosystem reporting; closed #23 is a different import-shadowing bug. No matching issue was found.

Activity

  1. pirumpi commented on Sep 18, 2026

    @pirumpi
    ContributorAuthor

    Draft PR #40 now pins the fixed Diffusers 0.40.0 image/video runtimes and forces fresh runtime environments. A normal Apple Silicon MPS smoke generated a valid 512x512 PNG from the existing SD Turbo model; an opt-in hardware smoke test is committed. CUDA image/video qualification remains, so the issue stays open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions