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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
chore(prompts): file orders 449-450, Pillow RCE pins in rembg and four unjustified stale pins in modly-host
nirholasbb7a39af4948
diff --git a/prompts/finish/449-auto-dependency-cve-pillow-rembg.md b/prompts/finish/449-auto-dependency-cve-pillow-rembg.mdnew file mode 100644index 000000000..442dc2a37--- /dev/null+++ b/prompts/finish/449-auto-dependency-cve-pillow-rembg.md@@ -0,0 +1,93 @@+# 449. `workers/rembg` is still pinned to a Pillow with 41 open advisories, several of them RCE-class, on a caller-supplied image decode path++How to run: paste this file's repo path into a fresh Claude Code chat in this repository and say "run this work order". Runnable now, no gate, no owner action required.++## Operating clause (binding)++- Read CLAUDE.md first. CLAUDE.md overrides everything, including this file.+- Finish 100% in this session. Never end the turn with a question, an option list, or an unexecuted plan.+- This is a bug fix (a security defect): follow the test-first rule (CLAUDE.md, "Bug fixes are test-first") as far as it applies. There is no app-level behavior bug to reproduce with a new test (this is a dependency-version fix), so the equivalent "prove it fails first" step is the OSV scan below: run it before the bump and confirm the advisories are present, then run it after and confirm they are gone.+- The only permitted stops are the CLAUDE.md stop-and-ask gates (spend/on-chain writes, push/deploy, posting externally, committing content referencing a crypto project other than `$THREE`, destroying unrecoverable data). This order touches none of them.+- Concurrent agents share this worktree: stage explicit paths only (never `git add -A` or `git add .`), re-check `git status` and `git diff --staged` before committing.+- The em-dash and en-dash characters are banned in everything you write.++## Why this matters (measured 2026-10-25)++`workers/rembg/requirements.txt` pins:++ Pillow==12.3.0++with a comment claiming this is current and safe:++ # 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.++That comment is now stale. `npm run audit:deps` (the repo's OSV-based Python pin scanner, `scripts/check-deps.mjs`) run today against `workers/rembg/requirements.txt` reports 41 open advisories against `Pillow==12.3.0`, fixed by moving to `13.0.0`, including CRITICAL and HIGH RCE-class findings:++- `GHSA-332p-7hrc-92wf`: heap buffer overflow in TIFF write, fixed in 13.0.0.+- `GHSA-5x8w-8jj5-q52h`: FlashPix JPEG decode RCE, fixed in 13.0.0.+- `GHSA-8g5g-8vmr-9782`: heap buffer overflow in JPEG decode, fixed in 13.0.0.+- `GHSA-v9pv-5gc8-w2m6`: stale native-storage reuse (use-after-free class), fixed in 13.0.0.+- `GHSA-w889-685w-c8fh`: Ghostscript argument injection leading to RCE via EPS handling, fixed in 13.0.0.+- Plus ~36 further HIGH/MODERATE DoS and memory-safety findings, all listed as fixed in 13.0.0 by OSV.++This is live exposure, not theoretical: `workers/rembg/main.py:153` (`_open_image`) runs `Image.open(io.BytesIO(data)).convert("RGBA")` on `data` that is the raw bytes of whatever the caller's `POST /remove` request supplied (`workers/rembg/README.md` confirms this is the service's primary mutating endpoint, gated only by `Authorization: Bearer $API_KEY`, which authenticates the caller but does not make the image bytes trustworthy). This is exactly the "hostile-input pass" class that `prompts/masters/06-the-adversary.md` calls out: a service that decodes attacker-chosen file bytes is the textbook reachable path for an image-library heap overflow, independent of whether the caller is also authenticated.++This is not speculative or already covered elsewhere: every sibling GPU/CPU worker in this repo has already made this exact bump and rembg is the one holdout. Confirmed today:++ grep -rn "^Pillow==" workers/*/requirements*.txt++returns `Pillow==13.0.0` in `workers/remesh/requirements.txt`, `workers/texture/requirements.txt`, `workers/modly/requirements-triposg.txt`, `workers/modly/requirements-hunyuan.txt`, and `workers/modly/requirements-host.txt`, and `Pillow==12.3.0` only in `workers/rembg/requirements.txt`. There is no base-image or transitive-dependency constraint holding rembg back: rembg's own Dockerfile (`FROM python:3.11-slim`) matches the Python version the other already-bumped workers use, and `rembg==2.0.75`'s own dependency floor does not pin Pillow upward.++This is also not a duplicate of order 444 (which fixed `fast-xml-parser` under `@bnb-chain/greenfield-js-sdk`, a JS/npm dependency, unrelated package and unrelated worker) or of the `transformers`/`diffusers` pins in `workers/model-triposg`, `workers/texture`, `workers/model-hunyuan3d`, `workers/modly`, and `workers/longcat` (those pins carry their own in-file comments explaining they are deliberately held back by a torch/base-image compatibility constraint; Pillow in rembg has no such constraint and no such comment, it is a plain oversight).++## Task++1. Read `workers/rembg/requirements.txt` in full and confirm the current state described above (`Pillow==12.3.0`, stale comment).+2. Read `workers/rembg/main.py` lines 1-200, specifically `_open_image` (around line 145) and `_decode_image` (around line 162), to confirm the caller-supplied decode path the comment already describes is still accurate after the bump (no code change expected here, this is a version-only fix).+3. Before changing anything, run the scanner and capture the "before" state:++ npm run audit:deps 2>&1 | tee /tmp/audit-deps-before.log+ grep -A3 "rembg/requirements.txt" /tmp/audit-deps-before.log | grep -i pillow++ Confirm it reports `Pillow==12.3.0` with open advisories (expect the CRITICAL/HIGH GHSA IDs listed above among them; the exact count may drift slightly if OSV has added or reclassified entries since this order was written, that does not change the fix).+4. Edit `workers/rembg/requirements.txt`: change `Pillow==12.3.0` to `Pillow==13.0.0`, and update the comment above it to state the new version and that this pin is now aligned with every other worker in the repo (remove the now-false "Pillow 12.3.0, not 11.x" framing; state what 13.0.0 fixes instead, matching the style used in `workers/modly/requirements-host.txt`'s `Pillow==13.0.0` line or lack of comment there, whichever reads cleaner given this file already has a paragraph in place).+5. Re-run the scanner and capture the "after" state:++ npm run audit:deps 2>&1 | tee /tmp/audit-deps-after.log+ grep -A3 "rembg/requirements.txt" /tmp/audit-deps-after.log | grep -i pillow++ Confirm the Pillow advisories against `workers/rembg/requirements.txt` are gone (either the package line is absent from the report, or any remaining entries are for a different package in that file, not Pillow).+6. Build the worker image to exercise the real decode path end to end; the Dockerfile's own build gate (`workers/rembg/Dockerfile`, final `RUN` before `EXPOSE`) runs `test_rembg_policy.py` and `test_rembg_smoke.py` (with `API_KEY=build-gate GCS_BUCKET=build-gate`) inside the image build itself, so a successful build is the real verification that Pillow 13.0.0 still decodes and processes images correctly with the baked `u2net` and `isnet-general-use` models:++ cd workers/rembg && docker build -t rembg-pillow-bump-test . 2>&1 | tail -60++ This must complete successfully (the `RUN python test_rembg_policy.py && API_KEY=build-gate GCS_BUCKET=build-gate python test_rembg_smoke.py` layer is the gate; if it fails, read the output, it will say which assertion failed, and fix forward, do not skip or weaken the gate). Remove the test image afterward (`docker rmi rembg-pillow-bump-test`) so this does not leave build artifacts behind; this is a local verification build, not a deploy, and must never be pushed to any registry.+7. Run `npm run check:rules -- --paths workers/rembg/requirements.txt` and fix anything it flags.+8. Add a `data/changelog.json` entry (tag `fix`) noting the rembg background-removal service closed a batch of image-library security advisories, matching the style and surface link used for prior dependency-fix entries (check how order 444's changelog entry referenced `fast-xml-parser`/greenfield for the wording convention), then run `npm run build:pages` and confirm only the expected generated files change.+9. Read the full diff (`git diff workers/rembg/requirements.txt data/changelog.json`) and confirm every changed line is one of the changes above (requirements.txt: version + comment; changelog: one new entry; generated files from `build:pages`).++## Done when++- `workers/rembg/requirements.txt` pins `Pillow==13.0.0`, with its comment accurate and no longer naming 12.3.0 as current.+- `npm run audit:deps` no longer reports Pillow advisories against `workers/rembg/requirements.txt` (captured before/after logs prove this).+- `docker build` of `workers/rembg` completes successfully, meaning the image's own build-gate tests (`test_rembg_policy.py`, `test_rembg_smoke.py`) pass against the new Pillow version with the real baked ONNX models.+- The verification test image is removed (`docker rmi`), no build artifacts left behind.+- `npm run check:rules -- --paths workers/rembg/requirements.txt` reports no violations.+- A changelog entry exists and `npm run build:pages` ran cleanly.+- Nothing outside `workers/rembg/requirements.txt`, `data/changelog.json`, and the generated `public/changelog*`/`CHANGELOG.md` files changed.++## Never blocked++| Apparent blocker | Resolution |+| --- | --- |+| "Docker build takes a while and downloads base images." | It is a one-layer-cached `python:3.11-slim` pull plus a pip install; run it, it completes within this session. If Docker is genuinely unavailable in a future environment, fall back to installing `Pillow==13.0.0` into a local venv alongside rembg's other pins and running `test_rembg_policy.py`/`test_rembg_smoke.py` directly, but Docker is confirmed available here (`docker ps` succeeds), so use the real build gate. |+| "The OSV advisory count might differ from the 41 cited here." | The exact count drifts as OSV adds entries; what matters is that Pillow 13.0.0 is the latest stable release and the fix-version every currently-known advisory against 12.3.0 points to. Bump to 13.0.0, not to some intermediate version, and move on. |+| "Should this also touch `transformers` or `diffusers` pins while in this area?" | No. Those pins carry their own deliberate, already-reasoned comments explaining a torch/base-image blocker; touching them is a separate, larger decision this order does not cover. |+| "rembg's own `[gpu]` extra or ONNX pin might need to move too." | No. This order is scoped to Pillow only; `onnxruntime==1.28.0` and `rembg==2.0.75` are unaffected by this advisory set and are not being re-evaluated here. |++## Report format++State: the old and new Pillow version, the before/after `audit:deps` advisory counts for this file, the Docker build result (pass/fail and the two build-gate test names it ran), the `check:rules` result, and the commit hash.diff --git a/prompts/finish/450-auto-dependency-cve-modly-host-four-pins.md b/prompts/finish/450-auto-dependency-cve-modly-host-four-pins.mdnew file mode 100644index 000000000..ac506a56f--- /dev/null+++ b/prompts/finish/450-auto-dependency-cve-modly-host-four-pins.md@@ -0,0 +1,112 @@+# 450. `workers/modly/requirements-host.txt` carries four stale pins with open advisories, including a CRITICAL cert-bundle issue, and no comment explaining any of them++How to run: paste this file's repo path into a fresh Claude Code chat in this repository and say "run this work order". Runnable now, no gate, no owner action required.++## Operating clause (binding)++- Read CLAUDE.md first. CLAUDE.md overrides everything, including this file.+- Finish 100% in this session. Never end the turn with a question, an option list, or an unexecuted plan.+- This is a bug fix (a security defect): follow the test-first rule (CLAUDE.md, "Bug fixes are test-first") as far as it applies. There is no app-level behavior bug to reproduce with a new failing test (this is a dependency-version fix); the equivalent "prove it fails first" step is the OSV scan in step 2 below, run before the bump, then again after.+- The only permitted stops are the CLAUDE.md stop-and-ask gates (spend/on-chain writes, push/deploy, posting externally, committing content referencing a crypto project other than `$THREE`, destroying unrecoverable data). This order touches none of them.+- Concurrent agents share this worktree: stage explicit paths only (never `git add -A` or `git add .`), re-check `git status` and `git diff --staged` before committing.+- The em-dash and en-dash characters are banned in everything you write.++## Why this matters (measured 2026-10-25)++`npm run audit:deps` (the repo's OSV-based Python pin scanner, `scripts/check-deps.mjs`) run today against `workers/modly/requirements-host.txt` reports open advisories against four of its pins, none of which carry any justifying comment in the file (unlike the `transformers`/`diffusers` pins in sibling workers, which do carry deliberate "held back by a base-image constraint" comments; these four have no such note, they are plain oversights):++ GHSA-6q48-6c7w-9gw2 [CRITICAL] certifi bundles emSign root CAs with compromised intermediate CA keys+ fixed in 2026.10.19++ GHSA-r6ph-v2qm-q3c2 [HIGH] Subgroup attack, missing validation for SECT curves, fixed in 46.0.5+ GHSA-jwv3-5hgf-82ww [HIGH] Duplicate self-signed intermediates cause exponential path-building, fixed in 49.0.0+ GHSA-537c-gmf6-5ccf [HIGH] Vulnerable OpenSSL included in cryptography wheels, fixed in 48.0.1+ GHSA-g6cj-pr64-35w5 [HIGH] PKCS#7 EnvelopedData decryption exposes a Bleichenbacher oracle, fixed in 50.0.0+ GHSA-p423-j2cm-9vmq [MODERATE] Buffer overflow on non-contiguous buffers, fixed in 46.0.7+ GHSA-m2h6-j472-rp4c [MODERATE] Wildcard DNS name verifier escapes permittedSubtrees, fixed in 49.0.0+ GHSA-m959-cc7f-wv43 [LOW] Incomplete DNS name constraint enforcement, fixed in 46.0.6+ (plus PYSEC-2026-2141, the same subgroup-attack finding under its PyPI advisory ID)++ GHSA-6w46-j5rx-g56g [MODERATE] Vulnerable tmpdir handling, fixed in 9.0.3++ GHSA-wp53-j4wj-2cfg [HIGH] Arbitrary file write via non-default configuration, fixed in 0.0.22+ GHSA-pp6c-gr5w-3c5g [HIGH] Unbounded multipart part headers DoS, fixed in 0.0.27+ GHSA-5rvq-cxj2-64vf [HIGH] Quadratic-time querystring parsing DoS, fixed in 0.0.30+ GHSA-mj87-hwqh-73pj [MODERATE] DoS via large multipart preamble/epilogue, fixed in 0.0.26+ GHSA-vffw-93wf-4j4q [LOW] Content-Disposition parameter smuggling, fixed in 0.0.30+ GHSA-6jv3-5f52-599m [LOW] Semicolon field-separator parameter smuggling, fixed in 0.0.30+ GHSA-v9pg-7xvm-68hf [LOW] Negative Content-Length buffers entire body in memory, fixed in 0.0.31++The file's own header comment states the policy that makes fixing this safe: "Modly's own `api/requirements.txt` lists these packages with lower bounds only; the versions below satisfy every bound it declares." That means every pin in this file is free to move upward; nothing here is held down by Modly's own declared requirements. Current upstream latest (checked today via `pip index versions <pkg>`): `certifi` 2026.10.23, `cryptography` 50.0.2, `pytest` 9.1.1, `python-multipart` 0.0.32.++This worker's backend (Modly, fetched at a pinned commit per `workers/modly/Dockerfile`) and the three.ws front code both run on this requirements file; `cryptography` and `certifi` sit directly on the TLS path every outbound call this worker makes depends on (Hugging Face Hub downloads, GCS uploads, MCP), and `python-multipart` is a declared dependency of Modly's own FastAPI backend for request-body parsing, which is reachable the moment a caller sends a crafted request to that backend. This is the same "hostile-input pass" class `prompts/masters/06-the-adversary.md` calls for: a request-parsing library with open DoS/arbitrary-file-write advisories sitting in front of a backend that serves third-party job requests is exactly the surface that lens says to check first.++Not a duplicate of order 449 (that order is the same scan surfacing a Pillow finding in a different worker, `workers/rembg`, a different package, different file, no overlap) or of the `transformers`/`diffusers` findings already triaged and intentionally left alone across `workers/model-triposg`, `workers/texture`, `workers/model-hunyuan3d`, `workers/modly/requirements-triposg.txt`, `workers/modly/requirements-hunyuan.txt`, and `workers/longcat` (those carry explicit base-image-compatibility comments; the four pins here carry none).++## Task++1. Read `workers/modly/requirements-host.txt` in full (currently ~30 lines) and confirm the four pins named above and the absence of any justifying comment for them.+2. Before changing anything, run the scanner and capture the "before" state:++ npm run audit:deps 2>&1 | tee /tmp/audit-deps-modly-before.log+ awk '/^[a-zA-Z0-9_.-]+@[0-9A-Za-z.+-]+$/{pkg=$0} /in: workers\/modly\/requirements-host.txt/{print pkg}' /tmp/audit-deps-modly-before.log | sort -u++ Confirm it lists `[email protected]`, `[email protected]`, `[email protected]`, `[email protected]` (counts may drift slightly from this order's writing if OSV added or reclassified entries; that does not change the fix).+3. Edit `workers/modly/requirements-host.txt`: bump the four pins to a version that clears every advisory above:+ - `certifi==2025.8.3` to `certifi==2026.10.23` (fixes the CRITICAL emSign finding; pure CA-bundle data update, no API surface).+ - `cryptography==45.0.7` to `cryptography==50.0.2` (clears every HIGH/MODERATE/LOW listed above; use the latest stable rather than stopping at the lowest fixed version, consistent with the Pillow precedent in order 449 and in the sibling worker files that are already on current pins).+ - `pytest==8.3.5` to `pytest==9.1.1` (clears the tmpdir advisory; this is the only `pytest==` pin anywhere in `workers/`, `services/`, or `packages/`, confirmed via `grep -rn "^pytest==" workers/*/requirements*.txt`, so there is no cross-worker consistency constraint to preserve).+ - `python-multipart==0.0.20` to `python-multipart==0.0.32` (clears every advisory above).+ Add a short comment above the block (matching the file's existing section-header style) noting these four are kept current because nothing in this file is held down by Modly's declared lower bounds, per the header comment already in place.+4. Re-run the scanner and capture the "after" state:++ npm run audit:deps 2>&1 | tee /tmp/audit-deps-modly-after.log+ awk '/^[a-zA-Z0-9_.-]+@[0-9A-Za-z.+-]+$/{pkg=$0} /in: workers\/modly\/requirements-host.txt/{print pkg}' /tmp/audit-deps-modly-after.log | sort -u++ Confirm none of the four packages appear in this output for `workers/modly/requirements-host.txt` anymore.+5. Verify the bump installs and the host-side code still works, without the full GPU/CUDA image build (that build also clones and compiles two separate extension repos and pulls a multi-GB CUDA devel base image; it is disproportionate to a version-only pin bump and is not required here, since none of these four packages touch torch or CUDA). In a throwaway virtualenv:++ python3 -m venv /tmp/modly-host-venv+ /tmp/modly-host-venv/bin/pip install -r workers/modly/requirements-host.txt+ /tmp/modly-host-venv/bin/python -c "import certifi, cryptography, pytest, multipart; print(certifi.__version__, cryptography.__version__, pytest.__version__, multipart.__version__)"++ Confirm it prints `2026.10.23 50.0.2 9.1.1 0.0.32` (or whatever the current latest resolved to) with no install errors.+6. Run the front's own CPU-only test suite against that venv, since this is the real exercise of the bumped stack end to end (FastAPI/Starlette request handling via `httpx`/`python-multipart`, the TLS stack via `cryptography`/`certifi`, pymeshlab/trimesh/numpy via `pytest`):++ cd workers/modly+ MODLY_CONTRACT_REQUIRE_BACKEND= /tmp/modly-host-venv/bin/python test_app_contract.py+ /tmp/modly-host-venv/bin/python -m pytest test_postprocess.py test_request_policy.py test_storage_backend.py -q++ `test_app_contract.py` must print only Part A's passes and exit 0 (Part B is skipped since `MODLY_CONTRACT_REQUIRE_BACKEND` is unset, matching how the file documents running outside Docker). All three pytest files must pass. If anything fails, read the failure, it is either a real incompatibility (fix forward, e.g. a pytest 9 collection change) or an environment gap (missing system lib for pymeshlab); do not skip the fix to avoid diagnosing it.+7. Remove the throwaway venv (`rm -rf /tmp/modly-host-venv`) so it leaves no artifacts.+8. Run `npm run check:rules -- --paths workers/modly/requirements-host.txt` and fix anything it flags.+9. Add a `data/changelog.json` entry (tag `fix`) noting the Modly 3D-generation worker closed a batch of TLS, request-parsing, and test-tooling security advisories, matching the style of the entry order 449 adds, then run `npm run build:pages` and confirm only the expected generated files change.+10. Read the full diff (`git diff workers/modly/requirements-host.txt data/changelog.json`) and confirm every changed line is one of the four version bumps, the new comment, and the one changelog entry.++## Done when++- `workers/modly/requirements-host.txt` pins `certifi==2026.10.23`, `cryptography==50.0.2`, `pytest==9.1.1`, `python-multipart==0.0.32` (or whatever was current latest at fix time if this order runs later than written), each clearing every advisory listed above.+- `npm run audit:deps` no longer reports any of the four packages against `workers/modly/requirements-host.txt` (before/after logs captured).+- A throwaway venv with the new requirements installs cleanly and prints the expected versions.+- `test_app_contract.py` Part A and the three CPU-only pytest files (`test_postprocess.py`, `test_request_policy.py`, `test_storage_backend.py`) all pass against the bumped stack.+- The throwaway venv is removed.+- `npm run check:rules -- --paths workers/modly/requirements-host.txt` reports no violations.+- A changelog entry exists and `npm run build:pages` ran cleanly.+- Nothing outside `workers/modly/requirements-host.txt`, `data/changelog.json`, and the generated `public/changelog*`/`CHANGELOG.md` files changed.++## Never blocked++| Apparent blocker | Resolution |+| --- | --- |+| "Bumping pytest 8 to 9 is a major version, might break test collection." | Verify by running the three pytest-based suites listed in step 6 against the bumped version. If a collection or fixture incompatibility surfaces, it is a real, fixable issue (adjust the affected test), not a reason to hold the pin back; pytest is a test-only dependency here, never shipped on a request path. |+| "The full Modly Docker image build would exercise this more thoroughly." | True but disproportionate: that build pulls a multi-GB CUDA devel base image and compiles two extension repos, none of which touch these four packages. The venv-based verification in steps 5 to 6 exercises the actual code paths (FastAPI/Starlette, TLS, pymeshlab/trimesh) that these packages serve. The full image build happens naturally at the next real deploy and is not gated by this order. |+| "python-multipart isn't imported directly in this worker's own main.py." | Correct, it backs Modly's own fetched FastAPI backend, not the three.ws front's code. The version bump and the advisories it closes apply regardless of which side exercises it; verifying via `test_app_contract.py` (which calls into the installed FastAPI/Starlette stack) is the correct host-side check available without the full backend build. |+| "Should certifi/cryptography go further than the lowest fixed version?" | Already done: use current latest (`50.0.2` / `2026.10.23`), not the lowest version that merely clears the listed advisories, consistent with order 449's Pillow bump and the already-current sibling worker pins. |++## Report format++State: the four old and new pin versions, the before/after `audit:deps` findings for this file, the venv install result, the `test_app_contract.py` and pytest results (pass counts), the `check:rules` result, and the commit hash.