Skip to content

Prevent telemetry low_savings_commands from including arguments #1785

Closed

Description

@LionartBR

Summary

Telemetry documentation says full command lines, arguments, file paths, environment variables, source code, and secrets are not collected. In v0.39.0, most telemetry fields are aggregate or reduced, but low_savings_commands can still include command arguments because it sends the first three whitespace-separated words of the stored rtk_cmd.

This is a privacy hardening issue, not an accusation of malware.

Version / tag / commit

Evidence

Telemetry payload:

  • src/core/telemetry.rs:106-140 includes low_savings_commands in the JSON payload.
  • src/core/telemetry.rs:271-278 populates it from tracker.low_savings_commands(5) and formats each entry as "{cmd}:{pct}%".
  • src/core/tracking.rs:1053-1067 implements low_savings_commands; it selects full rtk_cmd, then returns cmd.split_whitespace().take(3).join(" ").

Stored command sources can include arguments:

  • src/main.rs:1199-1204 records TOML-filtered fallback as rtk:toml {raw_command}.
  • src/main.rs:1227 records passthrough as rtk fallback: {raw_command}.
  • src/main.rs:2341-2344 records proxy usage as rtk proxy {cmd_name} {cmd_args.join(" ")}.

Therefore a command such as a proxy or fallback invocation with a URL/path/token-like first argument can flow into the first three words of low_savings_commands, depending on savings stats and ranking.

Docs:

  • docs/TELEMETRY.md:65 documents low_savings_commands as a sent telemetry field.
  • docs/TELEMETRY.md:109-114 says RTK does not collect full command lines or arguments, file paths, secrets, API keys, or environment variable values.

Other telemetry fields look better reduced:

  • src/core/tracking.rs:976-986 extracts only the tool name for top_commands.
  • src/core/tracking.rs:1024-1038 groups passthrough telemetry by first word only.
  • src/core/tracking.rs:1141-1172 maps commands to ecosystem categories for ecosystem_mix.
  • src/core/tracking.rs:1188-1195 sends only a count of distinct project paths.

Impact

Users who opt in to telemetry may unintentionally send a command argument in low_savings_commands. Depending on the command, the first argument can be a URL, path, repository name, host, branch, package, or token-like string. This conflicts with the documented privacy claim and creates avoidable telemetry sensitivity.

Verification steps

No release binary execution is needed.

  1. Inspect src/core/telemetry.rs at v0.39.0 and confirm low_savings_commands is included in the payload.
  2. Inspect src/core/tracking.rs:1053-1067 and confirm the first three words of rtk_cmd are sent.
  3. Inspect src/main.rs:1199-1204, :1227, and :2341-2344 and confirm stored rtk_cmd values can include raw command arguments.
  4. Compare with docs/TELEMETRY.md:109-114.

Suggested mitigation

  • Make low_savings_commands use the same tool-name reduction as top_commands, or map to a fixed taxonomy.
  • If subcommand granularity is needed, maintain a per-tool allowlist of safe subcommands and drop all other arguments.
  • Add unit tests with URL/path/token-like arguments proving telemetry payload fields do not include them.
  • Update docs/TELEMETRY.md if the intended policy is to send sanitized subcommand names rather than only tool names.

Activity

  1. added
    bug
    help wanted
    on May 27, 2026
  2. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 91%

    Summary

    Privacy bug: low_savings_commands telemetry leaks command arguments (URLs, paths, tokens) despite documentation guaranteeing they are not collected; fix by applying the same tool-name-only reduction used by top_commands.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/core/tracking.rs
    • src/core/telemetry.rs
    • src/main.rs
    • docs/TELEMETRY.md

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

  3. kobihikri commented on Jul 27, 2026

    @kobihikri

    @LionartBR's analysis here is correct, and I wanted to add one piece of evidence that I think raises the priority: the argument that leaks can be a credential, and I was able to trigger it rather than just reason about it.

    Their report notes it deliberately needs no binary execution, and describes the exposed value as potentially "a URL, path, repository name, host, branch, package, or token-like string". Running the path confirms the stronger case. With a stored command whose average savings falls inside this field's 0 < avg < 30 window, the password survives the take(3) reduction into the value send_ping places in the JSON body:

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

    Those credentials are synthetic and it was run in a container — nothing real was transmitted. The shape is what matters: rtk psql <DSN> -c ... reduces to rtk psql <DSN>, because the third whitespace word is the connection string.

    On my own machine this is not hypothetical either. My history DB has 63,542 rows, and 129 distinct stored commands carry a path or URL in that third word — including postgres://… DSNs with inline credentials from local development. On this particular machine none of those happened to sit inside the 0 < avg < 30 bucket (they scored either 0.0 or ≥35.99), so nothing of mine was ever eligible to be sent. But that window is an ordinary numeric threshold, not a safety mechanism, and a slightly different compression ratio puts a DSN in range.

    So I'd suggest this is worth treating as credential exposure rather than only argument exposure — it also touches DISCLAIMER.md, which promises that no "secrets" are collected.

    I've opened #3233 implementing the mitigation @LionartBR suggested. It keeps rtk's leading marker, then only bare subcommand words, and takes a third word only when the second names a tool that genuinely has subcommands — so rtk git log and rtk docker ps still report usefully while rtk psql postgres://… reduces to rtk psql. Full credit for the finding is @LionartBR's; I only wrote the patch, and I'm happy for it to be closed or reworked if you'd prefer a different shape (their tool-name-only option is simpler and I'd support that too).

    Disclosure: I used AI assistance to investigate and draft this. I verified the behaviour and reproduced it myself before posting.

  4. KuSh commented on Sep 26, 2026

    @KuSh
    Collaborator

    This looks resolved by #4123, shipped in v0.50.0: the low_savings_commands entries in the telemetry payload are now built from the tool name plus, only for tools that route by subcommand, a subcommand-shaped word, so URLs, paths, connection strings and search terms no longer reach the payload. This was checked in the code and its tests rather than against a live telemetry endpoint, so marking it resolved-pending-close. If you find a stored command shape that still leaks an argument on v0.50.0 or later, please comment here.

  5. added
    resolved-pending-close
    on Sep 26, 2026
  6. KuSh commented on Oct 3, 2026

    @KuSh
    Collaborator

    This has carried the resolved-pending-close label with no new report of it happening, so closing it. Fixed by #4123, shipped in v0.50.0: low_savings_commands labels are now built from the tool name, plus a subcommand-shaped word only for tools that route by subcommand, so URLs, paths and connection strings no longer reach the telemetry payload. If you find a stored command that still leaks an argument on the latest release, please comment and it can be reopened.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:docsarea:securitybughelp wantedpriority:highresolved-pending-close

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions