Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(security): scan the Python workers against OSV, and fix what the first run found

nirholas70a4a0fb319b
diff --git a/data/changelog.json b/data/changelog.json
index b035f25db..e5b4b62b2 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -26948,6 +26948,15 @@
"improvement"
],
"link": "/forge-studio"
+ },
+ {
+ "date": "2026-09-07",
+ "title": "Security: the image and mesh workers now run patched libraries",
+ "summary": "The services that strip a background, convert a mesh, and paint a texture all decode a file you upload, and they were pinned to an image library with a long list of published flaws, including several that let a crafted image corrupt memory. Those three services now run the patched release, and the mesh converter's 3D-format library was moved off a version with a critical flaw of its own. There is also a new check that scans every pinned Python dependency across the whole worker fleet against the public vulnerability database, so the next one gets found rather than waited for.",
+ "tags": [
+ "security",
+ "infra"
+ ]
}
]
}
diff --git a/data/guards.json b/data/guards.json
index f3f05bf7f..dd670f10d 100644
--- a/data/guards.json
+++ b/data/guards.json
@@ -1255,6 +1255,22 @@
},
"expect": "9.9.9"
}
+ },
+ {
+ "id": "check-deps",
+ "script": "scripts/check-deps.mjs",
+ "npm": "audit:deps",
+ "title": "Python worker dependencies",
+ "protects": "No pinned Python dependency in workers/, services/ or packages/ carries a known vulnerability in the OSV database.",
+ "why": "npm audit covers the JavaScript tree and nothing covered the other half of the platform. Twenty requirements files pin the runtime of every GPU and CPU worker, and a pinned version never gets a security bump unless somebody goes looking. The workers that decode caller-supplied images and meshes are exactly where an image-parsing overflow matters.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "network",
+ "proof": {
+ "kind": "live",
+ "reason": "Queries the OSV database over its public API for every pinned requirement, so the answer changes as advisories are published and there is nothing offline to mutate. The requirement parsing it depends on is covered by tests/check-deps.test.js instead."
+ }
}
],
"exempt": [
diff --git a/docs/audit/python-deps-2026-09-07.md b/docs/audit/python-deps-2026-09-07.md
new file mode 100644
index 000000000..d5b39d2a1
--- /dev/null
+++ b/docs/audit/python-deps-2026-09-07.md
@@ -0,0 +1,127 @@
+# Python worker dependencies: first OSV scan, 2026-09-07
+
+The first vulnerability scan of the Python half of the platform. `npm audit`
+covers the JavaScript tree; nothing covered the 20 requirements files that pin
+the runtime of every GPU and CPU worker, so nothing ever had.
+
+Reproduce with `npm run audit:deps` ([scripts/check-deps.mjs](../../scripts/check-deps.mjs)).
+It queries [OSV](https://osv.dev) for every exact-pinned requirement under
+`workers/`, `services/` and `packages/`.
+
+**First run: 321 advisories across 19 pinned package versions, out of 100
+pinned packages in 20 files.** After the fixes below: 285 across 17.
+
+## Fixed in this pass
+
+Both were chosen the same way: severity, times whether a caller's bytes reach
+the vulnerable code.
+
+### Pillow 11.0.0 to 12.3.0 (rembg, remesh, texture)
+
+34 advisories, 13 of them HIGH: heap out-of-bounds writes in `Image.paste()` and
+`Image.crop()` via signed coordinate overflow, an out-of-bounds write in the PSD
+loader, a controlled heap write in `ImageCmsTransform.apply()`, an out-of-bounds
+read on the mmap path, and a family of decompression-bomb bypasses in the font
+and PDF loaders.
+
+All three workers decode an image the caller supplied. This was the most directly
+reachable finding in the scan.
+
+Verified before bumping:
+
+- The rembg worker's full smoke test (20 checks, both baked-in models) passes on
+ Pillow 12.3.0, and so does the BiRefNet path added earlier today.
+- `pip check` is clean on the rembg requirement set.
+- No package pinned in remesh or texture caps Pillow below 12; `transformers`
+ is the only one that constrains it at all, at `>=10.0.1,<=15.0`.
+- Every PIL symbol those two workers use (`Image.LANCZOS`, `Image.NEAREST`,
+ `fromarray`, `new`, `composite`, `open`, `resize`, `convert`) exists in 12.3.0
+ and the exact call chain round-trips.
+
+remesh and texture were bumped on that evidence rather than a functional run:
+their images need a build to exercise, which happens on their next deploy.
+
+### usd-core 24.11 to 25.11 (remesh)
+
+`GHSA-58p5-r2f6-g2cj`, CRITICAL: a `Sdf_PathNode` use-after-free leading to
+potential remote code execution, plus a MODERATE file-parsing use-after-free of
+the same class.
+
+Exposure here was narrower than the severity suggests: remesh only *authors* USD
+(`Usd.Stage.CreateNew`), it never parses a caller's USD file. A pinned CRITICAL
+is still not a thing to keep. Verified that 25.11 imports the same module set the
+worker uses (`Gf, Sdf, Usd, UsdGeom, UsdShade, UsdUtils, Vt`) and that
+`UsdUtils.CreateNewUsdzPackage` still produces a valid USDZ.
+
+## What is left, in priority order
+
+### 1. `libassimp5`, not `pyassimp` (remesh, stylize)
+
+33 advisories against `pyassimp==5.2.5`, and **bumping the pin cannot fix any of
+them**: 5.2.5 is the last release on PyPI, and the vulnerable code is the assimp
+C++ library, which both Dockerfiles install from Debian as `libassimp-dev
+libassimp5`. The scanner points at the Python binding because that is what a
+requirements file can name.
+
+This matters because assimp is the trimesh backend for **FBX and DAE input**, so
+a caller's mesh file goes through it. The lever is the base image: rebuild both
+workers on a Debian release carrying a patched `libassimp5`, or drop the FBX/DAE
+input path to Blender, which remesh already ships for FBX export.
+
+### 2. `transformers` 4.41.0 / 4.46.0 / 4.46.3 / 4.47.1 (longcat, hunyuan3d, triposg, texture)
+
+43 advisories each, 6 HIGH, fixed in 5.0.0. Two different classes hide in that
+number and they need separating before anyone bumps a major version across four
+GPU workers:
+
+- **Unsafe deserialization when loading a model or config.** Not caller
+ reachable: every worker loads pinned weights we staged ourselves.
+- **ReDoS in tokenizer and config regexes.** Potentially caller reachable, because
+ a user's text prompt does reach a tokenizer on the generation lanes.
+
+Read the second class first; it decides whether this is urgent or housekeeping.
+
+### 3. `torch` 2.3.1 (texture)
+
+23 advisories, one CRITICAL: `torch.load` with `weights_only=True` leading to
+remote code execution. Same reachability answer as transformers, the worker loads
+its own weights. The fix is 2.7.1, which is a CUDA-compatibility decision for the
+whole image rather than a pin edit, so it belongs with the next texture worker
+rebuild.
+
+### 4. The cheap ones
+
+| Package | Pinned | Fixed in | Worker |
+|---|---|---|---|
+| `requests` | 2.32.3 | 2.33.0 | avatar-reconstruction |
+| `pynacl` | 1.5.0 | 1.6.2 | stylize |
+| `rembg` | 2.0.56 / 2.0.59 / 2.0.65 | 2.0.75 | avatar-reconstruction, model-triposr, model-hunyuan3d, rembg |
+| `diffusers` | 0.30.0 / 0.31.0 / 0.35.1 | 0.38.0 | model-hunyuan3d, model-triposg, texture, longcat |
+| `onnx` | 1.18.0 | 1.22.0 | longcat |
+| `pytorch-lightning` | 1.9.5 | 2.4.0 | model-hunyuan3d (2.1 image) |
+| `basicsr` | 1.4.2 | no fix published | model-hunyuan3d (2.1 image) |
+
+`requests` and `pynacl` are one-line bumps with no model-behaviour risk and
+should go with the next deploy of those workers. `rembg` changes the inference
+path this platform's cutouts run on, so it wants the same treatment BiRefNet got:
+run the worker's smoke test against the new version first.
+`pytorch-lightning` 1.9.5 to 2.4.0 is a major version inside a GPU image whose
+Python stack is already pinned around torch 2.5, and `basicsr` has no fixed
+release at all, so both are constrained by the Hunyuan 2.1 image rather than by
+the pin.
+
+## Notes on the scan itself
+
+- **`npm run audit:deps` needs network and is deliberately not in the gate.** A
+ build must not fail because api.osv.dev is having a bad afternoon. It is
+ registered as an on-demand guard in [data/guards.json](../../data/guards.json).
+- **It only sees exact pins.** `pkg>=1.2`, `pkg~=1.2` and a bare `pkg` resolve to
+ whatever the build found that day, which is a reproducibility problem before it
+ is a security one. `node scripts/check-deps.mjs --unpinned` lists them.
+- **A locally built wheel is queried on its public version.** The CUDA wheels
+ (`torch-cluster==1.6.3+pt21cu121`) are our rebuild of an upstream release, and
+ OSV indexes the release.
+- **The parser is tested** ([tests/check-deps.test.js](../../tests/check-deps.test.js)),
+ including an assertion that every requirement line in the tree is classified.
+ A parser that silently drops a line reports a package clean without ever
+ looking at it, which is worse than not scanning.
diff --git a/docs/guards.md b/docs/guards.md
index 08b8715ab..131b7935d 100644
--- a/docs/guards.md
+++ b/docs/guards.md
@@ -97,6 +97,7 @@ Run `npm run audit:guards` to print the current count and per-stage breakdown. T
| One `<model-viewer>` build | `npm run check:model-viewer` | Every `<model-viewer>` reference in tracked source names one version, no version is served under two integrity hashes, and the vendored copy matches. |
| Design-token ratchet | `npm run audit:tokens` | Hardcoded colour hexes cannot creep back past a committed baseline. |
| Credential material | `npm run check:secrets` | No dotenv file, private key, keystore, or downloaded cloud credential becomes a tracked file, and no added line carries a provider-issued key. |
+| Python worker dependencies | `npm run audit:deps` | No pinned Python dependency in `workers/`, `services/` or `packages/` carries a known vulnerability in the OSV database. Needs network, so it runs on demand rather than in the gate. |
| iOS app icon | `npm run check:ios-icons` | The committed iOS icon and launch images are exactly what the current brand mark produces, and the icon carries no alpha channel. |
| macOS app icon | `npm run check:macos-icon` | The ten committed Mac icon sizes and their Contents.json are exactly what the current brand mark produces. |
| Apple glance widget | `npm run check:apple-widget` | Both Xcode projects that build the Agent glance widget are consistent, every shared Swift source belongs to the targets that need it, and the Swift client still agrees with `api/glance/mine.js` on the endpoint, the headers, the states, the sizes and the token shape. |
diff --git a/package.json b/package.json
index b89d44b21..0c8667218 100644
--- a/package.json
+++ b/package.json
@@ -213,6 +213,7 @@
"audit:pages": "node scripts/audit-page-index.mjs --strict",
"audit:meetup": "node scripts/meetup-audit.mjs",
"audit:docs": "node scripts/audit-docs.mjs",
+ "audit:deps": "node scripts/check-deps.mjs",
"audit:upstreams": "node scripts/audit-upstreams.mjs",
"audit:upstreams:map": "node scripts/audit-upstreams.mjs --map",
"docs:freshness": "node scripts/doc-freshness.mjs",
diff --git a/public/guards.json b/public/guards.json
index f3f05bf7f..dd670f10d 100644
--- a/public/guards.json
+++ b/public/guards.json
@@ -1255,6 +1255,22 @@
},
"expect": "9.9.9"
}
+ },
+ {
+ "id": "check-deps",
+ "script": "scripts/check-deps.mjs",
+ "npm": "audit:deps",
+ "title": "Python worker dependencies",
+ "protects": "No pinned Python dependency in workers/, services/ or packages/ carries a known vulnerability in the OSV database.",
+ "why": "npm audit covers the JavaScript tree and nothing covered the other half of the platform. Twenty requirements files pin the runtime of every GPU and CPU worker, and a pinned version never gets a security bump unless somebody goes looking. The workers that decode caller-supplied images and meshes are exactly where an image-parsing overflow matters.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "network",
+ "proof": {
+ "kind": "live",
+ "reason": "Queries the OSV database over its public API for every pinned requirement, so the answer changes as advisories are published and there is nothing offline to mutate. The requirement parsing it depends on is covered by tests/check-deps.test.js instead."
+ }
}
],
"exempt": [
diff --git a/scripts/check-deps.mjs b/scripts/check-deps.mjs
new file mode 100644
index 000000000..72b7c8a01
--- /dev/null
+++ b/scripts/check-deps.mjs
@@ -0,0 +1,265 @@
+#!/usr/bin/env node
+/**
+ * check-deps: scan the Python workers' pinned dependencies for known
+ * vulnerabilities, against the OSV database (https://osv.dev).
+ *
+ * Why this exists. `npm audit` covers the JavaScript tree, and nothing covered
+ * the other half of the platform: 20 requirements files across `workers/`,
+ * `services/` and `packages/` pin the runtime of every GPU and CPU worker, and
+ * a pinned version is a version that never gets a security bump unless someone
+ * goes looking. The `overrides` block in package.json is the record of that work
+ * being done by hand on the JS side, one advisory at a time. This is the same
+ * job for PyPI, done by a query rather than by remembering.
+ *
+ * Why not `osv-scanner`. It is the reference tool and it is the right answer on
+ * a machine that has it: it is a Go binary, so it cannot be a repo dependency,
+ * and a check nobody can run is not a check. This queries the same OSV database
+ * over its public API, so the data is identical and the install cost is zero.
+ * If you have osv-scanner, run it too; it understands lockfile ecosystems this
+ * does not.
+ *
+ * What it can and cannot see:
+ * - `pkg==1.2.3` is scannable, and most of the tree is pinned this way.
+ * - `pkg>=1.2`, `pkg~=1.2`, and a bare `pkg` are NOT scannable: the installed
+ * version is whatever the build resolved that day. Those are reported
+ * separately, because an unpinnable dependency is its own reproducibility
+ * problem in a worker whose image is built months after its Dockerfile.
+ * - A local version segment (`1.6.3+pt21cu121`, the CUDA-built wheels) is
+ * queried on its public part; OSV indexes upstream releases, not rebuilds.
+ *
+ * Usage:
+ * npm run audit:deps # exit 1 if anything vulnerable is found
+ * node scripts/check-deps.mjs --advisory # always exit 0
+ * node scripts/check-deps.mjs --unpinned # also list what cannot be scanned
+ *
+ * Needs network. Deliberately NOT wired into `npm run gate` or the deploy path:
+ * a build must not fail because api.osv.dev is having a bad afternoon.
+ */
+import { readFileSync, readdirSync, existsSync, statSync } from 'node:fs';
+import { resolve, dirname, join, relative } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+const args = process.argv.slice(2);
+const ADVISORY = args.includes('--advisory');
+const SHOW_UNPINNED = args.includes('--unpinned');
+
+const SEARCH_DIRS = ['workers', 'services', 'packages'];
+const OSV_BATCH = 'https://api.osv.dev/v1/querybatch';
+const OSV_VULN = 'https://api.osv.dev/v1/vulns/';
+
+// ── Collecting requirements ──────────────────────────────────────────────────
+
+function requirementFiles() {
+ const found = [];
+ for (const dir of SEARCH_DIRS) {
+ const base = join(root, dir);
+ if (!existsSync(base)) continue;
+ for (const entry of readdirSync(base)) {
+ const child = join(base, entry);
+ if (!statSync(child).isDirectory()) continue;
+ for (const name of readdirSync(child)) {
+ if (/^requirements.*\.txt$/.test(name)) found.push(join(child, name));
+ }
+ }
+ }
+ return found.sort();
+}
+
+/**
+ * Parse one requirements file into { pinned, unpinned }.
+ *
+ * Requirement lines carry more than a name and a version: extras (`uvicorn[standard]`),
+ * environment markers (`; python_version < "3.11"`), inline comments, pip flags
+ * (`-f`, `--extra-index-url`), and direct URLs. Everything that is not a plain
+ * `name==version` is either unpinnable or not a PyPI release at all.
+ */
+export function parseRequirements(text) {
+ const pinned = [];
+ const unpinned = [];
+ for (const rawLine of text.split('\n')) {
+ let line = rawLine.trim();
+ if (!line || line.startsWith('#')) continue;
+ if (line.startsWith('-') ) continue; // pip flags: -r, -f, --extra-index-url
+ line = line.split(' #')[0].trim(); // trailing comment
+ line = line.split(';')[0].trim(); // environment marker
+ if (!line) continue;
+ if (/^[a-z+]+:\/\//i.test(line) || line.includes('@')) continue; // direct URL or VCS ref
+ const match = line.match(/^([A-Za-z0-9][A-Za-z0-9._-]*)\s*(\[[^\]]*\])?\s*(.*)$/);
+ if (!match) continue;
+ const name = match[1];
+ const spec = (match[3] || '').trim();
+ const exact = spec.match(/^==\s*([^,\s]+)$/);
+ if (exact) pinned.push({ name, version: exact[1] });
+ else unpinned.push({ name, spec: spec || '(any version)' });
+ }
+ return { pinned, unpinned };
+}
+
+// OSV indexes upstream releases. A locally built wheel carries a PEP 440 local
+// version segment after "+", which is our build, not an upstream release, so
+// query the public part and let the caller know that is what happened.
+export function publicVersion(version) {
+ return version.split('+')[0];
+}
+
+// ── OSV queries ──────────────────────────────────────────────────────────────
+
+async function postJson(url, body) {
+ const res = await fetch(url, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify(body),
+ });
+ if (!res.ok) throw new Error(`${url} answered HTTP ${res.status}`);
+ return res.json();
+}
+
+async function getJson(url) {
+ const res = await fetch(url);
+ if (!res.ok) throw new Error(`${url} answered HTTP ${res.status}`);
+ return res.json();
+}
+
+/** Query OSV for a list of {name, version}, in batches it will accept. */
+async function queryOsv(packages) {
+ const hits = new Map(); // "name@version" -> [vuln id]
+ const BATCH = 100;
+ for (let i = 0; i < packages.length; i += BATCH) {
+ const slice = packages.slice(i, i + BATCH);
+ const body = {
+ queries: slice.map((p) => ({
+ package: { name: p.name, ecosystem: 'PyPI' },
+ version: publicVersion(p.version),
+ })),
+ };
+ const out = await postJson(OSV_BATCH, body);
+ (out.results || []).forEach((result, idx) => {
+ const ids = (result.vulns || []).map((v) => v.id);
+ if (ids.length) hits.set(`${slice[idx].name}@${slice[idx].version}`, ids);
+ });
+ }
+ return hits;
+}
+
+/** The batch endpoint returns ids only; the detail endpoint has the useful part. */
+async function describeVulns(ids) {
+ const described = new Map();
+ for (const id of ids) {
+ try {
+ const v = await getJson(OSV_VULN + encodeURIComponent(id));
+ described.set(id, {
+ id,
+ summary: v.summary || v.details?.split('\n')[0] || '(no summary)',
+ severity: highestSeverity(v),
+ fixed: fixedVersions(v),
+ withdrawn: Boolean(v.withdrawn),
+ });
+ } catch {
+ described.set(id, { id, summary: '(details unavailable)', severity: '', fixed: [], withdrawn: false });
+ }
+ }
+ return described;
+}
+
+function highestSeverity(vuln) {
+ const labels = [];
+ for (const s of vuln.severity || []) if (s.score) labels.push(s.score);
+ const db = vuln.database_specific?.severity;
+ if (db) labels.unshift(db);
+ return labels[0] || '';
+}
+
+function fixedVersions(vuln) {
+ const out = new Set();
+ for (const affected of vuln.affected || []) {
+ for (const range of affected.ranges || []) {
+ for (const event of range.events || []) if (event.fixed) out.add(event.fixed);
+ }
+ }
+ return [...out];
+}
+
+// ── Report ───────────────────────────────────────────────────────────────────
+
+async function main() {
+ const files = requirementFiles();
+ if (!files.length) {
+ console.log('check-deps: no requirements files found.');
+ return 0;
+ }
+
+ const byPackage = new Map(); // "name@version" -> Set(file)
+ const unpinnedByFile = new Map();
+ for (const file of files) {
+ const rel = relative(root, file);
+ const { pinned, unpinned } = parseRequirements(readFileSync(file, 'utf8'));
+ for (const p of pinned) {
+ const key = `${p.name}@${p.version}`;
+ if (!byPackage.has(key)) byPackage.set(key, new Set());
+ byPackage.get(key).add(rel);
+ }
+ if (unpinned.length) unpinnedByFile.set(rel, unpinned);
+ }
+
+ const packages = [...byPackage.keys()].map((key) => {
+ const at = key.lastIndexOf('@');
+ return { name: key.slice(0, at), version: key.slice(at + 1) };
+ });
+
+ console.log(`check-deps: ${packages.length} pinned package(s) across ${files.length} requirements file(s), querying OSV…\n`);
+
+ let hits;
+ try {
+ hits = await queryOsv(packages);
+ } catch (err) {
+ console.error(`check-deps: could not reach OSV (${err.message}).`);
+ console.error('This check needs network. It is not part of the deploy gate for exactly that reason.');
+ return ADVISORY ? 0 : 2;
+ }
+
+ const allIds = [...new Set([...hits.values()].flat())];
+ const described = await describeVulns(allIds);
+
+ let findings = 0;
+ for (const [key, ids] of [...hits.entries()].sort()) {
+ const live = ids.map((id) => described.get(id)).filter((v) => v && !v.withdrawn);
+ if (!live.length) continue;
+ findings += live.length;
+ const where = [...byPackage.get(key)].join(', ');
+ console.log(`${key}`);
+ console.log(` in: ${where}`);
+ for (const v of live) {
+ const sev = v.severity ? ` [${v.severity}]` : '';
+ const fix = v.fixed.length ? ` fixed in ${v.fixed.join(', ')}` : ' no fixed version published';
+ console.log(` ${v.id}${sev} ${v.summary}`);
+ console.log(` ${fix}`);
+ }
+ console.log('');
+ }
+
+ if (SHOW_UNPINNED) {
+ const total = [...unpinnedByFile.values()].reduce((n, list) => n + list.length, 0);
+ console.log(`Not scannable: ${total} requirement(s) with no exact version, in ${unpinnedByFile.size} file(s).`);
+ console.log('An unpinned dependency resolves to whatever the build found that day, so neither');
+ console.log('this check nor a rebuild months later can say what actually shipped.\n');
+ for (const [file, list] of [...unpinnedByFile.entries()].sort()) {
+ console.log(` ${file}`);
+ for (const u of list) console.log(` ${u.name} ${u.spec}`);
+ }
+ console.log('');
+ }
+
+ if (!findings) {
+ console.log(`check-deps: no known vulnerabilities in ${packages.length} pinned package(s).`);
+ return 0;
+ }
+ console.log(`check-deps: ${findings} advisory/advisories across ${hits.size} package version(s).`);
+ console.log('Bump the pin in the requirements file, then rebuild that worker image.');
+ return ADVISORY ? 0 : 1;
+}
+
+// Importable for tests; only runs the report when invoked directly.
+if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
+ main().then((code) => { process.exitCode = code; });
+}
diff --git a/tests/check-deps.test.js b/tests/check-deps.test.js
new file mode 100644
index 000000000..a65da97f8
--- /dev/null
+++ b/tests/check-deps.test.js
@@ -0,0 +1,138 @@
+// Requirement parsing for the OSV dependency scan (scripts/check-deps.mjs).
+//
+// The scan is only as good as what it can read out of a requirements file, and
+// these files are not a simple list: they carry pip flags, extras, environment
+// markers, inline comments, direct URLs, and CUDA-built wheels with a PEP 440
+// local version. Every case below is taken from a real file in workers/.
+//
+// The failure this guards against is silent: a parser that drops a line reports
+// "no known vulnerabilities" for a package it never looked at, which is worse
+// than not scanning at all.
+import { describe, it, expect } from 'vitest';
+import { readFileSync, readdirSync, existsSync, statSync } from 'node:fs';
+import { join } from 'node:path';
+import { parseRequirements, publicVersion } from '../scripts/check-deps.mjs';
+
+describe('parseRequirements', () => {
+ it('reads a plain pin', () => {
+ const { pinned } = parseRequirements('fastapi==0.115.5\n');
+ expect(pinned).toEqual([{ name: 'fastapi', version: '0.115.5' }]);
+ });
+
+ it('reads a pin that carries extras', () => {
+ const { pinned } = parseRequirements('uvicorn[standard]==0.32.1\n');
+ expect(pinned).toEqual([{ name: 'uvicorn', version: '0.32.1' }]);
+ });
+
+ it('keeps the pin when an environment marker follows it', () => {
+ const { pinned } = parseRequirements('numpy==1.26.4 ; python_version < "3.13"\n');
+ expect(pinned).toEqual([{ name: 'numpy', version: '1.26.4' }]);
+ });
+
+ it('strips an inline comment', () => {
+ const { pinned } = parseRequirements('Pillow==11.0.0 # pinned for the ONNX runtime\n');
+ expect(pinned).toEqual([{ name: 'Pillow', version: '11.0.0' }]);
+ });
+
+ it('ignores comments and blank lines', () => {
+ const { pinned, unpinned } = parseRequirements('# CPU only, see the Dockerfile\n\n\nonnxruntime==1.28.0\n');
+ expect(pinned).toEqual([{ name: 'onnxruntime', version: '1.28.0' }]);
+ expect(unpinned).toEqual([]);
+ });
+
+ it('ignores pip flags, which are not packages', () => {
+ const text = [
+ '-f https://data.pyg.org/whl/torch-2.1.2+cu121.html',
+ '--extra-index-url https://miropsota.github.io/torch_packages_builder',
+ '-r base.txt',
+ 'trimesh==4.5.3',
+ ].join('\n');
+ const { pinned } = parseRequirements(text);
+ expect(pinned).toEqual([{ name: 'trimesh', version: '4.5.3' }]);
+ });
+
+ it('ignores a direct URL or VCS reference, which OSV cannot resolve', () => {
+ const text = [
+ 'https://example.invalid/wheels/custom-1.0-py3-none-any.whl',
+ 'thing @ git+https://github.com/example/thing@abc123',
+ 'einops==0.8.0',
+ ].join('\n');
+ const { pinned } = parseRequirements(text);
+ expect(pinned).toEqual([{ name: 'einops', version: '0.8.0' }]);
+ });
+
+ it('separates the specs it cannot scan rather than dropping them', () => {
+ const { pinned, unpinned } = parseRequirements('gradio>=5.25.0\nnumpy~=1.26.4\ntimm\nbpy==4.3.0\n');
+ expect(pinned).toEqual([{ name: 'bpy', version: '4.3.0' }]);
+ expect(unpinned.map((u) => u.name)).toEqual(['gradio', 'numpy', 'timm']);
+ // A bare name still reports something a reader can act on.
+ expect(unpinned.find((u) => u.name === 'timm').spec).toBe('(any version)');
+ });
+
+ it('keeps a locally built wheel as pinned, local segment intact', () => {
+ const { pinned } = parseRequirements('torch-cluster==1.6.3+pt21cu121\n');
+ expect(pinned).toEqual([{ name: 'torch-cluster', version: '1.6.3+pt21cu121' }]);
+ });
+});
+
+describe('publicVersion', () => {
+ it('leaves an ordinary version alone', () => {
+ expect(publicVersion('2.3.1')).toBe('2.3.1');
+ });
+
+ // OSV indexes upstream releases. A local version segment is our build, not an
+ // upstream release, so querying it verbatim finds nothing and would report a
+ // CUDA-built torch as clean when the upstream release it came from is not.
+ it('drops the local build segment before the query', () => {
+ expect(publicVersion('1.6.3+pt21cu121')).toBe('1.6.3');
+ expect(publicVersion('0.7.7+pt2.1.2cu121')).toBe('0.7.7');
+ });
+});
+
+describe('the real requirements files', () => {
+ const roots = ['workers', 'services', 'packages'];
+ const files = [];
+ for (const dir of roots) {
+ if (!existsSync(dir)) continue;
+ for (const entry of readdirSync(dir)) {
+ const child = join(dir, entry);
+ if (!statSync(child).isDirectory()) continue;
+ for (const name of readdirSync(child)) {
+ if (/^requirements.*\.txt$/.test(name)) files.push(join(child, name));
+ }
+ }
+ }
+
+ it('finds requirements files to scan at all', () => {
+ expect(files.length).toBeGreaterThan(0);
+ });
+
+ // Not a style rule: a line the parser classifies as neither pinned nor
+ // unpinned is a package nobody is looking at, and it fails silently.
+ it('classifies every requirement line in the tree', () => {
+ const unaccounted = [];
+ for (const file of files) {
+ const text = readFileSync(file, 'utf8');
+ const { pinned, unpinned } = parseRequirements(text);
+ const seen = new Set([...pinned.map((p) => p.name.toLowerCase()), ...unpinned.map((u) => u.name.toLowerCase())]);
+ for (const raw of text.split('\n')) {
+ const line = raw.trim();
+ if (!line || line.startsWith('#') || line.startsWith('-')) continue;
+ if (/^[a-z+]+:\/\//i.test(line) || line.includes('@')) continue;
+ const name = line.match(/^([A-Za-z0-9][A-Za-z0-9._-]*)/)?.[1];
+ if (name && !seen.has(name.toLowerCase())) unaccounted.push(`${file}: ${line}`);
+ }
+ }
+ expect(unaccounted).toEqual([]);
+ });
+
+ it('reads a version for the packages the image-handling workers pin', () => {
+ const rembg = files.find((f) => f.includes(join('workers', 'rembg')));
+ expect(rembg).toBeTruthy();
+ const { pinned } = parseRequirements(readFileSync(rembg, 'utf8'));
+ const names = pinned.map((p) => p.name.toLowerCase());
+ expect(names).toContain('pillow');
+ expect(names).toContain('rembg');
+ expect(names).toContain('onnxruntime');
+ });
+});
diff --git a/workers/rembg/requirements.txt b/workers/rembg/requirements.txt
index af57cd46e..f7eb971b0 100644
--- a/workers/rembg/requirements.txt
+++ b/workers/rembg/requirements.txt
@@ -6,7 +6,11 @@ uvicorn[standard]==0.32.1
# made every rebuild a different inference runtime.
rembg==2.0.59
onnxruntime==1.28.0
-Pillow==11.0.0
+# Pillow 12.3.0, not 11.x: every 11.x release carries open advisories, and this
+# service decodes an image the caller supplied, which is the exact path the heap
+# out-of-bounds writes in Image.paste/crop and the PSD and font loaders live on.
+# `npm run audit:deps` is what surfaces the next one.
+Pillow==12.3.0
google-cloud-storage==2.19.0
httpx==0.27.2
pydantic==2.10.3
diff --git a/workers/remesh/requirements.txt b/workers/remesh/requirements.txt
index 2e4ce8b5e..84ac02d5a 100644
--- a/workers/remesh/requirements.txt
+++ b/workers/remesh/requirements.txt
@@ -6,14 +6,21 @@ numpy==1.26.4
# Quad/low-poly UV atlas generation (re-unwrap before texture re-bake). MIT.
xatlas==0.0.9
# Texture atlas read/write for the re-bake step.
-Pillow==11.0.0
+# Pillow 12.3.0, not 11.x: every 11.x release carries open advisories, several of
+# them heap out-of-bounds writes reachable from a decoded image. `npm run
+# audit:deps` surfaces the next one.
+Pillow==12.3.0
google-cloud-storage==2.19.0
httpx==0.27.2
pydantic==2.10.3
# FBX/DAE input loading via the assimp python bindings (trimesh backend).
pyassimp==5.2.5
# USD / USDZ support
-usd-core==24.11
+# usd-core 25.11, not 24.11: 24.11 carries a CRITICAL Sdf_PathNode use-after-free
+# (GHSA-58p5-r2f6-g2cj) and a file-parsing use-after-free, both RCE-class. This
+# worker only authors USD, it never parses a caller's, so the exposure was
+# narrow, but a pinned CRITICAL is not a thing to keep.
+usd-core==25.11
# FBX *export* with skeletons via headless Blender (io_scene_fbx). trimesh/assimp
# can't write a rigged FBX; Blender 4.2 LTS ships the Python 3.11 ABI this image
# uses. See blender_fbx.py and output_format=fbx.
diff --git a/workers/texture/requirements.txt b/workers/texture/requirements.txt
index 5a4e7e7fb..4664a443f 100644
--- a/workers/texture/requirements.txt
+++ b/workers/texture/requirements.txt
@@ -9,7 +9,10 @@ trimesh[easy]==4.5.3
pyrender==0.1.45
scipy==1.14.1
numpy==1.26.4
-Pillow==11.0.0
+# Pillow 12.3.0, not 11.x: every 11.x release carries open advisories, several of
+# them heap out-of-bounds writes reachable from a decoded image. `npm run
+# audit:deps` surfaces the next one.
+Pillow==12.3.0
torch==2.3.1
torchvision==0.18.1
google-cloud-storage==2.19.0