trust-remote-code and model supply chain risk in vLLM

vLLM can run Python code shipped inside a model repository when trust-remote-code is enabled. This page explains how to decide that, and how to pin, mirror and protect model artifacts.

On this page

Why trust-remote-code is a supply chain decision in vLLM

The --trust-remote-code flag lets code shipped inside a model repository run on your serving host, so enabling it is a supply chain decision, not a tuning setting. Before a team turns it on for a model family, it should decide who publishes the code, which revision it trusts, and whether that code can reach the rest of the environment. vLLM is an Apache-2.0 licensed, community-maintained inference engine, so the license permits you to use and modify it, but nobody vets the custom model code that individual model repositories bring with them. The vLLM recipe for DeepSeek-V3 passes the flag in its examples, which is why teams planning that model family often meet the question first in a recipe rather than in a policy review.

The vLLM security guide warns that some cache formats support arbitrary code execution, which widens the surface beyond the flag itself. A model that loads without the flag can still leave artifacts in cache directories that a later process reads, so the cache location, its permissions and the users that can write to it belong in the same decision. Ask the model owner which repository and revision the team will load, whether the repository ships Python files that the loader will import, and whether the serving account can write to the directories vLLM uses for downloads and caches. Confirm each answer against your own environment and the current vLLM security guide before the first production load.

When to allow trust-remote-code and when to refuse it

Some published vLLM recipes pass --trust-remote-code. The DeepSeek-V3 recipe is one example, so teams should check the flag in every recipe they follow rather than assume it is absent or present. When a recipe requires the flag, the decision is not whether the flag is safe in general but whether this specific repository's custom code is acceptable to run on your hosts. Treat the flag as a request to execute Python shipped with the model, and review it as code.

  • Read the recipe line by line: Confirm which flags it sets and whether the model repository includes custom modeling or configuration files.
  • Inspect the repository code: Review the Python files the flag would load, including imports, network calls and file writes, before the first run.
  • Pin the revision: Record the exact commit hash of the model repository and of the recipe, and load only that revision.
  • Mirror the approved snapshot internally: Serve weights and code from an internal store so production hosts do not fetch from the public hub at startup.
  • Sign-off: The security team approves the reviewed revision, and the platform owner records the approval with the deployment.

Before go-live, confirm that the approved revision hash in the deployment matches the reviewed one.

Pinning, mirroring and protecting model weights in vLLM

This sequence turns an approved model into a pinned, internally mirrored artifact that vLLM loads from a protected cache, so the served weights and code can be traced to a reviewed revision. Security, platform and ML engineering teams each own part of it.

  1. Approve the model source and owner

    The security or platform owner confirms which model repository, publisher and license are allowed for the use case, and records who is accountable for updates. Scope the approval to a named model and organization account, not a general category of models. The step is done when the approval record names the repository, the owner, the license review outcome and the environments where the model may run. Confirm the license terms with your legal team, since the model license is separate from the vLLM Apache-2.0 license.

  2. Review any repository code before use

    Before any code in the model repository is allowed to run, an engineer reads the custom modeling, tokenizer and configuration files that the repository ships alongside the weights. Look for Python files referenced through auto_map or similar config entries, and for any install or download steps they perform. The step is done when the reviewer has a written list of executable files, a decision for each one, and the exact revision they reviewed. If the repository ships no custom code, record that finding, because it removes the main reason to enable the flag.

  3. Pin a specific model revision

    The ML platform engineer selects a full commit hash for the approved model, rather than a branch name such as main, and records it in the deployment configuration. Mutable references can change after review, so the pin is what ties the review to what will load. The step is done when the commit hash appears in the deployment manifest, the approval record and the review record, and all three match. Ask the model publisher or your own registry whether the commit is signed or otherwise verifiable.

  4. Copy the pinned weights into an internal store

    The platform team downloads the reviewed revision once, from a controlled network path, and copies the weights, tokenizer and config files into an internal object store or artifact registry. Vendor-side changes then cannot reach production silently, and the team can scan the files and keep a checksum for each one. The step is done when every file in the pinned revision has a stored checksum that matches the reviewed copy, and the internal location is the only source referenced by the serving configuration.

  5. Set the cache directory with restricted ownership

    The operations team creates a dedicated model cache directory for the vLLM service account, owned by that account and readable only by the processes that need it. Other users on the host and the container should not be able to write to it. The security guide warns that some cache formats support arbitrary code execution, so write access to the cache is effectively write access to the model. The step is done when a permissions check shows no group or world write access, and a test write from a second account fails.

  6. Start vllm serve with the flag only where approved

    The platform engineer starts vllm serve pointing at the internal store and the protected cache, and adds --trust-remote-code only for models whose review approved executable repository code. Many recipes, including the DeepSeek-V3 example, pass the flag, so copy it only after checking whether the model actually needs it. The step is done when the startup command in the deployment manifest matches the approval record, and the service logs show the flag state the reviewer approved.

  7. Confirm the served revision matches the pin

    After the service starts, the engineer compares the loaded model artifacts and their checksums against the pinned revision and the stored copy. The check should also confirm that the endpoint reports the expected model identifier and that the service did not fetch any file from the public hub. The step is done when the comparison record is signed off and stored with the change ticket. Repeat this check after every restart, image change or vLLM upgrade, because each of those can alter what is loaded.

Configuration options that change model code execution risk

This table compares the vLLM settings and loading choices that decide whether a model repository can run code on your server, and when each one fits. Read each row as a control you set in the serving configuration, with its trade-off on availability, reproducibility and maintenance. The main takeaway is that enabling remote code is a per-model decision, and the safer options work only when they are paired with pinned revisions and controlled storage.

OptionWhen it fitsTrade-off and what to confirm
--trust-remote-code flagOnly for a specific model whose architecture needs custom Python code, reviewed before deploymentLets repository code execute on the host. Some vLLM recipes, such as DeepSeek-V3, pass it. Confirm exact behavior in the vLLM security guide before enabling it.
Leaving trust-remote-code offModels that load with the built-in architectures, which is the default posture for most approved modelsFails fast on models that need custom code, so the team must find a supported alternative or review the code. Confirm which models in your catalog need the flag.
Pinned model revisionEvery production model, so the weights and any repository code stay identical across restarts and rebuildsRequires a review step for each upgrade and a record of the commit used. Confirm the revision option and how it applies to tokenizer and config files in the vLLM docs.
Local or internal weights pathWhen models are mirrored to storage you control and reviewed before being promotedRemoves runtime downloads from public hosts, but the team must maintain the mirror, its access controls and its integrity checks.
Hugging Face cache locationWhen the cache directory sits on a restricted volume owned by the service account and is not shared with other workloadsCached files can be reused without review. The security guide warns about cache formats that support arbitrary code execution, so confirm which formats your version reads.
Offline loading with --enable-offline-docs or offline mode settingsAir-gapped or egress-restricted hosts where the server must not reach model hubs at startupStartup fails if a required file is missing from the mirror. Confirm which offline settings apply to model weights, not only to documentation.
Chat template from the model or --chat-templateModels that ship a chat template, or a template you have reviewed and stored with the deploymentA template supplied by an external repository changes how prompts are formatted. A reviewed local template gives a fixed input, but it must be tested against each model version.

Risks a malicious or compromised model repository introduces

A model repository is more than weight files. It can carry Python that runs when the model loads, revisions that change after review, cache entries that can execute code, and dependencies and network calls that happen at startup. Each card below names one of these threats and the control from the setup section that limits it.

Repository code runs on load

When --trust-remote-code is set, custom modeling and configuration code from the model repository is imported and executed inside the vLLM process. Anyone who can publish or alter that code gains execution on the inference host, with access to the GPU node, mounted secrets and the internal network. Control: leave the flag off by default and enable it only for a named model after someone has read the repository code. Check whether the recipe you follow requires it before you copy its command line.

DeepSeek-V3 recipe

Revision changes after approval

A model name points to a branch, so the weights and code behind it can change without any change on your side. A model you tested in staging may be a different artifact on the next pod restart. Control: pin every model to a specific commit revision in the deployment manifest, record the revision in your change log, and fail startup when the revision is not the approved one. Repeat the check whenever a dependent model is updated.

Cache entries that execute code

The model cache holds downloaded files and derived artifacts. Some serialization formats can run code when deserialized, so a poisoned cache file can execute on the next load even if the repository itself looks clean. Control: restrict the cache directory to the service account, use read-only mounts where the platform allows it, and prefer tensor formats that do not carry executable code. The vLLM security guide's cache directory section describes the formats to avoid.

vLLM security guide

Unreviewed dependencies pulled at start

Custom model code often imports packages that are not part of your vLLM image. If the container installs them at startup, the inference host installs whatever the latest matching version is at that moment. Control: bake the exact dependency versions into the image at build time, scan that image, and block runtime installs with network policy and a read-only root filesystem. Ask the model owner for the full list of imports before approval.

Unintended network fetches during load

Model loading can reach out to hubs, auxiliary model repositories, or URLs named inside configuration files. A compromised file can use that path to pull more code or to send data out, and a host with open egress makes the fetch succeed silently. Control: allow egress only to your internal mirror, set offline mode where the stack supports it, and log DNS and outbound connections during the first load of each new model. Confirm the exact offline settings in your vLLM release notes before you rely on them.

How model artifacts move from source to the vLLM server

The path starts with a model publisher who posts weights and any custom code to a public model repository. Your team downloads one pinned revision into an internal review step, where the files and any remote code are checked before they enter the internal mirror. The pinned cache directory is populated only from the mirror, and the vLLM server loads the model from that cache. Check that each hop uses the same revision hash and that the cache directory is writable only by the service account.

Model artifacts cross one trust boundary before the vLLM server loads them.

Questions teams ask before allowing model code in vLLM

Can we avoid the trust-remote-code flag entirely?

Often yes, but it depends on the models you plan to serve. The flag tells vLLM to load Python code bundled inside a model repository, and some model families need it to build their architecture. Before you standardize, list each model you intend to run and check whether its vLLM recipe or model card passes --trust-remote-code. The vLLM DeepSeek-V3 recipe is one example that does. Models that run on vLLM's built-in architectures can usually be served without the flag, so the practical question is how many of your target models need it. Keep a per-model record of the decision so an exception does not become a global setting by accident.

How long does a model code review take, and who does it?

The duration depends on the number of models, the size of the code each repository ships, and how deep the review goes. Your security or platform team usually owns the decision, with an engineer reading the bundled Python files, the configuration and any tokenizer or processor code. A quick review checks for network calls, file writes, subprocess use and dynamic imports. A deeper review also covers the model's dependencies and the revision you intend to pin. Ask any partner to state the review depth and the models in scope in the written scope before work starts, because the same model can take very different time at each depth.

What does the work need from our team?

The work needs a named owner for the approval decision, an engineer who can read Python and the vLLM configuration, and access to the environment where models will run. Your team should also provide the list of target models, the approved model sources, and the place where internal mirrors will live. Security needs to agree on the review criteria before the first model is reviewed, so that approvals are consistent. Plan time for an exception process, because a model that needs the flag will come up again when a new version ships.

Can our own team run this review and mirror process?

Yes, if you have engineers who can read model code and operate an internal artifact store. Your team pays for its own time and infrastructure, and the work recurs whenever you add a model or update a pinned revision. The main gaps are usually review depth, documented criteria and the discipline to re-check revisions. DeployOpen implements and tests these controls in infrastructure you control and can prepare the review checklist and evidence, but the decision on which models you accept stays with your organization. Ask for a written scope that names the deliverables, so you can compare it with what your team would build.

What drives the effort of this work up or down?

Three factors drive most of the effort. The first is the number of models, because each repository and each revision needs its own review. The second is review depth, from a pattern scan to a line-by-line reading with sandboxed test runs. The third is mirror tooling: a team with an existing artifact store and a process for pinned revisions has far less to build than a team starting from nothing. Recurring costs include re-review when a model updates, storage for mirrored weights and the staff time to handle exceptions. When you request a quote, ask how each of these factors was counted.

How do the cache directories fit into this decision?

Cache directories hold downloaded weights and tokenizer files, and the vLLM security guide warns about cache formats that support arbitrary code execution. Treat the cache as part of the supply chain: restrict write access to the service account, keep it off shared volumes where other workloads can write, and clear it when a revision is retired. Confirm the exact cache formats and paths for your vLLM version in the security guide before you set file permissions, since defaults can differ across releases.

Does allowing model code change our compliance evidence?

It can. An approval that runs arbitrary code in your serving environment is a control decision that auditors will want to see documented. Keep a record for each model: the source, the pinned revision, the review result, the approver and the date. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors and certification bodies make the assessment. Ask your assessor which evidence they expect before you start the review.

Limits to confirm in your environment

The trust-remote-code decision rests on facts that change between releases and between model repositories. Confirm each item below against the vLLM version you actually run, because the flag behavior, recipe examples and cache handling can shift with the release cadence.

Flag behavior in your release

Releases ship about every two weeks, so the default behavior, the warnings printed at startup and the scope of the flag can change between the version you tested and the version you deploy. Pin the exact version in your deployment and read its release notes for anything touching remote code. For example, v0.31.0 shipped on October 5, 2026, so a build from before that date should be re-checked before you promote it. Confirm the flag behavior on a staging host, not from memory of an older guide.

vLLM releases

Recipes that require the flag

Some published recipes pass --trust-remote-code in their example commands, including the DeepSeek-V3 recipe. A recipe example is not a statement that the model needs the flag in every configuration, and a copied command can enable remote code for a model that does not need it. Review each recipe you adopt, record why the flag is present, and decide whether a model-specific exception is justified.

DeepSeek-V3 recipe

Cache format support

The security guide warns that some cache formats support arbitrary code execution. Confirm which cache formats your release loads, whether any of them can be reached from a model repository you do not control, and whether the cache directory is writable only by the service account. Treat the cache as executable input, not as passive data, and document which formats your team has approved.

vLLM security guide

Mirror revision preservation

An internal mirror of model weights only protects you if it keeps the exact commit or revision you reviewed. Check that your mirror tooling copies the revision hash, the configuration and any custom Python files together, and that it does not silently refresh files from upstream. Test by changing an upstream file in a sandbox repository and confirming the mirror does not pick up the change until you approve it.

Pinned revisions in serving config

Confirm that every model load in your serving configuration names a specific revision rather than a branch such as main. A branch name can move between a review and a restart, so a model that passed review may load different code later. Check the deployment manifests, startup scripts and any gateway configuration that passes a model identifier, and record who approves a revision change.

Operating the model supply chain after go-live

The model supply chain needs ongoing work after go-live because the risk changes each time a model, revision or engine version changes. Treat every new model revision as a new intake, not as a routine update. Re-run the review for --trust-remote-code and for any custom model code, confirm the pinned revision hash still matches what was approved, and check whether the chat template or tokenizer files changed. Keep the internal weight mirror as the only source the serving hosts can reach, so a silent upstream change cannot reach production without passing through the same approval.

Track the vLLM release stream and its security advisories as a standing task with a named owner. vLLM ships new minor releases about every two weeks, with v0.31.0 dated October 5, 2026 in the supplied release history, so the reader should expect a steady flow of changes to review. For each release, confirm whether it alters how model code is loaded, how caches are read, or which parser or loader paths are used, and record the decision to upgrade or defer. Ask your team to confirm the exact release currently running in each environment, since fleets often drift across clusters.

Audit the model cache directory on a schedule. Compare the files present against the approved manifest of model names, revisions and checksums, and flag any file or format that was not part of the approval. The vLLM security guide's cache directory section covers formats that can support arbitrary code execution, so confirm which cache formats your deployment writes and who can write to them. Keep the approval record for each model: who reviewed it, the decision, the pinned revision, the mirror location and the date. Auditors typically ask for this trail, and it is the evidence that the controls operated over time. For related hardening, the vLLM security guide covers the wider controls.

How DeployOpen scopes and delivers model supply chain controls

DeployOpen approaches trust-remote-code and model supply chain risk in vLLM as a scoped piece of work inside your own infrastructure. We agree which models, repositories and recipes are in play, decide with your security team which code paths may run, and then build and document the controls so your reviewers can check them.

How we scope

  • Inventory every model repository, recipe and launch command your teams plan to use with vLLM.
  • Record where each model needs --trust-remote-code and which owner accepts that risk in writing.
  • Agree in writing which cache directories, mirrors and revision pins are in the fixed-scope deliverables.
  • Confirm the scope with your security and compliance leads before any build work starts.

How we build

  • Set the trust-remote-code default off in launch configuration, with exceptions documented per model.
  • Pin model revisions and record checksums so a deployed model matches the reviewed version.
  • Mirror approved weights into storage you control and restrict write access to the model cache.
  • Test that unreviewed repositories fail to load and that cache formats are limited to approved types.

How we hand over

  • Deliver a model intake procedure covering review, approval, pinning and mirroring steps.
  • Document each exception to the trust-remote-code default with its owner, reason and review date.
  • Provide configuration files, cache permission settings and test results for your reviewers to inspect.
  • Walk your platform and security engineers through the procedure and the upgrade check it requires.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Re-check pinned revisions and exceptions when new vLLM releases or recipe changes arrive.
  • Retest the model intake controls after significant configuration or infrastructure changes.
  • Confirm retainer terms, response expectations and included testing in the written quote.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.