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.

Studio: flag a modules.json folder of only dots and slashes that leaves the model (#14527)

Daniel Hanb5156323919e
diff --git a/studio/backend/tests/test_account_path_confinement.py b/studio/backend/tests/test_account_path_confinement.py
index c4b6c4a9950..ecc9e0ca94d 100644
--- a/studio/backend/tests/test_account_path_confinement.py
+++ b/studio/backend/tests/test_account_path_confinement.py
@@ -364,3 +364,21 @@ def test_an_export_base_whose_index_escapes_is_refused(tmp_path):
)
(adapter / "adapter_config.json").write_text(json.dumps({"base_model_name_or_path": str(base)}))
assert _checkpoint_load_refusal(str(adapter), str(base))
+
+
[email protected]("path", ["..", "../..", "/", "\\", "./..", "..\\.."])
+def test_a_module_folder_of_only_dots_and_slashes_outside_the_model_is_flagged(tmp_path, path):
+ from utils.security.file_security import escaping_weight_references
+ folder = _write(
+ tmp_path / "st", {"modules.json": [{"idx": 0, "name": "0", "path": path, "type": "x"}]}
+ )
+ assert escaping_weight_references(folder) == [path]
+
+
[email protected]("path", ["", ".", "./"])
+def test_a_module_at_the_model_root_is_not_flagged(tmp_path, path):
+ from utils.security.file_security import escaping_weight_references
+ folder = _write(
+ tmp_path / "st", {"modules.json": [{"idx": 0, "name": "0", "path": path, "type": "x"}]}
+ )
+ assert escaping_weight_references(folder) == []
diff --git a/studio/backend/utils/security/file_security.py b/studio/backend/utils/security/file_security.py
index 38bb1a55377..e9dc5966530 100644
--- a/studio/backend/utils/security/file_security.py
+++ b/studio/backend/utils/security/file_security.py
@@ -133,11 +133,14 @@ def escaping_weight_references(folder) -> list:
modules = None
for module in modules if isinstance(modules, list) else []:
sub = module.get("path") if isinstance(module, dict) else None
- if not isinstance(sub, str) or not sub.strip("./\\"):
+ if not isinstance(sub, str):
continue
+ # Before the self-folder skip: "..", "../.." and "/" are only dots and slashes too.
if _escapes_folder(sub):
names.append(sub)
continue
+ if not sub.strip("./\\"):
+ continue
names.extend(_in_subfolder(sub, name) for name in _weight_names(folder / sub))
# Spark-TTS / BiCodec load their transformers model from LLM/.
if (folder / "LLM").is_dir():