Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ A Pooled room is a set of browsers that split one model's layers and pass the mo

- **Activations are not encryption.** The hidden state that crosses each hop is a lossy transformation of your text. Published attacks reconstruct a large fraction of tokens from mid-model activations (see e.g. [arXiv 2503.09022](https://arxiv.org/abs/2503.09022)). **Assume anyone in your room can read your prompts.** The trust model is "people you would share a document link with", not "strangers".
- **No verification of remote compute.** A peer could return wrong or manipulated activations. Nothing in the current design detects this. Spot-check auditing is on the roadmap and will be documented here when it ships.
- **Weights shared inside the room are not verified either.** A device that is missing a byte range of the model can take it from another device in the room that has it cached (only the length is checked), so a malicious peer could hand out altered weights. That is the same trust a room already places in its peers' compute; `?peerweights=0` turns sharing off. Pinned revisions with hashes are roadmap 19.
- **Weights shared inside the room are not verified either.** A device that is missing a byte range of the model can take it from another device in the room that has it cached (only the length is checked), so a malicious peer could hand out altered weights. That is the same trust a room already places in its peers' compute; `?peerweights=0` turns sharing off. Model URLs are pinned to immutable revisions; cryptographic verification of shared ranges remains roadmap 19.
- **Noise or permutation "privacy" tricks are not used, deliberately.** They are known to be breakable and would give a false sense of safety.
- **Saved prompt state stays on disk.** A room node (`pooled host` / `pooled join`, the OpenClaw plugin) keeps the KV cache of a pinned system prompt + tools in `~/.pooled/cache/ckpt/` (folder 0700, files 0600, at most 4 GB) so a restart does not read the prompt again; each device holds its own layers' part. That state is derived from the prompt, which can be roughly recovered from it: treat the folder like your prompts. Delete it to clear it, or set `POOLED_CKPT_DISK=0` to keep nothing on disk. The browser room keeps its checkpoints in the site's storage (OPFS) the same way.
- **Peers learn metadata** beyond the shared transcript: device names, memory pledges, layer assignments, and timing, via the room roster.
Expand All @@ -38,7 +38,7 @@ In Code mode the room's model writes a small web app and runs it. That code is w

## Model weights and supply chain

Weights are downloaded by each browser directly from public Hugging Face repositories over HTTPS and cached in the browser's Cache API. Pooled ships no weights. The exact file each room runs is identified by its URL and size stamp; verifying a content hash against the upstream repository is planned.
Weights are downloaded by each browser directly from public Hugging Face repositories over HTTPS and cached in the browser's Cache API. Pooled ships no weights. The catalogue pins weights, configuration and tokenizers to immutable Hugging Face revisions. GGUF ranges downloaded through the room’s `rangeFetch` must have the requested offsets, the catalogue file total (when known), and the declared streamed length. Cache keys include the pinned URL, so old mutable-revision entries are not reused. These checks detect wrong or incomplete downloads, but do not authenticate the bytes: cryptographic verification of cached and peer-shared ranges is still planned. `pooled pull` checks a whole-file SHA-256 on a fresh download.

## Reporting a vulnerability

Expand Down
2 changes: 1 addition & 1 deletion packages/openclaw/test/e2e_oc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ try {
const f = { "Qwen3-1.7B-Q8_0.gguf": "models/qwen17/model.gguf", "Qwen_Qwen3.6-35B-A3B-Q4_0.gguf": "models/q36moe/Qwen_Qwen3.6-35B-A3B-Q4_0.gguf" }[route.request().url().split("/").pop()];
return f ? route.continue({ url: `https://127.0.0.1:${PORT + 1}/${f}` }) : route.continue();
});
await ctx.route("https://huggingface.co/Qwen/Qwen3-1.7B/resolve/main/*.json", (route) =>
await ctx.route("https://huggingface.co/Qwen/Qwen3-1.7B/resolve/*/*.json", (route) =>
route.fulfill({ path: path.join(MODELS, "qwen17", route.request().url().split("/").pop()), contentType: "application/json", headers: { "access-control-allow-origin": "*" } }));
await ctx.route("https://cdn.jsdelivr.net/npm/peerjs@1.5.4/dist/peerjs.min.js", (route) => route.fulfill({ path: path.join(NN, "peerjs/dist/peerjs.min.js"), contentType: "text/javascript" }));
page = ctx.pages()[0] || await ctx.newPage();
Expand Down
2 changes: 1 addition & 1 deletion packages/openclaw/test/join_e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ try {
args: ["--no-sandbox", "--enable-unsafe-webgpu", "--ignore-gpu-blocklist", "--allow-loopback-in-peer-connection", "--disable-background-timer-throttling", "--disable-renderer-backgrounding",
"--disable-features=WebRtcHideLocalIpsWithMdns,LocalNetworkAccessChecks,BlockInsecurePrivateNetworkRequests", "--use-gl=angle", "--use-angle=gl-egl", "--enable-features=Vulkan"] });
await ctx.route("**/*.gguf", (route) => route.request().url().endsWith("Qwen3-1.7B-Q8_0.gguf") ? route.continue({ url: `https://127.0.0.1:${PORT + 1}/models/qwen17/model.gguf` }) : route.continue());
await ctx.route("https://huggingface.co/Qwen/Qwen3-1.7B/resolve/main/*.json", (route) =>
await ctx.route("https://huggingface.co/Qwen/Qwen3-1.7B/resolve/*/*.json", (route) =>
route.fulfill({ path: path.join(MODELS, "qwen17", route.request().url().split("/").pop()), contentType: "application/json", headers: { "access-control-allow-origin": "*" } }));
await ctx.route("https://cdn.jsdelivr.net/npm/peerjs@1.5.4/dist/peerjs.min.js", (route) => route.fulfill({ path: path.join(NN, "peerjs/dist/peerjs.min.js"), contentType: "text/javascript" }));
const page = ctx.pages()[0] || await ctx.newPage();
Expand Down
2 changes: 1 addition & 1 deletion packages/room-node/test/e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async function openTab(name, gb) {
return route.fulfill({ status: m ? 206 : 200, body, headers: { "content-type": "application/octet-stream", "content-range": `bytes ${lo}-${hi}/${size}`, "accept-ranges": "bytes",
"access-control-allow-origin": "*", "access-control-expose-headers": "content-range, content-length, accept-ranges" } });
});
await ctx.route("https://huggingface.co/Qwen/Qwen3-1.7B/resolve/main/*.json", (route) =>
await ctx.route("https://huggingface.co/Qwen/Qwen3-1.7B/resolve/*/*.json", (route) =>
route.fulfill({ path: path.join(MODELS, "qwen17", route.request().url().split("/").pop()), contentType: "application/json", headers: { "access-control-allow-origin": "*" } }));
await ctx.route("https://cdn.jsdelivr.net/npm/peerjs@1.5.4/dist/peerjs.min.js", (route) =>
route.fulfill({ path: path.join(NM, "peerjs/dist/peerjs.min.js"), contentType: "text/javascript" }));
Expand Down
12 changes: 11 additions & 1 deletion room.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import { drawCard } from "./room/card.js";
import { probe as preflight, deviceKind } from "./room/preflight.js";
import { pledgeRule, pledgeGB, dealPledgeBytes, afterLoadDeath, offloadFor, ngramFor, storageOf } from "./room/pledge.js";
import { computeScreen } from "./room/compute.js";
import { weightFileBytes } from "./room/models.js";
import { validateWeightRange } from "./room/weight-range.js";
import { CACHE_NAME, PREFIX as CACHE_PREFIX, cacheKey, cachedModels, deleteModel } from "./room/weightcache.js";
import { working, liveWords } from "./room/working.js";
import { partsFromProg, partsFromSnapshot, progressTracker, etaTracker, roomProgress, packParts, unpackParts, wholePct, stepLine, rowVerb,
Expand Down Expand Up @@ -2779,6 +2781,10 @@ async function getWeightCache() {
return weightCache;
}
async function rangeFetch(url, lo, hi, noCache = false) {
const expectedBytes = weightFileBytes(url);
// Header probes can request more than a small model contains. Normalize before
// cache/peer lookup so every source uses the same complete range.
if (expectedBytes != null) hi = Math.min(hi, expectedBytes - 1);
const c = await getWeightCache();
const key = cacheKey(url, lo, hi);
if (c && !noCache) {
Expand Down Expand Up @@ -2815,8 +2821,12 @@ async function rangeFetch(url, lo, hi, noCache = false) {
try { r = await fetch(url, { headers: { Range: `bytes=${lo}-${hi}` } }); }
catch { throw new FetchError(0, url); } // offline, CORS or a blocked host: no status to go on
if (r.status !== 206) throw new FetchError(r.status, url);
r = validateWeightRange(r, lo, hi, expectedBytes);
// Unknown self-hosted files can clamp a header probe at EOF. The response is
// usable, but does not fill this requested cache key's range.
const actualHi = Number(/-(\d+)\//.exec(r.headers.get("content-range"))[1]);
// phones skip the store (no spare RAM for the copy); Cache API refuses 206s, so store as a plain 200
if (c && !myMeta?.phone) storeRange(c, key, r.clone(), hi - lo + 1);
if (c && !myMeta?.phone && actualHi === hi) storeRange(c, key, r.clone(), hi - lo + 1);
return r;
}
// Store a range in the weight cache as it streams (no whole-range copy in JS). A body that errors
Expand Down
47 changes: 31 additions & 16 deletions room/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,28 +408,28 @@ export const DISK_COPY = {
const FLASH_BASE = "https://huggingface.co/bartowski/Qwen3.8-Flash-Next-GGUF/resolve/928589fdb66c6ff07f22ac561e3fbce76553548f/Qwen3.8-Flash-Next-Q4_0/";
export const MODELS = {
"qwen3-0.6b": { label: "Qwen3 0.6B · Q8", kind: "gguf",
gguf: "https://huggingface.co/Qwen/Qwen3-0.6B-GGUF/resolve/main/Qwen3-0.6B-Q8_0.gguf",
cfg: "https://huggingface.co/Qwen/Qwen3-0.6B/resolve/main/config.json",
tok: "https://huggingface.co/Qwen/Qwen3-0.6B/resolve/main/tokenizer.json" },
gguf: "https://huggingface.co/Qwen/Qwen3-0.6B-GGUF/resolve/23749fefcc72300e3a2ad315e1317431b06b590a/Qwen3-0.6B-Q8_0.gguf",
cfg: "https://huggingface.co/Qwen/Qwen3-0.6B/resolve/c1899de289a04d12100db370d81485cdf75e47ca/config.json",
tok: "https://huggingface.co/Qwen/Qwen3-0.6B/resolve/c1899de289a04d12100db370d81485cdf75e47ca/tokenizer.json" },
"qwen3-1.7b": { label: "Qwen3 1.7B · Q8", kind: "gguf",
gguf: "https://huggingface.co/Qwen/Qwen3-1.7B-GGUF/resolve/main/Qwen3-1.7B-Q8_0.gguf",
cfg: "https://huggingface.co/Qwen/Qwen3-1.7B/resolve/main/config.json",
tok: "https://huggingface.co/Qwen/Qwen3-1.7B/resolve/main/tokenizer.json" },
gguf: "https://huggingface.co/Qwen/Qwen3-1.7B-GGUF/resolve/90862c4b9d2787eaed51d12237eafdfe7c5f6077/Qwen3-1.7B-Q8_0.gguf",
cfg: "https://huggingface.co/Qwen/Qwen3-1.7B/resolve/70d244cc86ccca08cf5af4e1e306ecf908b1ad5e/config.json",
tok: "https://huggingface.co/Qwen/Qwen3-1.7B/resolve/70d244cc86ccca08cf5af4e1e306ecf908b1ad5e/tokenizer.json" },
"qwen3-4b": { label: "Qwen3 4B · Q8", kind: "gguf",
gguf: "https://huggingface.co/Qwen/Qwen3-4B-GGUF/resolve/main/Qwen3-4B-Q8_0.gguf",
cfg: "https://huggingface.co/Qwen/Qwen3-4B/resolve/main/config.json",
tok: "https://huggingface.co/Qwen/Qwen3-4B/resolve/main/tokenizer.json" },
gguf: "https://huggingface.co/Qwen/Qwen3-4B-GGUF/resolve/bc640142c66e1fdd12af0bd68f40445458f3869b/Qwen3-4B-Q8_0.gguf",
cfg: "https://huggingface.co/Qwen/Qwen3-4B/resolve/1cfa9a7208912126459214e8b04321603b3df60c/config.json",
tok: "https://huggingface.co/Qwen/Qwen3-4B/resolve/1cfa9a7208912126459214e8b04321603b3df60c/tokenizer.json" },
"qwen3.8-27b": { label: "Qwen3.8 27B \u00b7 Q4", kind: "qwen35",
gguf: "https://huggingface.co/unsloth/Qwen3.8-27B-GGUF/resolve/main/Qwen3.8-27B-Q4_0.gguf" },
gguf: "https://huggingface.co/unsloth/Qwen3.8-27B-GGUF/resolve/4ca720788d1e01f1bff70c033e0d0028fd02e502/Qwen3.8-27B-Q4_0.gguf" },
// mixture of experts: 256 experts, 8 active per token (~3B of 35B), so decode reads far less than the 27B
"qwen3.6-35b-moe": { label: "Qwen3.6 35B MoE \u00b7 Q4", kind: "qwen35",
gguf: "https://huggingface.co/bartowski/Qwen_Qwen3.6-35B-A3B-GGUF/resolve/main/Qwen_Qwen3.6-35B-A3B-Q4_0.gguf" },
gguf: "https://huggingface.co/bartowski/Qwen_Qwen3.6-35B-A3B-GGUF/resolve/5c2410d71524f4f72b023ce8daf7a80528226d5f/Qwen_Qwen3.6-35B-A3B-Q4_0.gguf" },
// 256 experts, 8 active (~10B of 122B), 48 layers, 16 query heads per kv head. Two files (shards: the loaders read
// both, room/models.js mergeSplitHeaders). In the ?dev=1 list, not the picker: 72 GB of weights, a room of big
// machines (or a PC that offloads its experts to RAM: room/plan.js), tests/test_moe.js MODEL=122b, `pooled pull`
"qwen3.5-122b-moe": { label: "Qwen3.5 122B MoE \u00b7 Q4", kind: "qwen35",
gguf: "https://huggingface.co/bartowski/Qwen_Qwen3.5-122B-A10B-GGUF/resolve/main/Qwen_Qwen3.5-122B-A10B-Q4_0/Qwen_Qwen3.5-122B-A10B-Q4_0-00001-of-00002.gguf",
shards: ["00001", "00002"].map((n) => `https://huggingface.co/bartowski/Qwen_Qwen3.5-122B-A10B-GGUF/resolve/main/Qwen_Qwen3.5-122B-A10B-Q4_0/Qwen_Qwen3.5-122B-A10B-Q4_0-${n}-of-00002.gguf`) },
gguf: "https://huggingface.co/bartowski/Qwen_Qwen3.5-122B-A10B-GGUF/resolve/fec8b222a2eddc3346d6b6d7f7c85efea93cd6bf/Qwen_Qwen3.5-122B-A10B-Q4_0/Qwen_Qwen3.5-122B-A10B-Q4_0-00001-of-00002.gguf",
shards: ["00001", "00002"].map((n) => `https://huggingface.co/bartowski/Qwen_Qwen3.5-122B-A10B-GGUF/resolve/fec8b222a2eddc3346d6b6d7f7c85efea93cd6bf/Qwen_Qwen3.5-122B-A10B-Q4_0/Qwen_Qwen3.5-122B-A10B-Q4_0-${n}-of-00002.gguf`) },
// Qwen3.8-Flash-Next (roadmap/33): 512 experts, 10 active (~6B of 125B), a 4-stream residual and a 28.8 GB n-gram
// table read from disk by the device holding layer 1. ?dev=1 only, like the 122B: its own engine (engine/qwen4exp.js,
// PR #346; room/flash.js adapts it to the room), context <= 2048 until QSA (CTX). Pinned revisions: FILES' sizes and
Expand All @@ -439,11 +439,26 @@ export const MODELS = {
shards: ["00001", "00002", "00003"].map((n) => `${FLASH_BASE}Qwen3.8-Flash-Next-Q4_0-${n}-of-00003.gguf`),
mtp: "https://huggingface.co/ggml-org/Qwen3.8-Flash-Next-GGUF/resolve/052beeaca7bec4a303e59cc7bc630c4f3a1b845d/mtp-Qwen3.8-Flash-Next-Q4_0.gguf" },
"smollm-135m": { label: "SmolLM 135M · bf16", kind: "safetensors",
st: "https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/resolve/main/model.safetensors",
cfg: "https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/resolve/main/config.json",
tok: "https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/resolve/main/tokenizer.json" },
st: "https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/resolve/12fd25f77366fa6b3b4b768ec3050bf629380bac/model.safetensors",
cfg: "https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/resolve/12fd25f77366fa6b3b4b768ec3050bf629380bac/config.json",
tok: "https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct/resolve/12fd25f77366fa6b3b4b768ec3050bf629380bac/tokenizer.json" },
};

// The expected total of this exact file, including split GGUFs. An unknown URL has no
// catalogue size: self-hosted/test models still get HTTP offset and stream-length checks.
export function weightFileBytes(url) {
for (const [key, M] of Object.entries(MODELS)) {
const F = FILES[key];
if (!F) continue;
if (M.mtp === url && F.mtp) return F.mtp.bytes;
if (M.shards?.length) {
const i = M.shards.indexOf(url);
if (i >= 0) return F.shards?.[i]?.bytes ?? null;
} else if (M.gguf === url) return F.bytes;
}
return null;
}

// Context window per room, in tokens: prompt + answer. Each full-attention layer keeps K and V
// for this many positions (4 KB per position each for the 27B, so 16 MiB per attention layer at
// 2048); the kernels only use it as a stride. Generation stops before the cache would overflow.
Expand Down
70 changes: 70 additions & 0 deletions room/weight-range.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Validate HTTP weight ranges before loaders or the raw cache consume them. This
// checks placement and byte count, not content hashes; synthetic cache/peer 200s
// have their own checks and must not pass through this HTTP-only helper.
export class WeightRangeError extends Error {
constructor(message, kind, status) {
super(message);
this.name = "WeightRangeError";
this.kind = kind;
this.status = status;
}
}

// Return a response with the original status and headers and a counted body.
// Only one upstream read runs per downstream pull, with no additional queued
// chunks. A request past EOF may end at total - 1; other truncated ranges fail.
// Completion is checked at EOF, including after the expected last byte.
export function validateWeightRange(response, lo, hi, expectedBytes = null) {
const status = response.status;
const reject = (message, kind) => {
const error = new WeightRangeError(message, kind, status);
try { response.body?.cancel(error).catch(() => {}); } catch { /* already consumed */ }
throw error;
};
if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi) || lo < 0 || hi < lo || !Number.isSafeInteger(hi - lo + 1))
reject("Invalid requested weight range", "range");
if (expectedBytes != null && (!Number.isSafeInteger(expectedBytes) || expectedBytes <= lo))
reject("Invalid expected weight file size", "range");
if (status !== 206) reject(`Weight range request returned HTTP ${status}, expected 206`, "status");

const match = /^bytes (\d+)-(\d+)\/(\d+)$/i.exec((response.headers.get("content-range") || "").trim());
if (!match) reject("Weight range response has no valid Content-Range", "range");
const [start, end, total] = match.slice(1).map(Number);
if (![start, end, total].every(Number.isSafeInteger) || start !== lo || total <= lo || end !== Math.min(hi, total - 1))
reject(`Weight range response does not match bytes ${lo}-${hi}`, "range");
if (expectedBytes != null && total !== expectedBytes)
reject(`Weight file size changed: received ${total} bytes, expected ${expectedBytes}`, "range");
const length = end - start + 1;
const contentLength = response.headers.get("content-length");
if (contentLength != null && (!/^\d+$/.test(contentLength) || Number(contentLength) !== length))
reject(`Weight range Content-Length does not match ${length} bytes`, "length");
if (!response.body) reject("Weight range response has no body", "length");

const reader = response.body.getReader();
let got = 0;
const body = new ReadableStream({
async pull(controller) {
try {
const { value, done } = await reader.read();
if (done) {
if (got !== length) throw new WeightRangeError(`Short weight range: received ${got} of ${length} bytes`, "length", status);
controller.close();
reader.releaseLock();
return;
}
if (!(value instanceof Uint8Array)) throw new WeightRangeError("Weight range body contains invalid bytes", "length", status);
got += value.byteLength;
if (got > length) throw new WeightRangeError(`Long weight range: received more than ${length} bytes`, "length", status);
controller.enqueue(value);
} catch (error) {
controller.error(error);
try { reader.cancel(error).catch(() => {}); } catch { /* already closed */ }
reader.releaseLock();
}
},
async cancel(reason) {
try { await reader.cancel(reason); } finally { reader.releaseLock(); }
},
}, { highWaterMark: 0 });
return new Response(body, { status, statusText: response.statusText, headers: response.headers });
}
Loading