AIDEFEND in Action AIA-0169 Validated Research

Unsloth Studio: Selecting a Model Ran the Python Code Shipped in Its Repository

Pillar Security researcher Ariel Fogel reported that Unsloth Studio ran Python code from a model repository on Hugging Face (the public hub where AI models are published and downloaded) as soon as an operator selected that model in the interface. Unsloth is an open-source library for fine-tuning and quantizing large language models, and Studio is its browser-based interface, still labelled beta. The problem sat in the step where Studio's backend inspects what a model can do: it read the model's config.json through the AutoConfig loader of Transformers (Hugging Face's Python library for loading and running models), and that inspection path left trust_remote_code enabled by default. trust_remote_code is the Transformers option that lets a loader download and run Python files shipped in a model repository. An auto_map entry in config.json could therefore point the loader at a configuration.py file in the same repository and have it executed, before any load, training or export action, and without consulting the user's own setting, which defaults to off. Pillar reproduced this with a harmless proof-of-concept repository on unsloth 2026.5.10. It reports the issue for unsloth 2026.5.10 and earlier and confirmed the fix in 2026.6.9. The maintainers disputed Pillar's security assessment, shipped the fix, and declined to publish the advisory, so no CVE (the public identifier assigned to a disclosed vulnerability) exists for it. There is currently no public evidence that this technique has been used in a real attack.

Remote Code ExecutionMalicious ModelsSupply Chain DefenseRuntime IsolationHugging Face
6 applicable AIDEFEND defenses

Threat Analysis

  • How choosing a model became code execution. A Hugging Face model repository can hold Python code next to its weights and configuration. The Transformers library lets config.json declare an auto_map entry that points AutoConfig, AutoModel or the tokenizer at custom Python files in the repository, and it imports and runs those files only when the calling code enables trust_remote_code. In Studio, the calling code was the backend's own capability check. Pillar reports that in the 2026.5.10 release, load_model_config(...) in studio/backend/utils/models/model_config.py declared trust_remote_code: bool = True, the check for vision and other capabilities called it without passing a value, and a separate Transformers 5 subprocess branch hardcoded the same value. Selecting a model therefore made Studio download config.json and whatever files auto_map named, and run them. The same check is reachable over HTTP at GET /api/models/config/{model_name:path} and GET /api/models/check-vision/{model_name:path}.
  • What the attacker needs, and what the proof of concept showed. The attacker publishes a model repository and needs a person who runs Studio to select it. Pillar's proof-of-concept repository set "auto_map": {"AutoConfig": "configuration.UnslothPocConfig"} in config.json, pointing at a configuration.py file beside it. After the researcher started Studio, signed in and picked that repository in the model picker, the backend downloaded and ran the module: the operating system's calculator opened and a line was appended to ~/UNSLOTH_POC_RCE.txt. No weights were loaded and no inference ran. This was a researcher test with a harmless payload in an environment Pillar controlled. The post reports no real victims and does not describe how an operator would be led to a particular repository.
  • Why the existing safeguards were not on this boundary. Studio requires a password and its backend listens on the loopback address by default, but the person who triggers the code is the signed-in operator. Both controls decide who can reach the backend, not what the backend does with the model that person selects. The user's own trust_remote_code setting defaults to off, yet it governs only the load, train and export path; the capability check never consulted it. Hugging Face describes its Hub scanning in its own documentation as "not 100% foolproof" and leaves the responsibility for checking a repository with the user, and Pillar notes that its repository was not flagged because the code is harmless at rest.
  • What the code could reach. The repository code runs inside the Studio backend process with the operator's permissions. Pillar lists what could follow from that: theft of Hugging Face tokens, SSH keys and cloud credentials; tampering with model weights and with training or inference outputs; persistence on the host and lateral movement to other systems. The reach is wider when Studio is started with -H 0.0.0.0 and so listens on every network interface, runs in Colab (Google's hosted notebook service), or is shared by several users on a self-hosted machine. These are consequences Pillar derives from arbitrary code execution; what it demonstrated is the harmless proof of concept.
  • Report, fix and disagreement. Pillar reported the issue privately in early June 2026 through a GitHub security advisory (GHSA-pc2m-72c4-r38q, which remains unpublished). A commit dated June 18, 2026, titled "Harden model fetching (#6391)", changed both True values to False, made capability detection read the raw config.json, and added a consent step before repository code may run. Pillar then re-tested release 2026.6.9, which PyPI (the Python package index) lists as released on June 22, 2026, and confirmed that neither a Hugging Face repository nor a local model directory triggered the issue. According to Pillar, the maintainers disputed its security assessment, arguing that Hugging Face's malware scanning was an adequate control and that Studio is beta; they shipped the fix and declined to publish the advisory, so no CVE was assigned. On November 24, 2026 the project's GitHub security advisories page still listed none. For a deploying team, the practical effect is that scanners which match installed packages against advisory databases will not report this flaw; at most they report the separate loader flaw described next.
  • The same default in other tools, and a separate later Unsloth flaw. Pillar lists three 2026 CVE records with the same cause in other tools for deploying, serving or training large language models, and each record matches its description: LMDeploy 0.12.3 and earlier hardcode trust_remote_code=True at several Hugging Face model-loading call sites (CVE-2026-46432); vLLM 0.14.1 hardcodes it in two model implementation files, which overrides the user's --trust-remote-code=False (CVE-2026-4944); and InstructLab's linux_train.py hardcodes it when loading models (CVE-2026-6859). Separately, a Pillar write-up dated October 27, 2026 describes a different Unsloth flaw, tracked as CVE-2026-93348: a model_type value in config.json that contains a line break can append attacker Python to an import statement that unsloth_zoo passes to exec() when a model is loaded for training or inference, and trust_remote_code=False does not prevent it. That flaw affects unsloth from 2025.9.9 up to but not including 2026.8.20. It is a different code path from the Studio check, but it means 2026.6.9 is not a sufficient upgrade target.

Applicable AIDEFEND Defenses (6)

AID-H-003.010
Deployed AI Software Vulnerability Remediation Lifecycle
Very High
The platform team that owns notebooks, GPU hosts, container images and managed runtimes should read back the unsloth and unsloth_zoo versions actually installed in each environment, not only what the lockfiles say. The Studio flaw has no advisory or CVE of its own, so a scanner that compares installed packages with advisory databases has no record for it. The same installations may be flagged for the separate loader flaw CVE-2026-93348, but that record says nothing about Studio. The team therefore has to enter its own notice with the affected range Pillar gives and assign an owner and a deadline to every environment where Studio can be started. This step finds the exposed population and repairs nothing by itself. The repair is to rebuild or reinstall every one of those environments on a fixed release, which removes the defect at its source: Pillar re-tested 2026.6.9 and found that neither a Hugging Face repository nor a local model directory runs repository code during capability inspection. Aim for a current release instead of stopping at 2026.6.9, because unsloth 2026.8.20 is the first release that no longer installs an unsloth_zoo version affected by that loader flaw. Close the work from versions read back on running hosts and images, long-lived workstations included. A repository whose custom code an operator later approves will still run that code.
AID-H-003.002
CI/CD Release Gating, Model Artifact Signing & Secure Distribution
High
A model repository is code as well as data, so the decision about which repositories a fine-tuning host may open belongs at the internal model mirror, before any tool inspects them. Applying the release acceptance checklist there means hosts take models only from the mirror, trust_remote_code stays off and loading stays offline by default, and a repository that needs custom code is admitted only with a named approval and a sandbox analysis verdict. An unreviewed repository that carries an auto_map module can then not be downloaded by the Studio backend at all. The checklist is written for promotion to production, so the team has to extend the mirror-only rule to fine-tuning and evaluation hosts itself, and an approved custom-code repository still executes its code.
AID-I-001.004
Sandbox Network Egress Restrictions
High
If the host that runs Studio can reach both the public Hub and arbitrary other addresses, the backend can download an attacker's repository, and the code it then runs can send tokens out or fetch a second stage. Blocking outbound connections by default and allowing only the internal mirror, at a gateway, proxy or host firewall that the Studio process cannot reconfigure, stops the download and the outbound transfer alike. Where the Hub itself stays on the allowlist the download is not prevented, and a mirror that fetches from the Hub on demand is a relay, not a boundary.
AID-I-001.002
MicroVM & Low-Level Sandboxing
High
Code that arrives with a model repository should run where there is nothing worth stealing. Placing the Studio backend in a hardware-virtualized microVM or a userspace-kernel sandbox that holds no long-lived Hugging Face write token, SSH key or cloud credential keeps repository code away from the host and from those credentials. The datasets, model outputs and any token the job itself needs remain within its reach, and the chosen sandbox runtime has to support the GPU the workload uses. On a single workstation where that is not practical, launching Studio under bubblewrap or Landlock without mounting the credential files in the home directory is a lighter local measure. It hardens a development machine and is not the boundary a shared or production host should rely on.
AID-D-004.004
Model Source & Namespace Drift Detection
Medium
Once fine-tuning hosts are meant to use only the internal mirror, a DNS query or connection from one of them to huggingface.co or hf.co means the rule was bypassed or never applied to that host. Alerting on that traffic from DNS, proxy or flow logs lets the team find a Studio instance that still pulls repositories straight from the Hub. The alert reveals the gap after the fact and says nothing about whether the downloaded repository was malicious.
AID-E-001.001
Root & Long-Lived Credential Object Eviction
Medium
This applies only after exposure, meaning a Studio release earlier than 2026.6.9 selected a repository the team cannot vouch for. The operator and the owners of each credential should then list what that backend process could read, including the Hugging Face token, SSH keys and cloud access keys, invalidate each one at its issuer, hand replacements to consumers that have been cleaned, and confirm that the old values are rejected. Deleting the files on the host does not help, because a copied credential keeps working. Nothing in the public record shows that such an exposure occurred.

What Defenders Should Do Now

  • Find every installed copy and move it to a fixed release. In notebook kernels, training hosts, container images and managed runtimes such as Databricks, read the installed versions with pip show unsloth unsloth_zoo or from the image's package list. The check passes when every environment where Studio can be started has unsloth 2026.6.9 or later. To close the later loader flaw as well, also confirm that unsloth_zoo is 2026.8.14 or later; unsloth 2026.8.20 is the first release that no longer accepts an older unsloth_zoo. No advisory exists for the Studio flaw, so record it as an internal remediation item instead of waiting for a scanner finding.
  • Confirm the fix on an isolated host. On a test host that holds no credentials, create a model directory of your own whose config.json has an auto_map entry pointing at a Python file that only writes a marker file, then select it in Studio. The check passes when no marker file appears unless you explicitly approve running the repository's code.
  • Decide where models may come from, and test it from the host. Let hosts that run Studio take models only from an internal mirror or from reviewed snapshots pinned to a commit, and admit repositories that need custom code only with a named approval. Banning trust_remote_code outright is not realistic, because Pillar notes that mainstream models such as IBM Granite Speech and Vision and DeepSeek-OCR depend on it; that is why each exception needs a named owner. Then test from the Studio host itself: connections to huggingface.co, to an arbitrary external IP address and to the cloud metadata service (the internal address a cloud instance uses to obtain its own temporary credentials) should be blocked by a control outside the Studio process, while the mirror stays reachable.
  • Keep credentials away from the Studio backend. Run Studio in a sandbox or a dedicated virtual machine that contains no long-lived Hugging Face write token, SSH key or cloud credential. Verify from inside, as the backend's user, that those credential files cannot be read and that the cloud metadata service cannot be reached.
  • If an older Studio selected a model you cannot vouch for, treat the host as having run untrusted code. Transformers copies the Python files it imports from a model repository into its dynamic-module cache, by default ~/.cache/huggingface/modules/transformers_modules/ unless the environment sets another Hugging Face home directory, so look there for repository code you do not recognize. Code that ran can delete those files, so an empty directory proves nothing. Then revoke and replace, at each issuer, the tokens and keys that process could read, confirm the old ones are rejected, and review the models and training outputs the host produced.

2 additional considerations

Look for the same default in your own loading code

The pattern Pillar documents is a tool that enables trust_remote_code on the user's behalf. The same line can sit in a team's own training scripts, evaluation harnesses and notebooks.
Recommendation: The teams that own this code can add a static check in CI that flags hardcoded trust_remote_code=True and parameters that default to on, and require a reviewed exception that names the repository and the pinned commit wherever the option is really needed. The check covers only source the team can scan; third-party tools still depend on version inventory and isolation.

Narrow the Hugging Face token on fine-tuning hosts

Hugging Face offers fine-grained tokens that can be limited to specific repositories, and a fine-tuning host usually needs to read only a few.
Recommendation: On hosts that run Studio, use a token that can only read the repositories the work needs, and move publishing, which needs write access, into a separate job. This does not stop code from running, but a stolen token can then not be used to overwrite models the team has already published.

Conclusion

A model repository can carry code as well as weights, and in this case the code ran at a step no operator reads as risky: choosing a model from a list. The maintainers' fix is what closes the path, and AIDEFEND  maps the case to the remediation lifecycle for deployed AI software: find every installed copy and prove from version readback that it reached a fixed release. Because no advisory will prompt that work, the team has to start it. Around the fix, AIDEFEND  points to three boundaries the deploying team controls: a model mirror that keeps trust_remote_code off unless a named exception is approved, outbound connections enforced outside the Studio process, and a sandbox that keeps tokens and keys out of the backend's reach. When the next tool ships the same default, those boundaries are already in place.

Last updated: