Skip to content

fix(security): add integrity check for global TOML filters - #1068

Closed
pszymkowiak wants to merge 1 commit into
developfrom
fix/global-filter-integrity
Closed

pszymkowiak wants to merge 1 commit into
developfrom
fix/global-filter-integrity

Conversation

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Summary

  • Global filters (~/.config/rtk/filters.toml) were loaded without integrity verification
  • A supply-chain attack (e.g. npm postinstall) could silently modify global filters to suppress security output or rewrite commands
  • First load now records a SHA-256 baseline in the existing trust store
  • If the file changes unexpectedly, RTK warns and refuses to load until rtk trust --global
  • Adds rtk trust --global command to review and accept global filter changes

Ref: #640 (H-3 finding from security audit)

Changes

  • src/hooks/trust.rs: check_global_integrity(), GlobalFilterStatus enum, run_trust_global() + 5 tests
  • src/core/toml_filter.rs: integrity gate before loading global filters (SA-2025-RTK-002)
  • src/main.rs: --global flag on rtk trust

Test plan

  • 1363 tests pass, 6 ignored
  • 0 new clippy warnings from this PR
  • Manual: create ~/.config/rtk/filters.toml, run any rtk command (baseline recorded), modify file, run again (warning + filters blocked), run rtk trust --global (accepted)

Global filters (~/.config/rtk/filters.toml) were loaded without any
integrity verification, unlike project-local filters which require
SHA-256 trust. A supply-chain attack (e.g. npm postinstall script)
could write to ~/.config/rtk/ to suppress security scanner output
or rewrite command output via replace/match_output rules.

Now: first load silently records a SHA-256 baseline. If the file
changes unexpectedly, RTK warns and refuses to load until the user
runs `rtk trust --global` to review and accept.

Ref: issue #640 (H-3 finding)

Signed-off-by: Patrick Szymkowiak <[email protected]>
Signed-off-by: Patrick szymkowiak <[email protected]>
@pszymkowiak
pszymkowiak requested a review from aeppling April 7, 2026 08:41
thehoff added a commit to thehoff/contextcrawler that referenced this pull request May 15, 2026
Three factual fixes from Codex's pass on the v1 of these docs:

1. THREAT_MODEL.md path references — all `cmds/...`, `core/...`,
   `hooks/...` paths now use the `src/...` prefix so they actually
   resolve when followed from repo root. 10 paths updated.

2. THREAT_MODEL.md hook filename — the integrity check is on
   `rtk-rewrite.sh`, not `contextcrawler-rewrite.sh`. Internal `rtk-`
   prefix is retained per the rebrand-internals-later policy (commits
   a26ebba / bb473fd). Updated the table entry and noted the policy.

3. AUDIT-2026-05-15.md H-3 disposition — was claimed "Fixed upstream
   (PR rtk-ai#1068) — Inherited", but verification against
   src/core/toml_filter.rs:218-222 shows the global filter path
   `~/.config/rtk/filters.toml` is still loaded without a trust check.
   Project-local `.rtk/filters.toml` IS trust-gated; only the global
   wasn't. Real downstream gap. Corrected disposition; added matching
   entry to THREAT_MODEL.md accepted-limitations with explicit
   "do not carry into v0.2.0" note.

Also: cross-branch references to `scripts/build-release.sh` and
`docs/quality/...` now annotated with which branch they ship on, so
the docs are still useful when this branch is read in isolation
before the v0.1.6 merge train lands.
@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@rtk-release-bot

Copy link
Copy Markdown
Contributor

Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you!

@rtk-release-bot rtk-release-bot Bot closed this Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant