From 2e1c1515ec566619dd4f67273d580065fb1ea1ee Mon Sep 17 00:00:00 2001 From: Robert Moir <130709596+zephyrnova@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:42:48 -0700 Subject: [PATCH 1/2] Stop the capability scan reporting hosts the add-on never contacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three defects, all found by running the scan over the two submissions open since the last review round rather than over the ones it was written from. The network host list missed every scheme but HTTP. video-chat (#21) signals over `wss://agents-chat.hyperpg.site` and relays through `stun:stun.l.google.com:19302`, and the enumeration a reviewer is told to judge named neither — it listed `localhost` and `github.com`, both harvested from the add-on's README. A list that silently omits the only two hosts an add-on talks to is worse than no list, because it reads as a complete one. The submitter noticed and wrote the real hosts into the pull request body by hand, which is the work this is supposed to have done for him. Prose is now separated from code. A README sentence containing the word "WebSocket" is not an egress site; hosts named only in documentation are reported under their own heading, so a reviewer can tell a link from a relay. Same for a lockfile's `resolved` URLs, which stage 4c already gates as registry-hosted and pinned, and for `xmlns` namespace declarations, which are identifiers and are never fetched. The Studio submission (#22) enumerated nine hosts; four of them are real and the other five were npm's and the W3C's. And `.exec(` is RegExp.prototype.exec. Any scanner, validator or syntax highlighter uses it, so the "native/process execution" category fired twice on the Studio's own manifest validator. The dotted bare form is excluded; the named variants have no RegExp counterpart and still match, and a `cp.execSync` is reached through `child_process` regardless. None of these is a gate, so none of them blocked anyone. They spend the reviewer attention the automation exists to protect, which is the same cost paid later. Signed-off-by: Robert Moir <130709596+zephyrnova@users.noreply.github.com> --- scripts/adjudicate/adjudicate.mjs | 35 +++++++++++++++++++++++++++---- scripts/adjudicate/policy.mjs | 20 ++++++++++++++++-- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/scripts/adjudicate/adjudicate.mjs b/scripts/adjudicate/adjudicate.mjs index 0484e2e..ac6547d 100644 --- a/scripts/adjudicate/adjudicate.mjs +++ b/scripts/adjudicate/adjudicate.mjs @@ -384,21 +384,48 @@ function main() { } // ── Stage 5: capability scan → JUDGMENT QUEUE (never a gate) ────────────── + // Prose is not code. A README sentence containing the word "WebSocket" is + // not an egress site, and a link in it is not a host the add-on contacts. + // Reading the two as one list is how video-chat (#21) enumerated as + // reaching `localhost` and `github.com` — both from its README — while its + // actual relay and STUN server appeared nowhere in the list at all. + const isDoc = (p) => /\.(md|markdown|txt)$/i.test(p) || /(^|\/)(LICENSE|NOTICE)$/.test(p); + + // A lockfile's `resolved` URLs are build-time fetches, and stage 4c already + // gates every one of them as registry-hosted and pinned. Repeating them here + // buries the handful of run-time hosts this list exists to surface: the + // Studio's own two became nine once npm's were mixed in. + const isLockfile = (p) => /(^|\/)package-lock\.json$/.test(p); + // `xmlns="http://www.w3.org/2000/svg"` names an XML namespace. Nothing is + // fetched from it, and an icon file is not an egress site. + const isNamespaceDecl = (t) => /\bxmlns(:\w+)?\s*=/.test(t); + const hosts = new Set(); + const docHosts = new Set(); for (const cat of SCAN_CATEGORIES) { const items = []; for (const f of files) { const p = pathOf(f); + if (isDoc(p)) continue; for (const { line, text } of f.added) { if (cat.patterns.some((re) => re.test(text))) items.push({ file: p, line, text: text.trim().slice(0, 160) }); } } if (items.length) queue.push({ category: cat.label, key: cat.key, items }); } - for (const f of files) - for (const { text } of f.added) - for (const m of text.matchAll(URL_RE)) hosts.add(m[1]); - if (hosts.size) notes.push(`Network hosts referenced (no allowlist exists yet — judge each): ${[...hosts].join(", ")}`); + for (const f of files) { + const p = pathOf(f); + if (isLockfile(p)) continue; + const into = isDoc(p) ? docHosts : hosts; + for (const { text } of f.added) { + if (isNamespaceDecl(text)) continue; + for (const m of text.matchAll(URL_RE)) into.add(m[1] ?? m[2]); + } + } + for (const h of hosts) docHosts.delete(h); + if (hosts.size) notes.push(`Network hosts referenced in code (no allowlist exists yet — judge each): ${[...hosts].join(", ")}`); + else notes.push("No network host appears in the submitted code — judge that against what the add-on says it does."); + if (docHosts.size) notes.push(`Hosts named only in documentation, never in code: ${[...docHosts].join(", ")}`); // ── optional: vocabulary drift check against the app source ─────────────── if (args.appSrc) checkVocabDrift(args.appSrc); diff --git a/scripts/adjudicate/policy.mjs b/scripts/adjudicate/policy.mjs index e8c663f..26f873e 100644 --- a/scripts/adjudicate/policy.mjs +++ b/scripts/adjudicate/policy.mjs @@ -202,7 +202,13 @@ export const SCAN_CATEGORIES = [ patterns: [ /\bchild_process\b/, /\bspawn(Sync)?\s*\(/, - /\bexec(File)?(Sync)?\s*\(/, + // `.exec(` on its own is RegExp.prototype.exec, which any scanner, + // validator or syntax highlighter uses — so a dotted bare `exec` is + // excluded and only the unqualified call is kept. The named variants + // have no RegExp counterpart and stay matchable either way; a + // `cp.execSync()` is still reached through child_process above. + /(? Date: Fri, 27 Nov 2026 11:32:13 -0700 Subject: [PATCH 2/2] Close the blind spots this branch opened, and one it inherited MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The review pass over this branch before merging found that two of its three fixes traded a false positive for a place a payload could hide. Both are the same mistake: a scan that refuses to read a file reports the same "(none)" as a scan that read it and found nothing. Documentation is scanned again, and labelled instead. Skipping `.md`, `.txt`, LICENSE and NOTICE for every category was too broad, because Node executes those files perfectly happily when something asks it to — CJS `require('./NOTICE')` and `node tools/build.txt` both do — so a build or main-process module could keep its payload in a file no category would look at. Verified: a `.txt` carrying `child_process`, `execSync` and an exfiltration host returned no items flagged. The prose problem this was reaching for is real, but it is a problem about HOSTS, and the host split below already solves it. Here the fix is to say where a match came from, so a reviewer can discount a README sentence without the scan guessing on their behalf. The namespace skip now removes the attribute, not the line. Dropping any line containing `xmlns=` meant a real host could hide behind the token: `fetch("https://evil.tld/x") /* xmlns= */` vanished from the host list entirely, and stage 5 does not strip comments. Only the quoted attribute value is removed now, so an SVG's namespace is still excluded and anything else on the line is still read. And one blind spot this branch did not open but does reach. An in-addon `.gitattributes` containing `*.js -diff` makes `git format-patch` emit `GIT binary patch` for every JavaScript file in the submission; the parsed patch then has no added lines, every scan sees empty files, and the judgment queue comes back `(none)`. Verified: a file containing `child_process`, `exec(`, `eval(` and a `wss://` host produced `VERDICT: PASS — no items flagged`. It is inside `addons//`, so stage 1's containment check has nothing to say about it, and it was not a sensitive path. Two layers, deliberately. `.gitattributes` and `.mailmap` are now sensitive paths — the first can suppress a diff, the second can rewrite the authorship a reviewer sees — and separately stage 1 refuses any text file delivered as a binary patch at all. The second exists because the attribute can be set somewhere other than the add-on's own directory, and a gate should not rest on having enumerated every route to the thing it is gating. The gates that read the post-patch TREE rather than the patch were never affected by any of this, which is why none of it changed a verdict. That is also what made it worth fixing: the capability scan is the reviewer's agenda, and an agenda that silently empties is worse than no agenda. Signed-off-by: Robert Moir <130709596+zephyrnova@users.noreply.github.com> --- scripts/adjudicate/adjudicate.mjs | 61 ++++++++++++++++++++++++++++--- scripts/adjudicate/policy.mjs | 17 +++++++++ 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/scripts/adjudicate/adjudicate.mjs b/scripts/adjudicate/adjudicate.mjs index ac6547d..e5d3a49 100644 --- a/scripts/adjudicate/adjudicate.mjs +++ b/scripts/adjudicate/adjudicate.mjs @@ -95,6 +95,7 @@ function parsePatch(text) { aPath: m ? m[1] : null, bPath: m ? m[2] : null, added: [], isNew: false, isDeleted: false, isRename: false, modeExec: false, isSymlink: false, isSubmodule: false, + isBinary: false, }; files.push(cur); newLine = 0; @@ -105,6 +106,13 @@ function parsePatch(text) { if (line.startsWith("deleted file mode ")) { cur.isDeleted = true; flagMode(cur, line); continue; } if (line.startsWith("old mode ") || line.startsWith("new mode ")) { flagMode(cur, line); continue; } if (line.startsWith("rename from ") || line.startsWith("rename to ")) { cur.isRename = true; continue; } + // A file arriving as a binary patch contributes NO added lines, so every + // scan that reads `added` silently sees an empty file rather than skipping + // a known-unreadable one. Recorded so the caller can tell the difference. + if (line.startsWith("GIT binary patch") || /^Binary files .* differ$/.test(line)) { + cur.isBinary = true; + continue; + } if (line.startsWith("--- ")) { if (line === "--- /dev/null") cur.isNew = true; continue; } if (line.startsWith("+++ ")) { if (line === "+++ /dev/null") cur.isDeleted = true; @@ -204,6 +212,28 @@ function main() { gate("1 scope: no symlinks added", symlinks.length === 0, symlinks.join(", ")); gate("1 scope: no submodules added", submodules.length === 0, submodules.join(", ")); + // Source that arrives as a binary patch is source nothing downstream can + // read. Every scan works from the patch's added lines, so a file with none + // is indistinguishable from an empty file — the capability scan reports + // `(none)` and reads as a clean result rather than as an unread one. + // + // The route is an in-addon `.gitattributes` saying `*.js -diff`, which is now + // a sensitive path above; this gate is the second layer, because the attribute + // can also be set elsewhere and because a gate should not depend on having + // enumerated every way of reaching it. + const SCANNABLE_EXT = /\.(ts|tsx|js|jsx|mjs|cjs|html|css|json|md|txt|ya?ml)$/i; + const binarySource = files + .filter((f) => f.isBinary && SCANNABLE_EXT.test(pathOf(f) || "")) + .map(pathOf); + gate( + "1 scope: no text file delivered as a binary patch", + binarySource.length === 0, + binarySource.length + ? `${binarySource.join(", ")} — these carry no readable diff, so every scan below sees them ` + + `as empty rather than as unread` + : "", + ); + // ── Stage 2: applies cleanly to base ────────────────────────────────────── let applies = false; try { @@ -398,7 +428,11 @@ function main() { const isLockfile = (p) => /(^|\/)package-lock\.json$/.test(p); // `xmlns="http://www.w3.org/2000/svg"` names an XML namespace. Nothing is // fetched from it, and an icon file is not an egress site. - const isNamespaceDecl = (t) => /\bxmlns(:\w+)?\s*=/.test(t); + // + // Only the ATTRIBUTE is removed, not the line. Dropping the whole line let a + // real host hide behind the token: `fetch("https://evil.tld/x") /* xmlns= */` + // disappeared from the list entirely, and stage 5 does not strip comments. + const withoutNamespaceDecls = (t) => t.replace(/\bxmlns(:\w+)?\s*=\s*(["'])[^"']*\2/g, " "); const hosts = new Set(); const docHosts = new Set(); @@ -406,9 +440,27 @@ function main() { const items = []; for (const f of files) { const p = pathOf(f); - if (isDoc(p)) continue; for (const { line, text } of f.added) { - if (cat.patterns.some((re) => re.test(text))) items.push({ file: p, line, text: text.trim().slice(0, 160) }); + if (cat.patterns.some((re) => re.test(text))) { + // DOCUMENTATION IS SCANNED, AND LABELLED. An earlier version of this + // skipped doc files for every category, which opened a blind spot + // rather than closing a false positive: Node's CJS `require('./NOTICE')` + // and `node tools/build.txt` both execute those files as JavaScript, so + // a payload kept in one would have been invisible to every category. + // Verified: a `.txt` containing `child_process`, `exec(` and an + // exfiltration host returned "no items flagged". + // + // The prose problem this was reaching for is real, but it is a problem + // about HOSTS, and that is handled below by reporting documentation + // hosts separately. Here the fix is to say where the match came from, + // so a reviewer can discount a README sentence without the scan having + // to guess for them. + items.push({ + file: isDoc(p) ? `${p} (documentation — not necessarily code)` : p, + line, + text: text.trim().slice(0, 160), + }); + } } } if (items.length) queue.push({ category: cat.label, key: cat.key, items }); @@ -418,8 +470,7 @@ function main() { if (isLockfile(p)) continue; const into = isDoc(p) ? docHosts : hosts; for (const { text } of f.added) { - if (isNamespaceDecl(text)) continue; - for (const m of text.matchAll(URL_RE)) into.add(m[1] ?? m[2]); + for (const m of withoutNamespaceDecls(text).matchAll(URL_RE)) into.add(m[1] ?? m[2]); } } for (const h of hosts) docHosts.delete(h); diff --git a/scripts/adjudicate/policy.mjs b/scripts/adjudicate/policy.mjs index 26f873e..fdb7129 100644 --- a/scripts/adjudicate/policy.mjs +++ b/scripts/adjudicate/policy.mjs @@ -81,6 +81,23 @@ export const SENSITIVE_PATH_PATTERNS = [ { re: /(^|\/)pnpm-workspace\.yaml$/, why: "pnpm workspace config" }, { re: /(^|\/)\.pnpmfile\.cjs$/, why: "pnpm hook file — executes during install" }, { re: /(^|\/)bunfig\.toml$/, why: "bun config — can re-point the registry for the build" }, + + // Git configuration that changes what a DIFF shows, which is a different + // kind of danger from the ones above: it does not alter what the build does, + // it alters what a reviewer sees. + // + // `.gitattributes` inside the addon's own directory, containing `*.js -diff`, + // makes `git format-patch` emit `GIT binary patch` for every JavaScript file + // in the submission. The parsed patch then has no added lines, so the stage 5 + // capability scan has nothing to read and the judgment queue comes back + // `(none)`. Verified 2026-11-27: a file containing `child_process`, `exec(`, + // `eval(` and a `wss://` exfiltration host produced `VERDICT: PASS — no items + // flagged`. The gates that read the tree rather than the patch are + // unaffected, so this hides the report rather than passing a gate — but the + // report is the reviewer's agenda, and a scan that silently reads nothing is + // worse than no scan. + { re: /(^|\/)\.gitattributes$/, why: "git attributes — can suppress the diff a reviewer reads" }, + { re: /(^|\/)\.mailmap$/, why: "git mailmap — can rewrite the authorship a reviewer sees" }, ]; // The complete set of `scripts` keys an addon's package.json may declare.