T08 · Insecure Dependencies
- Location
scripts/train_lora.py:15- Finding
Arbitrary Unpinned Hugging Face Model Repository Loading
- Content
View full analysis
Vulnerability Details
File Location:
scripts/train_lora.py:15,45-48
Vulnerability Type: Unpinned and user-selectable remote model dependency
Risk Level: MediumVulnerable Code
python p.add_argument("--model_id", default="black-forest-labs/FLUX.1-schnell")python pipe = FluxPipeline.from_pretrained( args.model_id, torch_dtype=torch.float32, )Technical Analysis
The
--model_idargument permits the caller to select an arbitrary Hugging Face repository, andFluxPipeline.from_pretrained()downloads model artifacts without specifying an immutablerevisionor verifying expected artifact hashes.This creates a supply-chain trust boundary that is not enforced by the script. A repository may change after the skill has been audited, while an attacker who can influence command-line arguments can redirect loading to an attacker-controlled repository. The code does not require an approved repository, immutable commit, or known artifact digest.
Loading an untrusted model can cause availability and integrity risks through malformed, poisoned, or unexpectedly large artifacts. Depending on the installed versions and model serialization formats supported by the underlying libraries, unsafe serialized artifacts may also increase the risk of code execution during deserialization. The reviewed code does not explicitly enable remote custom code, so remote-code execution is not established as an unconditional outcome.
Attack Path
- An attacker gains influence over the arguments used to invoke
train_lora.py, or compromises a mutable upstream model repository. - The attacker supplies an untrusted repository through
--model_id, or replaces artifacts in the configured repository's unpinned branch. FluxPipeline.from_pretrained()downloads and parses the current repository artifacts.- Malformed or oversized artifacts may exhaust memory or storage and terminate training; ...[truncated 900 chars]
- An attacker gains influence over the arguments used to invoke
- Remediation
View remediation
Remediation Suggestions
- Replace unrestricted
--model_idinput with an allowlist of approved repository identifiers. - Pin every approved model to an immutable Hugging Face commit:
python pipe = FluxPipeline.from_pretrained( approved_model_id, revision="FULL_IMMUTABLE_COMMIT_HASH", torch_dtype=torch.float32, use_safetensors=True, trust_remote_code=False, ) - Require
safetensorsand reject pickle-based formats wherever supported. - Record and verify cryptographic hashes for all expected downloaded artifacts.
- Validate artifact sizes and available disk and memory capacity before loading.
- Run model acquisition and parsing in a restricted environment with minimal filesystem permissions, no unnecessary credentials, and network access limited to approved Hugging Face endpoints.
- Separate model download from training so artifacts can be scanned and approved before use.
- Lock tested versions of
diffusers,transformers,peft,torch, and related dependencies in a dependency lock file.
- Replace unrestricted
