Files
llmgw/internal/control/catalog/pickle_test.go
T
Ilker ManapandClaude Opus 5.5 4466d2d15a
CI / test (push) Successful in 8m57s
Weights that run code are refused
Python pickles (.bin, .pt, .pth, .ckpt, .pkl) run whatever they hold when
loaded, as the engine's user, on the node; that is how the malicious models
found on Hugging Face work. The node refuses such a source, or a mirror set
holding one, before fetching anything. A model added with one, or given
one, is refused, while one already in the catalog still loads and is
refused by its node with the same words. vLLM and SGLang downloading a
model by its id get --load-format safetensors. The mirror page marks the
file. allow_pickle: true on a model lets it through on purpose, carried to
the node in EngineProfile.allow_pickle.

BACKLOG M lists the rest: checksums against Hugging Face on every path,
its own scan, trusted publishers, engines without the internet, an eval
before an untrusted model serves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:17:22 +01:00

31 lines
1.1 KiB
Go

package catalog
import (
"strings"
"testing"
)
func TestAModelInAPickleFormatIsRefusedUnlessItSaysSo(t *testing.T) {
m := Model{Name: "triposr", Source: "hf:stabilityai/TripoSR/model.ckpt",
Adapters: []Adapter{{Name: "a", Source: "http://m/a/adapter_model.bin"}}}
err := m.CheckPickle()
if err == nil || !strings.Contains(err.Error(), "model.ckpt") || !strings.Contains(err.Error(), "allow_pickle") {
t.Fatalf("not refused, or not said why: %v", err)
}
if got := m.PickleSources(); len(got) != 2 {
t.Errorf("pickle sources %v, want the model's and the adapter's", got)
}
// A source that was there before is not asked about again: changing
// the scaling of a model that runs does not need allow_pickle.
if err := m.CheckPickle(m.PickleSources()...); err != nil {
t.Errorf("sources already there were refused: %v", err)
}
m.AllowPickle = true
if err := m.CheckPickle(); err != nil {
t.Errorf("allow_pickle was not honoured: %v", err)
}
if err := (Model{Name: "q", Source: "http://m/q/v/q-Q4_K_M.gguf"}).CheckPickle(); err != nil {
t.Errorf("a GGUF was refused: %v", err)
}
}