security: trust boundary for project-local TOML filters (SA-2025-RTK-002)#623
Merged
pszymkowiak merged 3 commits intodevelopfrom Mar 16, 2026
Merged
Conversation
…002) .rtk/filters.toml was loaded silently from CWD with highest priority, allowing an attacker to commit malicious filters to a public repo that hide security vulnerabilities or rewrite command output via replace and match_output primitives. CVSS 7.0. Implementation: - New src/trust.rs: SHA-256 trust store in ~/.local/share/rtk/ - Trust gate in toml_filter::load(): untrusted filters are SKIPPED - rtk trust: review + trust project-local filters (stores hash) - rtk untrust: revoke trust - rtk trust --list: show all trusted projects - Content change detection: modified filters auto-rejected - RTK_TRUST_PROJECT_FILTERS=1 env var override for CI pipelines - 9 unit tests covering all trust states Security model: untrusted = skip (not "warn and load"). Zero attack surface when untrusted. Re-review required on any content change. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Address 3 critical and 4 important findings from security review: Critical fixes: - rtk verify: add trust gate before reading project-local filters (was executing untrusted filter regex via collect_test_outcomes) - TOCTOU: read .rtk/filters.toml once in rtk trust, hash in-memory buffer (prevents file swap between display and hash storage) - canonical_key: remove fallback path join, fail-closed if canonicalize fails (prevents symlink injection) Important fixes: - RTK_TRUST_PROJECT_FILTERS=1 now requires CI env var co-check (CI, GITHUB_ACTIONS, GITLAB_CI, JENKINS_URL, BUILDKITE) to prevent .envrc injection attacks - Corrupt trust store now logs warning instead of silent fallback - trusted_at date display uses safe .get(..10) instead of panicking slice Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Previously rtk untrust failed with a canonicalize error if the filter file had been deleted. Now falls back gracefully with "No trust entry found" message. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
pszymkowiak
added a commit
that referenced
this pull request
Mar 16, 2026
- Fix `[filter.` → `[filters.` in risk summary (matches actual TOML DSL format) - Add trust, untrust, session, rewrite to RTK_META_COMMANDS array - Update test to skip trailing_var_arg commands (rewrite, session) Follows up on PR #623 (SA-2025-RTK-002 trust boundary). Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
3 tasks
pszymkowiak
added a commit
that referenced
this pull request
Mar 16, 2026
…625) - Fix `[filter.` → `[filters.` in risk summary (matches actual TOML DSL format) - Add trust, untrust, session, rewrite to RTK_META_COMMANDS array - Update test to skip trailing_var_arg commands (rewrite, session) Follows up on PR #623 (SA-2025-RTK-002 trust boundary). Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.rtk/filters.tomlloaded silently from CWD, allowing attackers to hide malicious code or rewrite outputrtk trustreviews content + stores SHA-256 hash; content changes auto-invalidate trustrtk untrustrevokes;rtk trust --listshows all trusted projectsRTK_TRUST_PROJECT_FILTERS=1env override for CI pipelinesAttack scenario blocked
Architecture
Files
src/trust.rssrc/toml_filter.rsload()src/main.rsmod trust+Trust/UntrustcommandsTest plan
rtk trust— shows content, risk summary, stores hashrtk untrust— revokes, filters skipped againrtk trust --list— shows all trusted projects.rtk/filters.toml→ warning on stderr, raw outputRTK_TRUST_PROJECT_FILTERS=1→ bypass (CI mode).rtk/filters.toml→rtk trusterrors cleanly