Skip to content

ci(models): Model Requant Upload: re-quantize a revision on a runner, verify byte for byte, upload with the repo's R2 secrets (no promotion) [master] - #1976

Open
jonathan308 wants to merge 8 commits into
masterfrom
ci/model-requant-upload-master
Open

jonathan308 wants to merge 8 commits into
masterfrom
ci/model-requant-upload-master

Conversation

@jonathan308

@jonathan308 jonathan308 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Into master: GitHub starts a workflow_dispatch workflow only from the default branch, so this is the copy that matters. The same change goes into dev in #1975.

Approved in the delta review (11-10); ready for review.

Summary

Model Requant Upload (.github/workflows/model-requant-upload.yml) uploads a re-quantized revision of an existing model to darkbloom-models with the repository's existing R2 secrets. No one reads the credentials and no new secret is needed. It never registers or promotes: that stays Register Model (publish_revision_only=true, promote=true), on its own approval.

Why:

  • The better-4-bit builds need an R2 upload.
  • The R2 keys exist only as GitHub Actions secrets.
  • No existing workflow uploads model artifacts: release-provider.yml uploads provider releases to d-inf-app.

How it works

It runs from master only: a run on any other ref fails at its first step. It has two jobs:

  • preflight holds no secret. It runs the ref guard, validates the inputs, installs the hash-pinned tools and runs the quantizer's selftest.
  • requant-upload has needs: preflight and environment: prod. So each run waits for Gajesh2007's approval of the prod environment after a green preflight. He is its required reviewer and admins can't bypass it. The environment's deployment policy allows master, v* branches and v* tags; the ref guard narrows that to master.
    • Owner notes on prod:
      • drop the v* branch rule;
      • create any future PROD_R2_* inside prod;
      • never add R2_* to prod (they would silently replace what keys=legacy means).
Mode (of requant-upload) What Keys in scope
check (default) The selftest. Then both key sets each make a read-only head-object of the template's manifest.json in darkbloom-models: legacy (the repo's R2_* from 04-04, which the 0.10.11 production release used) and prod (PROD_R2_*). It prints only one verdict per set: pass, fail, absent (every part empty; not a failure of the run) or fail (incomplete). It fails only if no set passes both sets, check step only
build Check, then rebuild on the runner and verify byte for byte against manifest_json. No write the check step only
upload Build, then publish-model-revision.py's conditional reservation (an existing revision with other bytes is refused) and the upload, manifest last. It uses the keys input's set: legacy by default, or prod, which refuses while PROD_R2_* are absent. That set must have passed this run's check: the check fails early otherwise, and the upload step refuses again. Needs confirm_version = version the check step; the upload step holds only the chosen set

Findings (22:36Z):

  • The prod branch policy admits master. Custom policies: branch master, branch v*, tag v*. The required reviewer is Gajesh2007, and admins can't bypass.

  • PROD_R2_* are not set anywhere today.

    • The prod environment has 0 secrets, and there are no repo or org PROD_R2_*.
    • The 0.10.11 prod release (run 42693869770) logged "Using legacy unprefixed secret" for every R2 key.
    • The owner's decision (23:23Z): keys defaults to legacy. A check today should report keys prod (PROD_R2_*): absent, and keys=prod uploads refuse until those secrets exist.
  • Rebuild instead of staging. scripts/models/requant.py (numpy only, no MLX, no GPU) re-quantizes the language-model linears from the pinned bf16 Hugging Face source. It copies every other byte of the current revision.

  • Why the rebuilt bytes are the tested bytes. The output is deterministic for a given template, source, recipe and numpy. So verifying against the canonical manifest of the locally built and qualified candidate proves the upload is the tested bytes.

  • Byte equality is checked in about a second, before any secret:

    • What requant.py selftest covers:
      • fixed SHAKE-256-generated inputs: weight-like values, edge cases, and a strided, chunked MoE expert half;
      • every width a recipe produces: 4/64, 4/32, 6/64 and 8/64;
      • the safetensors, config and index serialization.
    • What it checks: 13 digests, recorded with numpy 2.5.4. The same 13 come out with SIMD dispatch disabled and with numpy 2.0.2 / Python 3.9. Every quantization digest equals a float64 oracle that depends on no CPU or SIMD path.
    • What it prints: its own sha256, Python, numpy and numpy's SIMD targets.
    • On a mismatch: the runbook forbids loosening the check. The fallback moves the locally qualified bytes through a pinned Hugging Face commit instead.
  • The format against MLX: checked against MLX-written tensors at 4/64, 4/32, 5/64, 6/64 and 8/64. 99.6–99.9 % of codes are equal; the rest are one step apart, from one-ulp bf16 scale rounding.

Security

  • Inputs are untrusted. They reach scripts only through env, never through an expression in a script. upload-model-revision.py inputs validates them before any secret is in scope:
    • the template is https://models.darkbloom.ai/v2/<slug>--<12 hex>/<version> (a full match), a revision of the same model ID;
    • the source is pinned to a 40-hex Hugging Face commit;
    • the recipe is known;
    • the version is one path component that doesn't start with ..
  • The manifest must be one that Register and every provider read:
    • schema 1 and integer counts;
    • created_at in darkbloom-publish hash's form. Without it, Register would promote the manifest, but no provider could decode it (Manifest.swift);
    • file_count, the total and the aggregate recomputed;
    • unique paths (ignoring case), with no hidden, empty, dot or control parts;
    • each file's role is ModelScanner.roleFor's.
    • 13 of the 14 published manifests pass. The Bonsai 2 9B manifest has fractional seconds, which older Foundation refuses.
  • Tools are installed with pip --require-hashes --only-binary :all: from scripts/models/requirements-requant-upload.txt: awscli 1.46.3 and its dependency closure, at the versions release-provider.yml resolved on 11-09, plus numpy 2.5.4. Every hash is the one PyPI lists for its wheel.
  • Secrets: the R2 secrets appear only in the prod job, and only in two steps.
    • The check step holds both sets. An absent or incomplete set runs nothing.
    • The upload step holds only the chosen set: per variable, two exclusive inputs.keys == '<set>' && secrets.X || '' expressions. It stops, naming the set's secrets, if any part is empty.
  • Logs: the check prints only one verdict per set. aws's output, which can name the endpoint, is discarded.
  • Hardening: permissions: contents: read, persist-credentials: false, one run at a time. The only action is actions/checkout pinned by SHA.

Validation

  • scripts/models/test_model_requant_upload.py: 25 tests (20 before the owner's key and approval decisions), OK with numpy 2.5.4 / Python 3.14 and with numpy 2.0.2 / Python 3.9. Without numpy they are OK with 7 skipped. They were written red first against the first version (42 failures, 5 errors) and cover:
    • input and manifest refusals (30 manifest cases), and that the published Qwen3.5-9B manifest passes;
    • the workflow's jobs and steps:
      • Structure: a secret-free preflight, then the prod job.
      • Run in Bash with a fake aws and python3:
        • master only, in both jobs;
        • both key sets checked, printing only a verdict per set, with no digit of the endpoint;
        • an absent set is reported and doesn't fail the run; an absent or incomplete set runs nothing;
        • an upload with an unchecked or failing set is refused;
        • the upload holds only the chosen set.
      • Also: tools by hash, the selftest before any secret, and no expression in any script;
    • range reads that must return exactly the range, and 429s that wait for Retry-After;
    • the selftest passes, catches a changed digest and a changed bf16 rounding, matches the float64 oracle, and covers every recipe width.
  • CI: Release Integrity runs these tests. scripts/test-darkbloom-route.py classifies the workflow as UNROUTED (31 OK).
  • Tools: a hash-verified install on macOS arm64 / cp314, and a hash-verified download for manylinux x86_64 / cp312 (the runner).
  • Docs: docs-impact OK. docs-check's 3 problems are links into the uninitialised libs/mlx-swift-lm submodule, present without this change. The changelog fragment is valid.
  • Not run: any dispatch. No R2 or registry action was taken.

Use, for the better-4-bit builds

  1. Locally (Mac B):
    • install from the same requirements file (Python ≥ 3.12);
    • run requant.py selftest;
    • build and qualify the candidate;
    • hash it with darkbloom-publish hash … --id <model> --version <new>.
  2. Dispatch gh workflow run model-requant-upload.yml --ref master -f mode=check … and approve the prod deployment. Use build for the first model, then upload with confirm_version (keys defaults to legacy; its set must pass check).
  3. On the owner's go: Register Model with publish_revision_only=true and promote=true.

Contracts and documentation

  • docs/operations/model-revisions.md, "Re-quantize and upload from CI"; docs/developer/test.md; changelog.d/model-requant-upload.md.
  • No provider, coordinator or protocol change.

jonathan308 and others added 3 commits November 10, 2026 13:06
… verify it byte for byte, upload with the repo's R2 keys

A workflow_dispatch workflow that uploads a re-quantized revision of an existing
model with the repository's R2 secrets, so no one handles the credentials and no
new secret is needed. It never registers or promotes.

- Modes: check (default; reads one known object in darkbloom-models, so a
  credential that only reaches the release bucket fails here), build (rebuild
  plus verify, no write), upload (the same, then publish-model-revision.py's
  conditional reservation and upload, manifest last; needs confirm_version).
- The runner rebuilds the candidate with scripts/models/requant.py (numpy only):
  the language-model linears re-quantized from the pinned bf16 source, every
  other byte copied from the current revision. The output is deterministic for
  a template, source, recipe and numpy 2.5.4, so verifying against the
  manifest of the locally built and qualified candidate proves the same bytes.
- upload-model-revision.py validates inputs before any secret is in scope (a
  models.darkbloom.ai revision of the same id, a 40-hex-pinned HF source, a
  known recipe, the manifest's id, version and canonical r2_prefix, which
  reproduces all 14 published prefixes), verifies the exact file set, sizes and
  sha256, and reuses publish-model-revision.py's reservation and upload.
- Inputs reach scripts only through env; permissions contents: read;
  persist-credentials false; the R2 secrets appear only in the read check and
  the upload step.

requant.py's quantization and packing were checked against MLX-written
tensors at 4/64, 4/32, 5/64, 6/64 and 8/64 (99.6-99.9 % of codes equal, the
rest one step apart from one-ulp bf16 scale rounding).

Docs: docs/operations/model-revisions.md, "Re-quantize and upload from CI".
Tests: scripts/models/test_model_requant_upload.py (7: canonical prefixes,
input refusals, the upload confirmation, exact-file verification, workflow
guards, packing round trip); OK with and without numpy. docs-impact OK;
docs-check's 3 problems are links into the uninitialised mlx-swift-lm
submodule, present without this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests first, against ace8cfb; each fails there (42 failures, 5 errors in
16 of 20 tests; scripts/test-darkbloom-route.py fails 1 of 31):

- Manifest: what Register (ValidateModelManifest) and every provider
  (Manifest.swift's non-optional created_at, validateArtifactManifest,
  ModelScanner.roleFor) read: created_at in darkbloom-publish's form, schema 1,
  integer counts, file_count, total, the aggregate recomputed, unique paths
  case-insensitively, the scanner's role, no hidden, empty, dot or control
  path parts. The published Qwen3.5-9B manifest must pass. verify refuses an
  invalid manifest even when the bytes match.
- template_url: no newline (a second GITHUB_OUTPUT line), query or deeper path.
- The workflow's steps, run as the runner's bash runs them with a fake aws and
  python3: only from refs/heads/master; each credentialed step stops on any
  empty R2 secret before running anything; the read check prints no digits of
  the endpoint on a connection error but keeps "(403)"; tools installed only
  with --require-hashes from a pinned requirements file; requant.py selftest
  and its sha256 right after the install, in every mode, before any secret;
  no expression in any run body; the rebuild streams its progress.
- requant.py: a range read must return exactly the range; 429 waits for
  Retry-After; `selftest` passes, catches a changed digest and a changed
  bf16 rounding; every selftest case equals a float64 oracle; the selftest
  covers every (bits, group) a recipe uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#1975)

Green for 3a6f828's tests (20 OK with numpy 2.5.4 / Python 3.14, with
numpy 2.0.2 / Python 3.9, and without numpy, 7 skipped);
test-darkbloom-route.py 31 OK.

- B1, CI: model-requant-upload.yml is classified UNROUTED (credentialed,
  literal Blacksmith runner), so test_every_workflow_is_classified passes here
  and in master's required Release Integrity.
- S1: the tools install with pip --require-hashes --only-binary :all: from
  scripts/models/requirements-requant-upload.txt: awscli 1.46.3 and its
  dependency closure at the versions release-provider.yml resolved on 11-09
  (run 42693869770), and numpy 2.5.4; every wheel hash PyPI lists. Checked: a
  hash-verified install on macOS arm64 / cp314, and a hash-verified download
  for manylinux x86_64 / cp312 (the runner); put-object --if-none-match is
  there.
- S2: the read check prints only aws's parenthesised error code ("(403)");
  a connection error's text, which names the endpoint, is withheld.
- S2: both credentialed steps stop, naming the secret, when any of
  R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY or R2_ENDPOINT is empty, before any
  command runs (`test -n a && test -n b` did not stop under errexit).
- S3: manifest_problems() mirrors Register's ValidateModelManifest and the
  provider's reader: schema 1; integer counts; created_at required, in
  darkbloom-publish's ISO 8601 form with whole seconds (Manifest.swift's
  createdAt is not optional, so a manifest without it is promoted by Register
  but no provider can decode it); file_count, total and the aggregate
  recomputed; paths unique case-insensitively, no hidden, empty, dot or
  control parts; each role ModelScanner.roleFor's. `inputs` and `verify` (so
  `upload`) refuse otherwise. 13 of the 14 published manifests pass; the
  Bonsai 2 9B one has fractional seconds (macOS 27's decoder accepts them,
  older Foundation does not), so it would be refused.
- S4: the first step refuses any ref but refs/heads/master, with an error
  (a job-level `if` would only skip). Documented: --ref master.
- S5: `requant.py selftest` (~0.1 s, no network): SHAKE-256-generated bf16
  inputs (weight-like with outliers; signed zeros, ties, subnormals, constant
  groups, ranges overflowing float32; a strided gate half of a fused
  [E, 2I, H] expert tensor in uneven row chunks, which must equal the
  unchunked result) at 4/64, 4/32, 6/64 and 8/64 (every width a recipe
  produces; a test enforces that), plus the safetensors, config and index
  serialization. 13 digests recorded with numpy 2.5.4; the same 13 with SIMD
  dispatch disabled and with numpy 2.0.2 / Python 3.9; every quantization
  digest equals the float64 oracle in the tests. It prints requant.py's
  sha256, Python, numpy and its SIMD targets. The workflow runs it right after
  the install in every mode, before any secret; the runbook runs it before
  every local build. On a mismatch the runbook forbids loosening the check:
  the fallback moves the locally qualified bytes through a pinned Hugging Face
  commit instead.
- N1: template_url must fullmatch https://models.darkbloom.ai/v2/<slug>--<12
  hex>/<version> (no newline into GITHUB_OUTPUT, no query, no deeper path);
  versions may not start with '.' (".." passed before).
- N2: the rebuild streams its progress. N3: a range read must return exactly
  the range; 429/503 wait for Retry-After (else back off up to 10 min), 12
  tries. affine_quantize takes chunk_values (default unchanged).
- N6: the tests read every step and run the guard, check and upload scripts
  in Bash with a fake aws and python3; no run body holds an expression.
- CI: Release Integrity runs scripts/models' tests. Docs: the runbook
  (--ref master, one at a time, the selftest, the hash-pinned tools,
  Python >= 3.12, build once then upload, the fallback) and
  docs/developer/test.md. Changelog fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference-landing Ready Ready Preview Nov 11, 2026 12:06am UTC
darkbloom-status Ready Ready Preview Nov 11, 2026 12:06am UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 11, 2026 12:06am UTC

Request Review

Comment thread scripts/models/requant.py
UA = {"User-Agent": "or-quality-requant/1"}


def get(url, start=None, end=None, tries=12):
import tempfile
import textwrap
import threading
import unittest
jonathan308 and others added 2 commits November 10, 2026 14:42
…and checks both key sets (#1975)

The owner's decisions (11-10 22:36Z), as tests; each fails on 8237934
(8 failures in 24 tests):

- Two jobs: `preflight` (no environment, no secret: the ref guard, inputs,
  hash-pinned tools, the selftest), then `requant-upload` with
  `environment: prod` and `needs: preflight`, so the prod environment's
  required reviewer approves each run after a secret-free preflight, its
  branch policy applies, and its PROD_R2_* secrets are visible.
- `check` (id check) tests both key sets against darkbloom-models with a
  read-only head-object: the prod environment's PROD_R2_* and the repo's
  legacy R2_* (04-04), the release workflow's fallback. It prints only
  "keys <set>: pass|fail|fail (not set)", nothing of aws's output; a set
  with any part empty runs nothing; it fails if neither set passes, and in
  upload mode if the chosen set did not pass.
- A `keys` input (choice prod|legacy, default prod), validated by `inputs`.
- `upload` holds only the chosen set (two exclusive expressions per
  variable) and refuses unless that set passed this run's check
  (steps.check.outputs) and no part of it is empty.
- Both jobs: the ref guard first, tools by hash, the selftest before any
  secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d PROD_R2_* keys, both key sets checked (#1975)

The owner's decisions (11-10 22:36Z). Green for 68ba4db's tests (24 OK
with numpy 2.5.4 / Python 3.14 and numpy 2.0.2 / Python 3.9; without numpy
OK, 7 skipped); test-darkbloom-route.py 31 OK.

- Two jobs. `preflight` (blacksmith-4vcpu, no environment, no secret): the
  ref guard, inputs, the hash-pinned tools, the selftest. `requant-upload`
  (`needs: preflight`, `environment: prod`): each run waits for the prod
  environment's required reviewer after a green preflight, the same gate as
  the provider release; no new mechanism. The environment's branch policy
  (custom: branch master, branch v*, tag v*) admits master. Its own ref guard,
  inputs, tools and selftest run again on its fresh runner.
- `check` tests both key sets with a read-only head-object of the template's
  manifest.json in darkbloom-models: `prod` (secrets.PROD_R2_*, visible only
  to a job in the prod environment) and `legacy` (the repo's R2_* of 04-04,
  release-provider.yml's fallback). A set with any empty part runs nothing.
  It prints only "keys prod (PROD_R2_*): pass|fail|fail (not set)" and the
  same for legacy; aws's output is discarded. Outputs prod/legacy. It fails if
  neither passes, and in upload mode if the `keys` set did not pass.
- `keys` input (choice prod|legacy, default prod), validated by `inputs`.
- The upload step holds only the chosen set (per variable, two exclusive
  `inputs.keys == '<set>' && secrets.X || ''` expressions) and refuses unless
  steps.check.outputs.<set> is pass and no part of the set is empty.
- The inputs moved to the workflow-level env (both jobs read them).
- Docs: the runbook (two jobs, the prod approval, the key sets, keys=) and
  docs/developer/test.md; the changelog fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 and others added 2 commits November 10, 2026 15:25
…bsent set is reported, not a failure (#1975)

The owner's decisions (11-10 23:23Z), as tests; 4 of 25 fail on 894caea:

- `keys` defaults to legacy (the repo's R2_*, which the 0.10.11 prod
  release used for every key), in the workflow input and in
  upload-model-revision.py; prod stays an option.
- `check` reports a set with every part empty as "absent", which is not a
  failure of the run; a set with some parts empty is "fail (incomplete)";
  neither runs anything. The run fails only when no set passes (both absent
  included), or in upload mode when the keys set did not pass (absent
  included).
- The workflow header says each run waits for Gajesh2007's approval of the
  prod environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…set is reported, not a failure (#1975)

The owner's decisions (11-10 23:23Z). Green for 0c4f948's tests (25 OK
with numpy 2.5.4 / Python 3.14 and numpy 2.0.2 / Python 3.9; without numpy
OK, 7 skipped); test-darkbloom-route.py 31 OK.

- `keys` defaults to legacy: the repo's R2_*, which the 0.10.11 production
  release used for every key (PROD_R2_* exist nowhere: the prod environment
  had 0 secrets on 11-10). prod stays an option; it refuses while its set is
  absent. Same default in upload-model-revision.py.
- `check` still tests both sets and reports one verdict per set: pass, fail,
  absent (every part empty; not a failure of the run) or fail (incomplete);
  neither absent nor incomplete runs anything. The run fails only when no set
  passes, or in upload mode when the keys set is not pass ("is absent in
  this check" for prod today).
- The prod environment gate stays on the job that holds keys. The workflow
  header now says it plainly: each run waits for Gajesh2007's approval of the
  prod environment (its required reviewer; admins can't bypass); no other
  gate. Docs: the runbook and the changelog fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the owner's notes on it (#1975)

The delta review (11-10) approved #1976 and #1975 with docs-only fixes:

- The workflow header and the runbook no longer call `prod` "the same gate
  as the provider release" (no release has run in it since 10-08). They say
  the key-holding job runs in the `prod` environment, which needs
  Gajesh2007's approval and allows `master`, `v*` branches and `v*` tags.
- Owner notes, in the header and the runbook: drop the `v*` branch rule from
  `prod`'s deployment policy; create any future PROD_R2_* inside `prod`; never
  add R2_* to `prod` (same-named environment secrets would silently replace
  what keys=legacy means). The gate protects only secrets created in `prod`.

No code change; 25 tests OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 11, 2026
…d the owner's notes on it (#1975)

The delta review (11-10) approved #1976 and #1975 with docs-only fixes:

- The workflow header and the runbook no longer call `prod` "the same gate
  as the provider release" (no release has run in it since 10-08). They say
  the key-holding job runs in the `prod` environment, which needs
  Gajesh2007's approval and allows `master`, `v*` branches and `v*` tags.
- Owner notes, in the header and the runbook: drop the `v*` branch rule from
  `prod`'s deployment policy; create any future PROD_R2_* inside `prod`; never
  add R2_* to `prod` (same-named environment secrets would silently replace
  what keys=legacy means). The gate protects only secrets created in `prod`.

No code change; 25 tests OK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan308
jonathan308 marked this pull request as ready for review November 11, 2026 03:35
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head c323531d338e against base 34c4a10d86aa.

Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: selected depth completed (5 batches); openai/gpt-6.1-sol: selected depth completed (4 batches)

LOW: requant.py build writes template-manifest paths to disk without containment or scheme checks

scripts/models/requant.py:406 · new attack surface

cmd_build reads the template's manifest.json over the network and, for each entry, opens os.path.join(a.out, p) for writing with no check on p. A path with '..' or an absolute path escapes the output directory. The same applies to tensor-derived filenames from the template's weight map. The docs say only the workflow's input manifest_json and template_url are validated (no '.'/'..' parts). They do not say the fetched template manifest is validated. Likewise get() passes any URL to urllib.urlopen, so a file:// URL or a redirect is accepted if the workflow guard is bypassed. If the model bucket, the CDN or the template content were tampered with, the build job could overwrite files in the runner workspace, including inputs of the later upload step in the secret-bearing prod-environment job. Fix: in the script, reject any p that is not a single safe relative component or that resolves outside a.out. Also restrict the URL scheme to https and the allowed hosts, and validate the fetched manifest the same way as manifest_json.

Raised by: anthropic/claude-sonnet-5.5

LOW: requant.py build writes template-manifest paths to disk without containment checks

scripts/models/requant.py:406 · new attack surface

cmd_build reads manifest.json from the remote template URL and, for every non-model entry, writes the downloaded bytes to os.path.join(a.out, f["path"]). The path is never checked for absolute components, ".." segments or path separators. A compromised or mistaken template manifest, or a template URL pointed at an attacker-controlled host, could make the build write files outside the output directory on the CI runner or a developer Mac. Within the output directory it could also overwrite the regenerated config.json or index, since only the names "config.json" and "model.safetensors.index.json" are skipped. The copied files are not verified against the manifest sha256 either. Fix: reject any path that is not a plain relative basename or normalized subpath, resolve it under a.out and assert containment, and verify each copied file's size and hash against the manifest before writing.

Raised by: anthropic/claude-sonnet-5.5

LOW: requant.py build writes template-manifest paths to disk without containment or scheme checks

scripts/models/requant.py:406 · T-012, T-027

Two source passes report that cmd_build in scripts/models/requant.py (about lines 401-410) fetches the template's manifest.json and writes each non-model entry to os.path.join(out, path) without rejecting absolute paths, '..' segments or separators, and without checking the entry's sha256. I could not replay requant.py in this pass, so the line number and behavior come from those passes. If the template were tampered with or mistaken, the build could write outside the output directory on the runner. In the prod-environment job, $RUNNER_TEMP holds manifest.json and the hash-pinned venv at tools/bin, which is on PATH. An overwrite of tools/bin/* or manifest.json could therefore execute attacker-chosen code in the later upload step, which holds R2 write credentials. The workflow validates template_url as a models.darkbloom.ai URL under the model's own prefix, but not the manifest contents it points to. Fix: accept only plain relative paths, resolve each under out and assert containment, verify size and sha256 before writing, and restrict get() to https.

Raised by: anthropic/claude-sonnet-5.5

LOW: build writes template-manifest paths without confining them to the output directory

scripts/models/requant.py:406 · A-004, T-027

At scripts/models/requant.py lines 401-407 (head), cmd_build reads manifest.json from the template URL. It then writes every listed path with open(os.path.join(a.out, p), 'wb'). p is not normalized or rejected when absolute or when it contains '..', and os.path.join discards a.out when p is absolute. Trigger: a tampered or wrongly selected template prefix, or an operator-supplied --template URL pointing at a host they do not control, lists a path such as '../../.github/...' or '/home/runner/...'. Impact: arbitrary file write on the build host or CI runner. If the upload workflow holds R2 credentials (A-004 publication path), the next step could run the overwritten file and tamper with what gets uploaded. This matters because providers serve whatever revision is uploaded (T-012/T-027 class). The same unvalidated names reach the URLs built at lines 98 and 405 and the weight_map. Fix: accept only relative, normalized basenames matching an allowlist pattern, with no '/', '..' or absolute paths. Check os.path.realpath(dest) stays under a.out. Optionally verify each copied file's sha256 against the manifest entry before writing.

Raised by: anthropic/claude-opus-5.5

MEDIUM: Remote template manifest can write outside the build directory

scripts/models/requant.py:406 · new attack surface

cmd_build takes file paths directly from the downloaded template manifest and passes them to os.path.join(a.out, p) without containment checks. A malicious template manifest can supply an absolute path or a path containing '..', causing copied bytes to overwrite files accessible to the invoking account outside the output directory. This occurs during reconstruction, before the runbook's downstream candidate-manifest verification, so that verification cannot undo the write. A compromised template host could consequently modify runner or local account files, potentially including executable files. Validate every downloaded manifest path before fetching or writing: reject absolute paths, traversal components and platform-specific separators, enforce output-root containment, and prevent symlink following. Validation of the separately supplied candidate manifest is not a substitute for validating this downloaded manifest.

Raised by: openai/gpt-6.1-sol

MEDIUM: Remote manifest paths can overwrite files outside the build directory

scripts/models/requant.py:406 · new attack surface

cmd_build takes each path directly from the downloaded template manifest and opens os.path.join(a.out, p) for writing without checking containment. A template endpoint serving a manifest entry such as '../existing-file' or an absolute path can supply bytes that overwrite any writable file at that location, rather than merely supplying model data. Creating a fresh output directory does not prevent this escape. This introduces a remote-data-to-local-filesystem write boundary in the new build tool. Reject absolute paths, traversal components and noncanonical paths before downloading or writing; enforce containment beneath the output directory and prevent symlink following.

Raised by: openai/gpt-6.1-sol

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Scan completed; human review required.
Cross-file reviewer requests further review; independent human review required; Final reviewer requests further review; independent human review required

Coverage: 57/57 source units; cross-file integration complete. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 0 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Bedrock: 26 request(s), 1083569 uncached + 0 cache-read + 157753 cache-write input / 30694 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately.
Workload allowance: 27 native request(s), including one shared response repair; 500 emergency ceiling. Selected depth and integration rounds are admitted as their scope becomes known.

This branch was successfully deployed

3 active deployments
Preview – eigen-homepages-darkbloom — c323531d Deployed Nov 11, 2026 by vercel[bot]
Preview – d-inference-landing — c323531d Deployed Nov 11, 2026 by vercel[bot]
Preview – darkbloom-status — c323531d Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant