Archived
hfget+deploy: fetch a repo on verified claims, and run with a key argv cannot show
The --model repo-id path trusts the hub with the machine's filesystem and the container runs with the kernel's door off. Both stop here. hfget.sh trusted a listing's file names to be names: an absolute path or a .. segment wrote wherever the destination's owner could write, and a name shadowing .hfget-manifest taught the next run whatever it liked. A listing is now vetted whole before anything is fetched -- absolute paths, .. segments, control characters (a tab splices one entry into two fields), names of hfget's own manifest -- and a child refuses a path that would escape anyway. Silent skipping was the alternative, and it leaves a directory that reads as complete and is not. And the content key was the hub's claim, never checked: an LFS file was kept for its size and its claimed oid recorded without ever hashing the download, so a swapped file of equal length -- or a spliced resume at any length -- passed forever after. The download is hashed on arrival and kept only when it matches the claimed sha256; a mismatch deletes the file, and the manifest now certifies verified content. --model-revision REV fetches at a branch, tag, sha or refs/pr/N instead of the moving main: without it a restart can serve weights nobody reviewed, and the guide now says to name one. --api-key-env NAME reads the key from the environment, where only the process and root can reach it, not the command line where every process on the host reads it in ps; an unset or empty variable refuses startup exactly like an empty --api-key. The compose files carry the key through environment: now -- the fail-closed :? guard moves with it -- across all 52 model files. And the containers' seccomp=unconfined has a way out: Docker's default profile, plus exactly the calls that forced the escape -- io_uring for the n-gram table, mbind/set_mempolicy/get_mempolicy for ROCm's NUMA binding -- is shipped as seccomp-radiance.json and selected through RADIANCE_SECCOMP; the default stays unconfined until each operator audits their own card stack. Verified: under the profile io_uring_setup and set_mempolicy behave as under unconfined and a non-listed syscall earns EPERM. hf_model_test: the escape-listing refusal, the oid verify (bad rejected and deleted, good certified), the pinned revision fetched -- against a fake curl for a hub. config_test: --api-key-env fails closed unset, reads the key set. ASan+UBSan: config/diag/hf_model/server/transport/ wire/lifecycle, 8/8.
This commit is contained in:
1 parent
ad3f03dbc6
commit
1577854d00
62 files changed
+1551
-61
No files matched your search
@@ -49,6 +49,8 @@ static const Flag g_flags[] = {
|
||||
"Hugging Face repo id (owner/name), fetched before startup" },
|
||||
{ "--download-dir", "DIR", "where a repo id is fetched to; default\n"
|
||||
"$XDG_CACHE_HOME/radiance/hf, else ~/.cache/radiance/hf" },
|
||||
{ "--model-revision", "REV", "the hub revision -- a branch, tag, full commit sha or refs/pr/N --\n"
|
||||
"a repo id is fetched at; default the repo's moving main branch" },
|
||||
{ "--radiance-home", "DIRS", "where kernels/, architectures/ and quantizers/ live; several\n"
|
||||
"homes separated by ':' are searched in order, the first winning" },
|
||||
{ "--kernels", "LIST", "the kernel libraries to use, separated by ',' or ':', first wins; unnamed ones are not loaded. Default: every library found" },
|
||||
@@ -213,6 +215,8 @@ static const Flag g_flags[] = {
|
||||
{ "--port", "N", "listen port" },
|
||||
{ "--api-key", "KEY", "require `Authorization: Bearer KEY` or `X-Api-Key: KEY` on every request but /health,\n"
|
||||
" /v1/health, /ping and the dashboard page" },
|
||||
{ "--api-key-env", "NAME", "read the API key from the named environment variable; keeps it off the\n"
|
||||
" command line, where every process on the machine can read it" },
|
||||
{ "--allow-host", "NAME", "a Host name the keyless loopback-only routes (/diagnostics,\n"
|
||||
" /admin/control-vector, the LoRA and session admin) accept besides\n"
|
||||
" localhost; repeatable" },
|
||||
@@ -523,6 +527,7 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
else if (S("-vv")) log_set_level(Log::Trace);
|
||||
else if (S("--model")) { if (!(v = need(i))) return RAD_E_INVAL; c->model = v; }
|
||||
else if (S("--download-dir")) { if (!(v = need(i))) return RAD_E_INVAL; c->download_dir = v; }
|
||||
else if (S("--model-revision")) { if (!(v = need(i))) return RAD_E_INVAL; c->model_revision = v; }
|
||||
else if (S("--radiance-home")) { if (!(v = need(i))) return RAD_E_INVAL; c->radiance_home = v; }
|
||||
else if (S("--kernels")) { if (!(v = need(i))) return RAD_E_INVAL; c->kernel_hierarchy = rad_split_kernel_list(v); }
|
||||
else if (S("--tp")) { if (!num(1, INT32_MAX, &c->tp)) return RAD_E_INVAL; }
|
||||
@@ -823,6 +828,23 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
return RAD_E_INVAL; }
|
||||
c->api_key = v;
|
||||
}
|
||||
else if (S("--api-key-env")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!*v) { RAD_ERR("--api-key-env takes the name of an environment variable");
|
||||
return RAD_E_INVAL; }
|
||||
const char* k = std::getenv(v);
|
||||
/* The empty --api-key refusal's sibling: a unit or compose file whose variable was
|
||||
* never set must not start a server that looks guarded and answers everything
|
||||
* keyless. The name is recorded so the config report can say where the key came
|
||||
* from without showing it. */
|
||||
if (!k || !*k) {
|
||||
RAD_ERR("--api-key-env: %s is unset or empty; refusing to serve keyless under a "
|
||||
"guarded-looking command line", v);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
c->api_key = k;
|
||||
c->api_key_env = v;
|
||||
}
|
||||
else if (S("--allow-host")) {
|
||||
if (!(v = need(i))) return RAD_E_INVAL;
|
||||
if (!*v) { RAD_ERR("--allow-host takes a non-empty name"); return RAD_E_INVAL; }
|
||||
@@ -1269,6 +1291,7 @@ struct ShowRow { const char* flag; Show show; };
|
||||
const ShowRow kShow[] = {
|
||||
{ "--model", [](const Config& c) { return c.model; } },
|
||||
{ "--download-dir", [](const Config& c) { return or_none(c.download_dir, "the XDG cache (~/.cache/radiance/hf)"); } },
|
||||
{ "--model-revision", [](const Config& c) { return or_none(c.model_revision, "the repo's main branch"); } },
|
||||
{ "--radiance-home", [](const Config& c) { return c.radiance_home; } },
|
||||
{ "--kernels", [](const Config& c) {
|
||||
std::string s;
|
||||
@@ -1352,6 +1375,7 @@ const ShowRow kShow[] = {
|
||||
{ "--port", [](const Config& c) { return num(c.port); } },
|
||||
/* Never print the secret, only whether it is set. */
|
||||
{ "--api-key", [](const Config& c) { return std::string(c.api_key.empty() ? "not set" : "set"); } },
|
||||
{ "--api-key-env", [](const Config& c) { return or_none(c.api_key_env, "not used"); } },
|
||||
{ "--allow-host", [](const Config& c) {
|
||||
std::string o;
|
||||
for (const std::string& h : c.allow_hosts) o += (o.empty() ? "" : ",") + h;
|
||||
|
||||
Reference in new issue
Block a user