Repository navigation
Description
Part of EPIC #2758. Priority p1 (bug).
Goal
tracker_client never writes the key of a private HTTP tracker (the <key> in /announce/<key> and /scrape/<key>) to stdout or stderr. Where a tracker URL is needed to identify a target, the key segment is masked with a fixed string (****), as section 7 (redaction policy) of the global CLI output contract (docs/adrs/20260519000000_define_global_cli_output_contract.md) requires.
Background
A private Torrust HTTP tracker authenticates a peer with a key in the URL path. A caller of tracker_client passes that URL on the command line or in the check configuration, so the key is a credential the tool holds. Reproduced on develop (7bc30738a) with a closed local port:
http announceandhttp scrape: theruntime_failurerecord on stderr carries the full request URL, key and query included, inside theDebugtext of areqwest::Error.check: the result on stdout echoes the configured URL, key included, in itsurlfield; its per-request texts carryreqwest::ErrorDebugtext.
Known sources: packages/tracker-client/src/http/client/mod.rs formats reqwest::Error with {err:?} and reqwest::Response with {response:?} (both print the URL; the Display of reqwest::Error also appends for url (<url>), so switching to {err} is not enough); console/tracker-client writes those texts unchanged (report_runtime_failure, the checker results, response.bytes().await?).
stderr and stdout of tracker_client are captured by CI and by AI agents, so a key written there can end up in shared logs. This predates #2768, where it was found. It does not overlap EPIC #2993 / #2999 (server side and rest-api-client), which touch other files.
In scope
- Audit every output path of
tracker_client(http announce,http scrape,udp announce,udp scrape,check,check monitor) that can write a tracker URL or request-error text. - One small function masks the key segment of an HTTP tracker URL; every output path uses it. Host, port and path prefix stay visible.
- No
reqwest::ErrorDebugtext in any output: a failed request is reported with an error kind (connect, timeout, status, decode) and the masked URL. - Fix the library source in
packages/tracker-clienttoo. - Regression tests (masking function, library error seam, black-box
tracker_client http announceagainst a closed port), red before the fix and green after. - Update
console/tracker-client/docs/contracts/tracker-cli-io-contract.mdwith the redaction rule for tracker URLs.
Out of scope
- The panic of
checkfor audp://URL without a port. - A schema version for the results.
- The checker dropping the key from the request path, and reporting a refused connection as a timeout (separate issues if wanted).
- Other tools of the EPIC; UDP URLs carry no key.
Acceptance criteria
- No output of
tracker_client(stdout or stderr, any subcommand, success or failure) contains the key of a tracker URL; the key segment is written as****. - No output contains the
Debugtext of areqwest::Error. - The library error text of
packages/tracker-clientdoes not contain the key. - Regression tests fail on the unchanged code and pass after the fix.
The full specification (with the reproduction evidence) is added by the spec PR under docs/issues/open/3004-2758-tracker-client-mask-tracker-key/.
Activity
docs(issues): [torrust#2758] address da2ce7's review 6023338079 of PR…
docs(issues): [torrust#3004] fix the review round 1 findings in the spec
docs(issues): [torrust#3004] add test resource ownership and more lea…
docs(issues): [torrust#3004] place the body-read test in the console …
docs(issues): [torrust#3004] run check in the body-read test for the …
docs(issues): [#3004] add the spec for masking the tracker key in tra…
Merge #3005: docs(issues): [#3004] spec for masking the tracker key i…
fix(tracker-client): [torrust#3004] mask keys in any echoed URL and t…
test(tracker-client): [torrust#3004] cover upper-case and malformed U…
docs(issues): [torrust#3004] record the review round 1 fix and the re…
fix(tracker-client): [torrust#3004] mask keys after a backslash, a de…
fix(tracker-client): [torrust#3004] mask the key after an escaped bac…
docs(issues): [torrust#3004] record the review round 2 fix and the fi…
fix(tracker-client): [torrust#3004] spell HTTP in upper case in the c…
docs(issues): [torrust#3004] record the recheck after review round 3
5 remaining items
docs(issues): [#3004] record the output path audit and the R0 repeat
fix(tracker-client): [#3004] mask the tracker key in the HTTP client …
fix(tracker-client): [#3004] do not write the tracker key in tracker_…
docs(tracker-client): [#3004] document the masking of the tracker key
docs(issues): [#3004] record the regression tests, the recheck and th…
Merge #3014: docs(issues): [#2993] recheck the EPIC and sub-issue spe…
docs(issues): [torrust#3004] tick the archive checkpoint
chore(issues): archive closed issue #3004 spec to docs/issues/closed
Merge #3021: chore(issues): archive closed issue #3004 spec to docs/i…
Merge #3027: docs(issues): [#2758] start #2766 after #2387 SI-1 inste…
Merge torrust#3012: fix(tracker-client): [torrust#3004] do not write …
Merge #3042: fix(secrets): [#2999] keep secrets out of errors, logs a…
docs(issues): [#2766] refresh the daemon JSON logging spec and record…
Merge #3081: docs(issues): refresh the daemon JSON logging spec and r…