Skip to content

fix(tracking): drop argument data from telemetry low_savings_commands - #3233

Closed
kobihikri wants to merge 1 commit into
rtk-ai:developfrom
kobihikri:fix/tracking-telemetry-low-savings-arguments
Closed

kobihikri wants to merge 1 commit into
rtk-ai:developfrom
kobihikri:fix/tracking-telemetry-low-savings-arguments

Conversation

@kobihikri

Copy link
Copy Markdown

Summary

  • low_savings_commands sent the first three whitespace words of the stored rtk_cmd. Because the proxy and fallback record sites store the raw command line, the third word can be a path, URL, or database connection string instead of a subcommand — so argument data could reach the telemetry payload.
  • This is the issue @LionartBR reported in Prevent telemetry low_savings_commands from including arguments #1785. All credit for finding and diagnosing it is theirs; their write-up already identified the exact call path and proposed this mitigation. This PR just implements it.
  • The label is now reduced rather than truncated: rtk's own leading marker is kept, then only bare subcommand words, and a third word only when the second names a tool that actually has subcommands. rtk git log and rtk docker ps are preserved; rtk psql postgres://user:pass@host/db -c ... becomes rtk psql.

Why it matters: docs/TELEMETRY.md:112-113 says full command lines, arguments, and file paths are never collected, and the contributor checklist at docs/TELEMETRY.md:189 requires new telemetry fields to carry "only aggregate counts or anonymized names — no raw paths, arguments, or user data". This field was the one that did not meet that bar; the sibling fields (top_commands via .nth(1), top_passthrough via SQL SUBSTR) already reduce correctly.

I confirmed the leak is reachable rather than theoretical. With a stored command whose savings land in the field's 0 < avg < 30 window, the credential survived into the value that send_ping puts in the JSON body:

TELEMETRY low_savings_commands PAYLOAD = [("rtk psql postgres://demo_user:[email protected]:5432/appdb", 15.0)]

(synthetic credentials, run in a container). On my own machine's history DB, 129 distinct stored commands have a path or URL in that third word.

Kept deliberately small and in-scope: one file, one behaviour change, no drive-by edits. If you would rather go further — e.g. @LionartBR's alternative of reducing to the tool name only, or a broader per-tool allowlist — I'm happy to change it to whatever you prefer, or to close this if you'd sooner fix it yourselves.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test --all
  • Five tests added in src/core/tracking.rs covering: the DSN regression from Prevent telemetry low_savings_commands from including arguments #1785, paths/flags/patterns, preserved real subcommands (git log, docker ps, cargo build), the rtk:toml / rtk proxy markers and empty input, plus a property test asserting no label ever contains /, @, =, or .
  • Full suite green: 2505 passed, 0 failed (run in a rust:1.91-slim container with git installed — without git present, 5 unrelated pre-existing git tests fail for environmental reasons)

Disclosure: I used AI assistance to help investigate this and draft the change. I verified every line myself, reproduced the behaviour, and ran the full test suite before opening this.

low_savings_commands sent the first three whitespace words of the stored
rtk_cmd. Stored values embed raw command lines (the proxy and fallback record
sites keep the full invocation), so the third word can be a path, URL or
database connection string rather than a subcommand.

docs/TELEMETRY.md states that full command lines, arguments, file paths and
secrets are never collected, and the contributor checklist requires telemetry
fields to carry "only aggregate counts or anonymized names". This field did not
meet that bar.

Reduce the label instead of truncating it: keep rtk's own leading marker, then
only bare subcommand words, and take a third word only when the second names a
tool that actually has subcommands. "rtk git log" and "rtk docker ps" are
preserved; "rtk psql postgres://user:pass@host/db -c ..." becomes "rtk psql".

Reported by @LionartBR in rtk-ai#1785.

Closes rtk-ai#1785
@CLAassistant

CLAassistant commented Jul 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kobihikri

Copy link
Copy Markdown
Author

Closing this — I should not have opened it.

@YOMXXX already has #2578 open since 2026-06-24, fixing the same thing in the same file, and it is mergeable and just waiting on review. Theirs came first and is the smaller change (+61/-4 against my +123/-2). Mine adds nothing that justifies a competing PR, and a second one only makes the queue harder to read.

My mistake was in how I checked for prior work: I searched issues, found @LionartBR's #1785 and credited it, then went straight to writing a patch without searching open pull requests. #2578 was linked right under the issue title the whole time. Entirely avoidable, and I'm sorry for the noise.

Maintainers: #2578 is the one to review. @LionartBR reported the issue, @YOMXXX wrote the fix.

The one thing I'd still offer is the reproduction I left on #1785: with a stored command whose savings land in the field's 0 < avg < 30 window, a connection-string password survives the take(3) reduction into the POSTed payload. That applies to whichever fix you land, and it may be worth a regression test in #2578 — but that is @YOMXXX's call, not mine.

Disclosure: I used AI assistance on the original PR and on this comment.

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.

2 participants