Skip to content

hook_decisions records raw command text regardless of exclude_commands, and [tracking] enabled is never read #4147

Open

Description

@Wilson421

What

The PreToolUse hook writes every Bash command it sees into hook_decisions.raw_cmd, verbatim. Neither documented knob stops it:

  • [hooks] exclude_commands gates rewriting, not recording. An excluded command still gets a row, with decision = 'defer'.
  • [tracking] enabled is parsed, defaults to true, is written into config.toml by rtk config --create, and — as far as I can find — is never read anywhere in the source. The only TrackingConfig field consulted is database_path (src/core/tracking.rs, get_db_path). Setting it to false changes nothing.

log_hook_decision → Tracker::new() → record_hook_decision inserts unconditionally; no config is consulted on that path.

Measured, two Windows machines, rtk 0.49.0

Machine A ([tracking] enabled = false, exclude_commands = ["sqlcmd","psql"], config confirmed read back by rtk config):

hook_decisions 111 -> 112 after one excluded command
row: decision=defer | raw_cmd = sqlcmd -Q "select 1 -- LABSPROBE1"

Machine B, independently, before seeing A's result: exclude_commands set for sqlcmd, bare and compound invocations both recorded in full, decision='defer'; then [tracking] enabled = false and a third command still recorded, 97 → 99 → 100. Across all of it the commands table stayed frozen at 17 rows while hook_decisions grew, which is the clue that pointed at the two tables being governed differently.

A note on method, because the obvious check is worthless here: rtk hook check '<cmd>' prints No rewrite for: <cmd> for an excluded command and for a command rtk has no filter for. It answers "will this be rewritten", never "will this be recorded". Both of us had to query the database with a marker string to get a real answer.

Why this one is worth more than a doc note

The other two things I filed this week (#4143, #4144) are the tool reporting a state it did not reach. This is a control surface that does not control the thing its name names, and it fails in the direction that looks safe: a privacy-minded user sets exclude_commands, sees No rewrite for: …, and reasonably concludes the command is not captured. It is captured, in full, in a local SQLite database that on Windows carries no owner-only hardening (set_owner_only is #[cfg(not(unix))] {}).

For most users this is uninteresting — command text, not output, and their editor's own transcripts hold more. For anyone whose command lines carry sensitive arguments, the difference between "I turned it off" and "there was no off switch" is the whole question.

Suggested resolution, your call

  1. Gate hook_decisions on exclude_commands — what the name implies. An excluded command produces no row, or a row with raw_cmd redacted to the bare program name (which is all discover needs for coverage stats).
  2. Make [tracking] enabled = false actually disable writes, or remove the field so it stops reading as an off switch.
  3. If neither, document it plainly: say that the only way to stop capture is to not install the hook, and drop enabled from the generated config so nobody sets it expecting an effect.

Happy to send a PR for (1) or (2) — say which shape you want and whether a redacted row or no row is preferable for discover's ground truth.

Activity

  1. rtk-wshm-sync-bot commented on Sep 20, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 93%

    Summary

    exclude_commands only gates rewriting (not hook_decisions recording) and tracking.enabled is never read, so raw command text (incl. sensitive args) is always captured with no way to opt out short of not installing the hook.

    📁 Relevant files
    • src/core/tracking.rs

    Suggested Actions

    1. Decide resolution shape: gate hook_decisions on exclude_commands, honor tracking.enabled, or document the gap
    2. Check src/core/tracking.rs get_db_path / record_hook_decision path where TrackingConfig fields are consulted
    3. Accept author's offer to send a PR once desired behavior (redact vs. drop row) is decided
    4. Address Windows SQLite file lacking owner-only permissions (set_owner_only is #[cfg(not(unix))] {})

    Triaged automatically by wshm · This is an automated analysis, not a human review.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions