From b2b3851f85a0ce85c9f08b3e11afaffd89c78d56 Mon Sep 17 00:00:00 2001 From: orbisai0security Date: Wed, 22 Jul 2026 03:38:48 +0000 Subject: [PATCH 1/3] fix: trailofbits.python.pickles-in-pytorch.pickles-in-pytorch security vulnerability Automated security fix generated by OrbisAI Security --- scripts/export_joyvasa_audio.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/export_joyvasa_audio.py b/scripts/export_joyvasa_audio.py index 360bb67..6bba77d 100644 --- a/scripts/export_joyvasa_audio.py +++ b/scripts/export_joyvasa_audio.py @@ -68,7 +68,8 @@ def main() -> None: sys.path.insert(0, str(args.source)) from src.modules.hubert import HubertModel - payload = torch.load(args.checkpoint, map_location="cpu", weights_only=False) + from safetensors.torch import load_file as _safe_load_file + payload = {"model": _safe_load_file(str(args.checkpoint))} config = HubertConfig.from_json_file(str(args.hubert_config)) encoder = HubertModel(config).eval() encoder_prefix = "audio_encoder." From 03f1cbb2c285eaecbe1d9afab3be98c08c912fd5 Mon Sep 17 00:00:00 2001 From: Anupam Mediratta Date: Wed, 22 Jul 2026 12:28:28 +0530 Subject: [PATCH 2/3] fix: use weights_only=True with explicit safe globals for torch.load Replaces weights_only=False with weights_only=True and an explicit add_safe_globals allowlist ([argparse.Namespace, PosixPath]) in both JoyVASA export scripts. This is the sanctioned PyTorch mitigation for the trailofbits pickles-in-pytorch semgrep pattern: only the known-safe non-default classes are allowlisted; all others are rejected by the restricted unpickler. Checkpoint format, SHA-256 pins, and all downstream payload accesses are unchanged. Co-Authored-By: Claude Sonnet 4.6 --- scripts/export_joyvasa_denoiser.py | 11 ++++++----- scripts/export_joyvasa_runtime.py | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/export_joyvasa_denoiser.py b/scripts/export_joyvasa_denoiser.py index 48d9aa6..ee164b7 100644 --- a/scripts/export_joyvasa_denoiser.py +++ b/scripts/export_joyvasa_denoiser.py @@ -1,8 +1,8 @@ """Export the pinned JoyVASA diffusion denoiser to a browser-oriented ONNX graph. -The checkpoint pickle global list must be audited before running this script. The -pinned checkpoint currently contains only argparse.Namespace, pathlib.PosixPath, -collections.OrderedDict, and PyTorch tensor rebuild/storage globals. +The checkpoint contains argparse.Namespace, pathlib.PosixPath, collections.OrderedDict, +and PyTorch tensor rebuild/storage globals. The non-default classes are explicitly +allowlisted via add_safe_globals; all others are rejected by weights_only=True. """ from __future__ import annotations @@ -11,7 +11,7 @@ import argparse import hashlib import json import sys -from pathlib import Path +from pathlib import Path, PosixPath import numpy as np import onnx @@ -54,7 +54,8 @@ def main() -> None: dit_module.enc_dec_mask = cpu_enc_dec_mask DenoisingNetwork = dit_module.DenoisingNetwork - payload = torch.load(args.checkpoint, map_location="cpu", weights_only=False) + torch.serialization.add_safe_globals([argparse.Namespace, PosixPath]) + payload = torch.load(args.checkpoint, map_location="cpu", weights_only=True) checkpoint_args = payload["args"] checkpoint_expected = { "n_diff_steps": 50, diff --git a/scripts/export_joyvasa_runtime.py b/scripts/export_joyvasa_runtime.py index f847cad..94e8cc7 100644 --- a/scripts/export_joyvasa_runtime.py +++ b/scripts/export_joyvasa_runtime.py @@ -6,7 +6,7 @@ import argparse import hashlib import json import pickle -from pathlib import Path +from pathlib import Path, PosixPath import numpy as np import torch @@ -32,7 +32,8 @@ def main() -> None: if sha256(args.template) != EXPECTED_TEMPLATE_SHA256: raise RuntimeError("Unexpected JoyVASA motion template") - payload = torch.load(args.checkpoint, map_location="cpu", weights_only=False) + torch.serialization.add_safe_globals([argparse.Namespace, PosixPath]) + payload = torch.load(args.checkpoint, map_location="cpu", weights_only=True) # The pinned 3.6KB pickle was audited before use and contains only a dict, # NumPy ndarray reconstruction, ndarray, and dtype globals. with args.template.open("rb") as handle: From d689b896878e730d2e59cf6a4ba2864ca841c1a4 Mon Sep 17 00:00:00 2001 From: Anupam Mediratta Date: Wed, 22 Jul 2026 12:40:44 +0530 Subject: [PATCH 3/3] fix: replace safetensors load with weights_only=True in audio export script export_joyvasa_audio.py was using safetensors.torch.load_file() on a native PyTorch checkpoint, which fails with SafetensorError. Replace with torch.load(..., weights_only=True) and an explicit add_safe_globals allowlist ([argparse.Namespace, PosixPath]), consistent with the other two JoyVASA export scripts. Co-Authored-By: Claude Sonnet 4.6 --- scripts/export_joyvasa_audio.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/export_joyvasa_audio.py b/scripts/export_joyvasa_audio.py index 6bba77d..b1f2ddc 100644 --- a/scripts/export_joyvasa_audio.py +++ b/scripts/export_joyvasa_audio.py @@ -12,7 +12,7 @@ import argparse import hashlib import json import sys -from pathlib import Path +from pathlib import Path, PosixPath import numpy as np import onnx @@ -68,8 +68,8 @@ def main() -> None: sys.path.insert(0, str(args.source)) from src.modules.hubert import HubertModel - from safetensors.torch import load_file as _safe_load_file - payload = {"model": _safe_load_file(str(args.checkpoint))} + torch.serialization.add_safe_globals([argparse.Namespace, PosixPath]) + payload = torch.load(args.checkpoint, map_location="cpu", weights_only=True) config = HubertConfig.from_json_file(str(args.hubert_config)) encoder = HubertModel(config).eval() encoder_prefix = "audio_encoder."