8000 fix(security): prove and scope the cgm_cbio vendor-material guard by shroominic · Pull Request #173 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

fix(security): prove and scope the cgm_cbio vendor-material guard - #173

Closed
shroominic wants to merge 1 commit into
mainfrom
fix/vendor-material-guard
Closed

shroominic wants to merge 1 commit into
mainfrom
fix/vendor-material-guard

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Fixes #172. Base is main.

What was wrong

The rule that is supposed to keep the CBIO GS1 vendor material out of the tree
was never exercised, and it was headed for the wrong scan.

  • The generic ruleset does not match the material when it is committed as a Dart
    byte-list constant. gitleaks 8.24.3 reports no leaks found for a tree that
    contains the material and a generic-api-key finding for a synthetic fixture
    of the same shape. The detector catches the fixture by accident and misses the
    credential.
  • Nothing tested the rule. A rule that stops matching (name drift, regex edit,
    scanner change) still reports green.
  • The rule cannot live in the history sweep: the material and a key-derived
    masked vector are already in this repository's public history, so a
    history-wide rule would fail forever and no fix on the tip could clear it.
  • The lane's [[allowlists]] block is silently ignored by the pinned scanner
    8.24.3, so it neither suppressed nor documented anything while reading like a
    packages/cgm_cbio exemption.

What this changes

File Change
security/gitleaks-vendor-material.toml One tree-scoped rule: a material-shaped binding plus a literal payload. No allowlist.
scripts/check-cbio-vendor-material.sh Scans the tree, then asserts the same rule reports a deliberate synthetic canary.
scripts/install-quality-tools.sh Installs gitleaks 8.24.3 with a per-platform SHA-256, like ShellCheck and actionlint.
.github/workflows/security.yml New blocking Vendor Material Guard job.
Makefile make vendor-material-guard, wired into make check.

The rule, the script, and this body restate no byte, no key-derived vector, and
no device address. The canary is assembled at run time from a synthetic payload
so the script itself carries nothing material-shaped; that is not cosmetic — the
first version of this script was rejected by its own rule, which is recorded
because it is the clearest proof the rule works.

Verification

Command Result
make tooling-bootstrap Installed checksum-pinned ShellCheck 0.11.0, actionlint 1.7.12, and gitleaks 8.24.3.
make vendor-material-guard vendor-material guard: cbio-vendor-material-constant rejected the canary and the tree is clean.
gitleaks 8.24.3, this config, tree at feature/cbio-gs1-glucose-live exit 2, 31 findings, including packages/cgm_cbio/lib/src/cbio_crypto.dart and compiled app.dill / kernel_blob.bin outputs.
gitleaks 8.24.3, this config, the fix/cbio-credential-redaction tree exit 0, 0 findings.
gitleaks 8.24.3, default config, the same lane tree no leaks found for the material constants. Reproduces the gap this rule closes.

Decisions taken

  • Tree scope, not history scope. The tip is the only place a fix can clear
    the finding, so the blocking rule runs with --no-git --source <tree>.
  • No allowlist. An entry would have to name the value it exempts. A
    legitimate synthetic fixture belongs under a non-material binding name; the
    self-test proves the rule rather than relaxing it.
  • Checksum-pinned install through the existing installer instead of a
    workflow-local download, so local and CI runs cannot diverge.
  • make check runs it. The guard is part of the repository command
    contract, not an extra job nobody runs locally.

Decision request

The material is already in this repository's public history, and one key-derived
masked vector is reachable from origin/feature/cbio-gs1-glucose-live and the
0.4.0 aggregates. No scanner setting can un-publish it. Purging it (a rewrite
of the unmerged sensor branches, plus their open pull requests) and rotating it
are both calls only the owner can make; rotating vendor-derived interoperability
material may not even be possible without the vendor. Until that decision lands,
this guard keeps new commits clean and the historical exposure stays recorded in
#164, #167, and the scan policy landing in #150.

The guard that keeps the vendor material out of the tree had never been
exercised, and as written it belonged in the wrong place.

- `security/gitleaks-vendor-material.toml` holds one tree-scoped rule that
  matches a material-shaped binding plus a literal payload. It restates no
  byte, no key-derived vector, and no device address, and it carries no
  allowlist, because an exemption would have to name the value it exempts.
- `scripts/check-cbio-vendor-material.sh` makes the rule prove itself: it scans
  the checked-out tree, then asserts the same rule still reports a deliberate
  synthetic canary. A rule that silently stops matching now fails instead of
  reporting a clean tree.
- The scanner is installed through the repository's existing checksum-pinned
  quality-tool installer, so local runs and CI use gitleaks 8.24.3, the version
  `gitleaks-action` resolves to.
- `make vendor-material-guard` runs it locally and is part of `make check`; the
  `Vendor Material Guard` job in `security.yml` runs it on every pull request.

The rule is deliberately not added to `.gitleaks.toml`: the material and a
key-derived masked vector are already in this repository's public history, so a
history-wide rule would fail forever and no change on the tip could clear it.

Fixes #172.
@shroominic
Copy link
Copy Markdown
Owner Author

Carried by the GS1 consolidation in PR #209 (branch feature/cbio-gs1, head 3eca4f4).

This PR is contained in the consolidated line; the merge that carries it is 0490128.

Closing as subsumed by the consolidation - not as won't fix. The per-defect evidence stays in this thread, and the carrying commit above is where the change now lives.

@shroominic shroominic closed this Sep 18, 2026
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.

security: the CBIO GS1 vendor-material rule is unverified and cannot live in the history sweep

1 participant

0