Own the PDFium WebAssembly module: reproducible build in CI, pinned by sha256, loaded with InitWithWASM #1151

Open
opened 2026-11-09 14:00:40 +00:00 by Cordy · 0 comments
Owner

Tracking issue (long-term supply-chain setup for #1101; related: #1147 upstream asks, #1148 licence notices).

Today (v0.6.404, fixed in v0.6.405 on branch ccm6405). v0.6.404 read go-pdfium's embedded module through //go:linkname to internal/pdfium_wasm.Module to hash it for the compile-cache marker. That was a shortcut: it depends on a private symbol of another module. v0.6.405 removes it. It was never needed: wazero already keys its compilation cache by content (VERIFIED in wazero v1.12.0: internal/engine/wazevo/engine_cache.go fileCacheKey = sha256(Module.ID, "WAZEVO", CPU features), Module.ID = sha256 of the wasm bytes (internal/wasm/module.go AssignModuleID); entries carry the wazero version and a mismatch is stale). Cairn's marker is now housekeeping only (Go, go-pdfium, wazero builds).

Professional end state. We ship a 5.8 MB native-code-producing blob that we did not build and cannot rebuild:

  1. Build pdfium.wasm ourselves in CI from pinned sources (PDFium revision, Emscripten version, flags; recipe from Klippa, #1147), reproducibly (two builds, same sha256).
  2. Commit or publish the artefact with its sha256 and an SBOM (CycloneDX/SPDX listing PDFium, FreeType, libjpeg-turbo, zlib, lcms2, OpenJPEG, ICU, musl, LLVM runtime) and provenance (SLSA level 2+ attestation from the runner).
  3. Load it with webassembly.InitWithWASM(Config{WASM: ourBytes}) so go-pdfium's default embed is not linked (saves ~5 MB), and verify the sha256 at start (refuse to render on mismatch).
  4. Generate pdfium.LICENSE.txt from the same pinned sources (closes #1148's open points mechanically).
  5. Renovate-style update job: a new PDFium revision is a PR with the new hash, SBOM diff and test renders.

Until then: the go-pdfium module is pinned by go.sum (h1 hash of the module zip, which includes the wasm), which is integrity but not provenance.

Tracking issue (long-term supply-chain setup for #1101; related: #1147 upstream asks, #1148 licence notices). **Today (v0.6.404, fixed in v0.6.405 on branch ccm6405).** v0.6.404 read go-pdfium's embedded module through `//go:linkname` to `internal/pdfium_wasm.Module` to hash it for the compile-cache marker. That was a shortcut: it depends on a private symbol of another module. v0.6.405 removes it. It was never needed: wazero already keys its compilation cache by content (VERIFIED in wazero v1.12.0: `internal/engine/wazevo/engine_cache.go` fileCacheKey = sha256(Module.ID, "WAZEVO", CPU features), Module.ID = sha256 of the wasm bytes (`internal/wasm/module.go` AssignModuleID); entries carry the wazero version and a mismatch is stale). Cairn's marker is now housekeeping only (Go, go-pdfium, wazero builds). **Professional end state.** We ship a 5.8 MB native-code-producing blob that we did not build and cannot rebuild: 1. Build `pdfium.wasm` ourselves in CI from pinned sources (PDFium revision, Emscripten version, flags; recipe from Klippa, #1147), reproducibly (two builds, same sha256). 2. Commit or publish the artefact with its sha256 and an SBOM (CycloneDX/SPDX listing PDFium, FreeType, libjpeg-turbo, zlib, lcms2, OpenJPEG, ICU, musl, LLVM runtime) and provenance (SLSA level 2+ attestation from the runner). 3. Load it with `webassembly.InitWithWASM(Config{WASM: ourBytes})` so go-pdfium's default embed is not linked (saves ~5 MB), and verify the sha256 at start (refuse to render on mismatch). 4. Generate `pdfium.LICENSE.txt` from the same pinned sources (closes #1148's open points mechanically). 5. Renovate-style update job: a new PDFium revision is a PR with the new hash, SBOM diff and test renders. Until then: the go-pdfium module is pinned by go.sum (h1 hash of the module zip, which includes the wasm), which is integrity but not provenance.
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#1151
No description provided.