Skip to content

OSS Scanner enrolment: a CPU-only Dockerfile and a threat model (.oss-scanner/) - #377

Merged
bong-water-water-bong merged 4 commits into
mainfrom
oss-scanner-enrol
Oct 9, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
oss-scanner-enrol

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Owner, 9 Oct: enrol the engine in Anthropic's OSS Scanner (github.com/anthropics/oss-scanner), contact [email protected].

The scanner builds the project in an isolated VM from a Dockerfile in our repository, then audits it offline and emails findings to the contact. This adds the two files the enrolment references:

  • .oss-scanner/Dockerfile: the engine as CI builds it (ubuntu 24.04, GCC 15, the ci.yml target list, the three Python tests, ctest), with debug info and frame pointers, CPU only, no submodules needed.
  • .oss-scanner/threat_model.md: where untrusted input enters (HTTP requests to serve, model and tokenizer files, config, tool outputs under --pm), what matters most and what is out of scope (third_party, hardware-only paths), how to exercise it without a GPU or NPU, and how we rate severity, consistent with SECURITY.md.

The enrolment PR itself goes to anthropics/oss-scanner (projects/1bit-engine/project.yaml pointing at these paths) once this is on main. A local docker build of the Dockerfile is running as verification; result to follow here.

🤖 Generated with Claude Code

…-scanner/)

Anthropic's OSS Scanner (github.com/anthropics/oss-scanner) builds a project
in an isolated VM and audits it offline; the enrolment references these two
files. The Dockerfile mirrors ci.yml (GCC 15, the CI target list, ctest) with
debug info and frame pointers. The threat model says where untrusted input
enters (requests to serve, model files, config), what matters, how to
exercise it without a GPU or NPU, and how we rate severity.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit b32c3d5)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Security Hardening

The Dockerfile builds the engine with debug info and frame pointers, which is acceptable for audit but lacks security hardening measures like stack canaries, ASLR, or non-executable stacks that are typically expected in production builds. This could expose the system to exploitation if the binary is executed in an untrusted environment.

# Build as CI does, with debug info and frame pointers for the audit. A failing step fails the build.
RUN cmake -S /src -B /src/build -G Ninja \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_C_COMPILER=gcc-15 -DCMAKE_CXX_COMPILER=g++-15 \
      -DCMAKE_C_FLAGS="-g -fno-omit-frame-pointer" \
      -DCMAKE_CXX_FLAGS="-g -fno-omit-frame-pointer" \
    && cmake --build /src/build -j"$(nproc)" --target onebit \
      npu_full_elf_test npu_pack_test npu_q4nx_test npu_private_route_test \
      tokenizer_test think_split_test gguf_meta_test laya_encoder_test \
      http_guard_test moe_gguf_index_test laya_bounds_test \
      npu_model_bounds_test npu_forward_loader_test tokenizer_linear_test

# The cheap tests, so the image is known to work; a failing test does not abort the build.
RUN cd /src && (python3 tests/gguf_to_q4nx_test.py && python3 tests/ternary_to_q4_0_test.py \
      && python3 tests/mtp_draft_vocab_test.py || echo "WARNING: a Python test reported failures") \
    && (ctest --test-dir /src/build --output-on-failure --timeout 300 || echo "WARNING: ctest reported failures")
Incomplete Scope Definition

The threat model defines what is in scope but does not clearly define the boundaries of the threat model itself. It's unclear whether the threat model covers all components that interact with untrusted input or if there are implicit assumptions about the environment in which the engine runs.

# Threat model

## What this project does and where untrusted input enters

The 1bit engine serves language models on AMD Strix Halo machines (the HRX GPU runtime and the
XDNA2 NPU) behind one OpenAI-compatible HTTP API, `1bit serve`, which Lemonade launches as a
backend (docs/lemonade.md, docs/serve.md). On the machine the scanner has, the GPU and NPU routes
cannot run; everything that parses input on the host can, and that is where untrusted input enters:

- **HTTP requests** to `1bit serve` (app/serve.cpp and app/*.cpp): JSON bodies on the chat,
  completion, embedding and reranking routes, headers (`Host`, `Origin`), query strings, and
  streamed responses coming back from the child `llama-server` that serve proxies. serve listens on
  127.0.0.1 and has no authentication of its own; its only request guards are the loopback `Host`
  and `Origin` checks (tests/http_guard_test). Lemonade is the layer that adds auth and binding.
- **Model files** opened by the engine itself: GGUF headers and tensor tables (gguf_meta,
  moe_gguf_index, the registry and routing code that reads architecture metadata), Q4NX model
  directories and their chunk tables (npu/q4nx*, npu_q4nx_test, npu_model_bounds_test), the NPU
  full-ELF containers and the ELF/PDI parsing around them (npu/full_elf*, npu_full_elf_test,
  npu_forward_loader_test), tokenizer JSON (tokenizer_*), and Laya's encoder checkpoint
  (laya_encoder_test, laya_bounds_test). A model file is downloaded from a public hub, so it is
  untrusted.
- **Configuration**: config/recipes.json, config/pm-experts.json, registry/architectures.json and
  the Lemonade-supplied command line (`--npu-opt`, `--pm-experts FILE`, `--lemonade-url`).
- **Tool outputs**: with `--pm`, serve runs a tool loop and calls other models through Lemonade's
  API; the text those models return is untrusted.

## Components that matter most / least

- **Most**: everything under `app/` (serve, the proxy, routing, the Project Manager loop), `npu/`
  host-side loaders and bounds code, the tokenizer loaders, `laya/` scorer input handling,
  `moe/` GGUF indexing, and the Python tools under `tools/` that rewrite model files.
- **Less**: build scripts and `scripts/` (they run with the developer's rights, not on a request
  path), docs, the registry generator.
- **Out of scope here**: `third_party/` (llama.cpp, HRX, Lemonade, the XDNA driver, tokenizers and
  the rest are pinned upstreams; report those to their own projects), GPU and NPU kernel dispatch
  that needs the hardware, and the weekly packaging workflows.

## How to exercise it

- `ctest --test-dir /src/build` runs the host-side suite (the Dockerfile already ran it once).
- `/src/build/1bit --help`, `1bit serve --help`, `1bit serve --recipes`, `1bit route ...` run with
  no hardware. Starting serve needs a model and a child `llama-server`, which this image does not
  have; the request-path code can still be driven through the unit tests (tests/http_guard_test,
  tests/smoke_serve, tests/think_split_test) and by reading app/serve.cpp.
- Loader fuzzing targets: the GGUF, Q4NX, full-ELF and tokenizer readers all take a file path and
  have small fixtures under tests/.

## How you rate severity

- Memory corruption (overflow, use-after-free, out-of-bounds read of attacker-controlled size)
  reachable from an HTTP request is **critical**; reachable from a model, tokenizer or config file
  is **high**.
- A request from a non-loopback origin that bypasses the `Host`/`Origin` guards, or any way for a
  web page to make serve do work, is **high**.
- Path traversal or arbitrary file read/write through a request field or a model directory is
  **high**.
- Denial of service of serve (crash, hang, unbounded allocation) from one request is **medium**;
  from a model file is **low** unless it is also memory corruption.
- Information leaks of local file contents through the API are **high**; leaks of file names or
  versions are **low**.

## Anything to leave alone

- `third_party/` and anything that only runs on the GPU or NPU.
- serve having no authentication and binding to loopback by default is a design decision
  (SECURITY.md); report bypasses of the loopback guards, not the absence of auth.
- The weekly release and bump workflows under `.github/workflows/` run with repository tokens on
  our own runners; they are not a request path.

bong-water-water-bong and others added 2 commits October 9, 2026 14:15
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit ac0817e

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 3f740d8

… (ctest 25/25 in the image)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit b32c3d5

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Local verification of the Dockerfile as the scanner builds it (docker build -f .oss-scanner/Dockerfile . on ryzen, Docker 29): image builds (2.2 GB), the engine and the CI target list compile with GCC 15, the three Python tests pass, and ctest reports 100% tests passed out of 25 inside the image. Two fixes on the way: CMake from PyPI (Ubuntu 24.04's 3.28 has no C++26 dialect), and curl/jq/make plus CC/CXX in the environment for the serve and configure tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant