Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix: prevent ai-assist model config RCE via untrusted Hugging Face repos (#4274)

Daniel Han88c7b08faa76
diff --git a/studio/backend/core/inference/inference.py b/studio/backend/core/inference/inference.py
index c4788b6cbba..ec3e2ba971b 100644
--- a/studio/backend/core/inference/inference.py
+++ b/studio/backend/core/inference/inference.py
@@ -751,7 +751,7 @@ class InferenceBackend:
# Step 2: Format with tokenizer.apply_chat_template()
try:
- if not (hasattr(tokenizer, 'chat_template') and tokenizer.chat_template):
+ if not (hasattr(tokenizer, "chat_template") and tokenizer.chat_template):
raise ValueError(
f"Model '{self.active_model_name}' has no chat_template set in its "
f"tokenizer_config.json. This is usually a problem with the model's "
diff --git a/studio/backend/utils/datasets/llm_assist.py b/studio/backend/utils/datasets/llm_assist.py
index 398d73cdcc8..c5892bfbc26 100644
--- a/studio/backend/utils/datasets/llm_assist.py
+++ b/studio/backend/utils/datasets/llm_assist.py
@@ -515,7 +515,12 @@ def _run_multi_pass_advisor(
try:
from utils.models.model_config import load_model_config
- config = load_model_config(model_name, use_auth = True, token = hf_token)
+ config = load_model_config(
+ model_name,
+ use_auth = True,
+ token = hf_token,
+ trust_remote_code = False,
+ )
archs = getattr(config, "architectures", [])
if archs and "Gemma3nForConditionalGeneration" in archs:
is_gemma_3n = True
diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.py
index 960e263cb2c..23ef9b2cbb0 100644
--- a/studio/backend/utils/models/model_config.py
+++ b/studio/backend/utils/models/model_config.py
@@ -383,7 +383,10 @@ for canonical_file, model_names in MODEL_NAME_MAPPING.items():
def load_model_config(
- model_name: str, use_auth: bool = False, token: Optional[str] = None
+ model_name: str,
+ use_auth: bool = False,
+ token: Optional[str] = None,
+ trust_remote_code: bool = True,
):
"""
Load model config with optional authentication control.
@@ -392,18 +395,23 @@ def load_model_config(
if token:
# Explicit token provided - use it
return AutoConfig.from_pretrained(
- model_name, trust_remote_code = True, token = token
+ model_name, trust_remote_code = trust_remote_code, token = token
)
if not use_auth:
# Load without any authentication (for public model checks)
with without_hf_auth():
return AutoConfig.from_pretrained(
- model_name, trust_remote_code = True, token = None
+ model_name,
+ trust_remote_code = trust_remote_code,
+ token = None,
)
# Use default authentication (cached tokens)
- return AutoConfig.from_pretrained(model_name, trust_remote_code = True)
+ return AutoConfig.from_pretrained(
+ model_name,
+ trust_remote_code = trust_remote_code,
+ )
# VLM architecture suffixes and known VLM model_type values.