Skip to content

git stash list strips the originating branch, wc labels every space-containing filename with its last word, and env's "relevant" filter prints credentials while discarding connection strings #3433

Open

Description

@HetCreep

Three filters that lose or misattribute the one fact their output exists to convey.

Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). All three run side by side against the real tools; outputs verbatim.

1. git stash list deletes the branch each stash came from

$ git stash list
stash@{0}: On main: main-side edit
stash@{1}: On hotfix: hotfix edit

$ rtk git stash list
stash@{0}: main-side edit
stash@{1}: hotfix edit

src/cmds/git/git.rs:1854-1873 strips everything up to the second ": ", which removes On <branch>: / WIP on <branch>:.

That prefix is the field that makes a stash list actionable. Someone — or an agent — choosing an entry to git stash pop now cannot tell which branch it was taken from, and popping a stash from another branch applies unrelated work onto HEAD. The failure is silent: either it merges cleanly and produces wrong code, or it conflicts for reasons the reader cannot explain from what rtk showed them.

Note the unit test at git.rs:2348-2351 asserts the stripped form, so a fix would need that test updated.

2. wc labels files by the last whitespace-separated token

$ wc -l "alpha report.txt" "beta report.txt" "gamma report.txt"
 1 alpha report.txt
 5 beta report.txt
 2 gamma report.txt
 8 total

$ rtk wc -l "alpha report.txt" "beta report.txt" "gamma report.txt"
1 report.txt
5 report.txt
2 report.txt
Σ 8

src/cmds/system/wc_cmd.rs:178-179,199 do line.split_whitespace() then take .last() as the filename. Three distinct files become three rows labelled report.txt carrying three different counts — so the output does not merely lose the names, it attributes counts to a file that does not exist.

Filenames with spaces are ordinary on Windows and macOS.

3. rtk env prints the AWS secret and drops the database URL

With AWS_SECRET_ACCESS_KEY, DATABASE_URL and MY_API_KEY all set:

$ rtk env
… AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI_FAKE_TEST_VALUE   ← printed in full
Total: 74 vars (showing 27 relevant)

DATABASE_URL: absent. MY_API_KEY: absent.

To be fair about what this is and is not: plain env prints all of them, so this is not a leak relative to the tool being wrapped. The problem is the selection. src/cmds/system/env_cmd.rs:140-152 routes AWS* into a category that is printed with no redaction, while is_interesting_var (:176-179) limits the general case to HOME/USER/LANG/LC_*/TZ/PWD/OLDPWD.

So a command that presents itself as filtered ("showing 27 relevant") keeps the credential and discards the connection string. Asking "is DATABASE_URL set?" through rtk returns no — which is wrong — while the AWS secret is surfaced to whatever reads the output, including an agent transcript.

Suggested directions (untested — no programmer has reviewed these)

  1. Keep the On <branch>: prefix — it is short and it is the point of the line. If compression is needed, the commit subject is the better thing to shorten.
  2. Reconstruct the filename by removing the leading count fields rather than taking the last token, or invoke wc in a mode with an unambiguous separator.
  3. Either redact values in the credential categories, or stop treating AWS* as automatically printable, and widen is_interesting_var so DATABASE_URL-shaped variables are not dropped. Printing secrets while hiding non-secrets is the worst of both.

Not verified

A related claim from the same review — that rtk env miscounts PATH entries because it splits an already-truncated 50-character preview on : — I could not confirm. My output had a different shape from the one described (PATH Variables: rather than PATH (N entries)), so I could not compare a count and am not asserting it. The value-truncation code at env_cmd.rs:36-41 is real; the miscount is not something I demonstrated.

Activity

  1. pszymkowiak commented on Aug 4, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 91%

    Summary

    Three independent output-correctness bugs: git stash list drops the source branch, wc mislabels multi-file space-containing filenames with the wrong name, and env's relevance filter prints AWS secrets unredacted while dropping DATABASE_URL — fix each filter (git.rs:1854-1873 incl. test at 2348-2351, wc_cmd.rs:178-199, env_cmd.rs:140-179).

    📁 Relevant files
    • src/cmds/git/git.rs
    • src/cmds/system/wc_cmd.rs
    • src/cmds/system/env_cmd.rs

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

  2. HetCreep commented on Sep 16, 2026

    @HetCreep
    Author

    Re-verified against develop @ 5e0f92c — verified by reading the code at this commit, not by building or running it. All three findings are still fully live; nothing here is fixed. Two of the three citations are unchanged, the stash one moved because of a file rename — corrected below.

    1. git stash list strips the originating branch — still live, citation moved.

    filter_stash_list now lives at src/cmds/git/git_cmd.rs:3327-3346 (originally cited at git.rs:1854-1873). The function itself hasn't changed at all: git log -p 0de9610..5e0f92c on this path shows zero commits touching filter_stash_list across the full 468-commit range. It still splits each line on the first ": ", and if a second ": " follows, keeps only the text after it — so stash@{0}: On main: main-side edit still becomes stash@{0}: main-side edit, with the branch name gone. The pinning test moved with the file, not away from the bug: test_filter_stash_list is now at git_cmd.rs:4811-4816 and still asserts the stripped form ("stash@{0}: abc1234 fix login", no branch).

    The move is a straight rename, git.rs → git_cmd.rs in 70ec493, a 0-line diff on the rename itself (the same rename was already confirmed under #3408, for that issue's git-related half). In between, roughly 60 unrelated commits reworked git diff/show/log/stash patch-mode-flag parsing — a different code path than list — adding about 1,470 lines ahead of this function, which is the entire reason the citation drifted from ~1860 to ~3330.

    Correction to the original report: please re-cite this as src/cmds/git/git_cmd.rs:3327-3346 (test at :4811-4816), not the old git.rs line numbers.

    2. wc mislabels space-containing filenames by their last token — still live, no drift.

    src/cmds/system/wc_cmd.rs has zero commits in 0de9610..5e0f92c, so the original citations are still exactly right: :178-179 (line.split_whitespace().collect(), then parts.last().copied()) and :199 (strip_prefix(parts.last().unwrap_or(&""), &common_prefix)). wc -l "alpha report.txt" "beta report.txt" still labels both rows report.txt, since only the last whitespace-split token of each line survives as the filename.

    3. rtk env prints the AWS secret while dropping DATABASE_URL/API-key vars — still live, no drift.

    src/cmds/system/env_cmd.rs had exactly one commit in range, d00c514 ('refactor: adopt let-chains'), and it's a pure if let → let-chain syntax rewrite on the unrelated filter-arg branch (lines 30-34) — the categorization logic is untouched. is_cloud_var (:140-156) still matches "AWS"; the categorization loop still routes cloud matches to output (:50-51) and prints them unredacted (:87-92), with truncation only kicking in past 100 characters (:36-41) — well beyond the length of a typical AWS secret. Meanwhile is_interesting_var (:176-178) is still exactly ["HOME", "USER", "LANG", "LC_", "TZ", "PWD", "OLDPWD"] matched via starts_with, so DATABASE_URL and MY_API_KEY match none of the four category functions (path/lang/cloud/tool) or is_interesting_var, and both are silently omitted from rtk env's output entirely — the same gap as originally reported.

    Please don't close this — nothing here is fixed. The only actionable change is the citation correction on finding 1.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions