Refuse profile env and args that would run code or touch files on the nodes
env is an allowlist of tuning families less path, plugin, library, address and credential names (NCCL_*_PLUGIN, CUDA_INJECTION64_PATH and the like got through the old denylist); llama.cpp's LLAMA_ARG_* are checked as flags. args refuse --trust-remote-code, --log-file, --slot-save-path, --tool-parser-plugin, --middleware, --allowed-local-media-path and others that read, write or load, and what the agent sets itself. Checked in the catalog and again on the node before an engine starts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c522e8b2aa
commit
c19abe95e1
6 files changed
+241
-21
No files matched your search
@@ -440,6 +440,9 @@ func (m Model) validate() error {
|
||||
m.Name, p.Name, k, why)
|
||||
}
|
||||
}
|
||||
if err := engines.UnsafeArgs(p.Engine, p.Args); err != nil {
|
||||
return fmt.Errorf("model %q profile %q: %w", m.Name, p.Name, err)
|
||||
}
|
||||
|
||||
if p.GPUClass == "" && !cpuCapable(p.Engine) {
|
||||
return fmt.Errorf("model %q profile %q: gpu_class is required for engine %q",
|
||||
|
||||
@@ -385,3 +385,21 @@ func TestARepositoryPageIsReadAsTheRepositoryForVLLM(t *testing.T) {
|
||||
t.Errorf("a file under /resolve/ is a source: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAModelThatWouldRunCodeOnItsNodesIsRefusedWhereItIsDefined(t *testing.T) {
|
||||
for _, p := range []Profile{
|
||||
{Name: "p", Engine: "vllm", GPUClass: "h100-80g", TP: 1, Args: []string{"--trust-remote-code"}},
|
||||
{Name: "p", Engine: "llamacpp", MinMemoryGB: 4, Args: []string{"--log-file", "/etc/cron.d/x"}},
|
||||
{Name: "p", Engine: "vllm", GPUClass: "h100-80g", TP: 1, Env: map[string]string{"NCCL_NET_PLUGIN": "/tmp/x.so"}},
|
||||
{Name: "p", Engine: "vllm", GPUClass: "h100-80g", TP: 1, Env: map[string]string{"CUDA_INJECTION64_PATH": "/tmp/x.so"}},
|
||||
} {
|
||||
if _, err := New([]Model{model("m", p)}); err == nil {
|
||||
t.Errorf("accepted %v %v", p.Args, p.Env)
|
||||
}
|
||||
}
|
||||
ok := Profile{Name: "p", Engine: "llamacpp", MinMemoryGB: 4, Args: []string{"--ctx-size", "16384"},
|
||||
Env: map[string]string{"OMP_NUM_THREADS": "8"}}
|
||||
if _, err := New([]Model{model("m", ok)}); err != nil {
|
||||
t.Errorf("a tuned model was refused: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user