From 410849c21199a7133fa7bb1f8b9908d6195c0851 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 13:25:29 +0000 Subject: [PATCH 01/11] docs(issues): [#2993] spec for keeping secrets out of errors, logs and client replies Adds the EPIC specification: an inventory of the secrets held by errors and written to logs, of what each protocol sends a client, and of the skills, ADRs and documents about handling secrets, plus the maintainer's decisions and two sub-issues (secrets, and the client error text policy). Co-Authored-By: Claude Fable 5.2 --- .../EPIC.md | 306 ++++++++++++++++++ 1 file changed, 306 insertions(+) create mode 100644 docs/issues/open/2993-secrets-and-client-error-text/EPIC.md diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md new file mode 100644 index 000000000..63915d77c --- /dev/null +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -0,0 +1,306 @@ +--- +schema-version: 1 +doc-type: epic +status: planned +epic: null +github-issue: 2993 +spec-path: docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +epic-owner: null +last-updated-utc: "2026-11-22 13:24" +semantic-links: + skill-links: + - create-issue + - handle-secrets + - handle-errors-in-code + related-artifacts: + - .claude/skills/create-issue/SKILL.md + - .claude/skills/handle-secrets/SKILL.md + - .claude/skills/handle-errors-in-code/SKILL.md + - docs/adrs/20260822094338_adopt_secrecy_for_sensitive_values.md + - docs/adrs/20261118045443_errors_do_not_record_source_locations.md + - docs/issues/open/2912-remove-source-locations-from-errors/EPIC.md + - docs/issues/open/2916-2912-si-4-tracker-core/ISSUE.md + - docs/issues/open/384-strip-location-from-errors-sent-to-clients/ISSUE.md +--- + + + +# EPIC #2993 - Keep secrets out of errors, logs and client replies, and make client error text safe + +Related to EPIC #2912 (Remove source locations from errors), but not a sub-issue of it. See "Relation to EPIC #2912". + +## Goal + +1. No secret (a peer authentication key, a REST API admin token, a database credential) is held by an error value, printed by an error message, or written to a log line or other output. +2. Text sent to a client of the HTTP tracker, the UDP tracker or the REST API is friendly and relevant, and gives an attacker nothing about the implementation (database driver text, nested internal error names, server timing values). + +## Why This Is Needed + +The review of the SI-4 pull request of EPIC #2912 (#2916) found that `authentication::key::Error::UnableToReadKey` keeps the peer key and prints it, against rule 3 of the errors ADR. The maintainer decided on 2026-11-22 that this is three separate problems: + +1. Removing source locations from errors. This is EPIC #2912 and stays its only scope. +2. Not leaking secrets in logs, output and error text. This EPIC, sub-issue SI-A. +3. Client-facing errors that are friendly and relevant without exposing information an attacker can use. This EPIC, sub-issue SI-B. + +The two problems differ in kind. SI-A is a bug class with concrete, listed cases. SI-B is a design question (what a client may be told) that needs an ADR before code. + +## Inventory (verified against the tree at `develop` commit `bcca9764c`, 2026-11-22) + +Paths are relative to the repository root. Every item was read in the code, and the leaks were reproduced on a running tracker (see "Verified by running experiments"). The one thing not checked is how a source location prints in a release build; the debug build prints the workspace-relative path (`packages/tracker-core/src/authentication/service.rs:98:27`), and that is EPIC #2912's concern. + +### A. Secrets held by errors or written to output + +| ID | Location | What leaks | Seen by | +| --- | --- | --- | --- | +| A1 | `packages/tracker-core/src/authentication/key/mod.rs:180` (`UnableToReadKey { key: Box }`, built in `authentication/service.rs:97`) | the full 32-character peer key, kept and printed (`Failed to read key: {key}`) | the HTTP client that sent the key | +| A2 | `packages/tracker-core/src/error.rs:128` (`PeerKeyError::InvalidKey { key: String }`, built in `authentication/handler.rs:106`, `:123`) and `packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs:31` (`InvalidKey { key, reason }`, Display `invalid key: "{key}"`) | the key an administrator uploaded, echoed back | the REST API administrator; REST handlers `auth_key/handlers.rs:38-46` and `invalid_auth_key_response` (`responses.rs:53-55`) | +| A3 | `packages/axum-http-server/src/v1/routes.rs:82-104` (`TraceLayer`, `DefaultMakeSpan` at INFO plus `on_request` with `%uri`) | the peer key in `/announce/` and `/scrape/`, plus the whole query string, in the request event and in the span of every event inside it | server log reader | +| A4 | `packages/axum-rest-api-server/src/routes.rs:76-98` (same pattern; the auth middleware is inside the trace layer, so wrong tokens are logged too) | the admin token in `?token=` and the key in `/api/v1/key/` | server log reader | +| A5 | `packages/tracker-core/src/authentication/key/mod.rs:113`, `:120` (`tracing::debug!("Generated key: {}...")`) | a newly generated peer key, in clear, at DEBUG | server log reader | +| A6 | `packages/rest-api-client/src/v1/client.rs:30` (`TransportError(reqwest::Error)`) and `:369-370` (token added to the query string); `without_url` is never called | reqwest prints the URL, so a transport error on a GET contains `?token=` | users of the client library and console tools | +| A7 | `packages/tracker-core/src/authentication/key/peer_key.rs:127-128`, `:46-47`, `:71-75` (`Key` and `PeerKey` derive `Debug`, `Display`, `Serialize`) | the peer key prints in clear wherever the value is formatted | any log or error that formats a `Key` | +| A8 | `packages/axum-rest-api-server/src/v1/middlewares/auth.rs:62-65` (`QueryParams { token: Option }` derives `Debug`); `packages/rest-api-client/src/connection_info.rs:7-9` (`api_token: Option`) | plain `String` tokens; no log of them was found | none today; a latent risk | +| A9 | `docs/containers.md` (lines about 492-562) | the documentation teaches `?token=` URLs and a `mysql://user:password@host` URL in config and environment | readers; the request log then records the token. The MySQL example (`path = "mysql://db_user:...@mysql:3306/torrust_tracker"`) is also stale: the v3 schema refuses `path` for a network database (`packages/configuration/src/v3_0_0/database.rs:203-204`) | + +Checked and found safe, so that the spec does not redo it: + +- Config tokens (`AccessTokens`) and the v3 database password are `SecretString`; `Debug` and the startup configuration log (`src/bootstrap/app.rs:66`, `to_redacted_json`) redact them. `Serialize` redacts them too (`serialize_with`). +- No `databases::error::Error` variant has a URL, DSN or password field; the connection URL goes only to `from_str`. +- No event payload, metric label or health-check output carries a key, token or credential. +- The `Authorization: Bearer` header is not logged (`include_headers` is off). +- The health-check API server has no `TraceLayer`. +- No `#[instrument]` takes a key, token or database URL without skipping it. + +Verified by running experiments (2026-11-22, a debug build of the tracker; MySQL 8.0 and PostgreSQL 16 in local containers): + +- A1 to A9 above were reproduced on a running tracker: the announce failure reason `Tracker authentication error: Failed to read key: , ` carried the sent key, and the request log held `uri=/announce/?...` and `uri=/api/v1/stats?token=`. With `Authorization: Bearer`, the admin token did not appear in the log, so the header form is the safe way to call the API today. +- More reproductions on the same build. A2: `POST /api/v1/keys` with a 14-character key returned 400 `Invalid URL: invalid auth key: string "", Invalid key length. Key must be have 32 chars, `. A5: with `trace_filter = "debug"`, `POST /api/v1/key/3600` wrote `Generated key: , valid for: ...` to the log. A4: `DELETE /api/v1/key/` wrote `uri=/api/v1/key/`. A duplicate key returned 500 `Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, " }`. The ERROR log lines for a 500 reply hold the status and the request id but not the body, so the server log does not tell an operator why the request failed. +- A6 by reading: `reqwest` appends `for url ()` to its `Display` (`reqwest-0.13.5/src/error.rs:300-302`), and the REST client has no header form: it always adds the token to the query string (`packages/rest-api-client/src/v1/client.rs:369-370`). Its users in the workspace are the REST server tests and the qBittorrent end-to-end tool (`src/console/ci/qbittorrent_e2e/tracker/client.rs`). +- UDP replies, on a public tracker with `listed = true`: a non-whitelisted announce returned `tracker announce error: Tracker core whitelist error: The torrent: , is not whitelisted, `; an announce with a wrong connection id returned `tracker announce error: Connection cookie error: cookie value is expired: , expected > 1795353220.6572893`, which gives the client the server clock and the decoded value of the cookie it sent; a 3-byte packet returned `error parsing request: SendableRequestParseError { message: "Couldn't parse action", opt_connection_id: None, opt_transaction_id: None }`, a Rust type name in client text. +- UDP trackers are not started in private mode (`Could not start UDP trackers while in private mode. UDP is not safe for private trackers!`), so the peer key never travels over UDP. +- A10, configuration errors echo secret values. `figment` prints the offending value (`Actual::Str` and the integer forms, `figment-0.10.19/src/error.rs:323-345`). Reproduced: `password = 987654321` makes the tracker print `invalid type: found signed int 987654321, expected a string for key "default.core.database.password"`, and `admin = 424242` under `[http_api.access_tokens]` prints the number the same way. A numeric password or token, which TOML reads as an integer, is therefore printed on stderr and in the log. Seen by the operator. Related: `Error::ConfigError` is built by `LocatedError`, so the line also holds a source location (SI-5 of EPIC #2912). +- A11, database server messages name the user and the client address. Reproduced with MySQL: `1045 (28000): Access denied for user 'db_user'@'172.17.0.1' (using password: YES)`; with PostgreSQL: `password authentication failed for user "db_user"`. sqlx passes the server message through unchanged (`sqlx-mysql-0.8.6/src/error.rs:44-49`). Today this reaches the operator (stderr and log). It reaches a client only when a runtime database failure is mapped into a client reply (section B), which is why SI-B must not forward driver text. The MySQL case is also labelled `The MySQL query was malformed` because `From<(SqlxError, Driver)>` maps every `Database` error to `InvalidQuery`, so the label is wrong as well. +- The v2 configuration is not reachable at runtime. The tracker loads `v3_0_0::Configuration` only (`src/bootstrap/config.rs:8`); a file with `schema_version = "2.0.0"` is refused with `UnsupportedVersion` (`v3_0_0/mod.rs:413`). Only the v2 `Logging` types are still imported (`packages/configuration/src/logging.rs:18`). So the v2 `Database.path` masking issue is dead code, and is out of scope for SI-A. +- `url::ParseError` is safe: its `Display` is a fixed string per variant and never includes the input (`url-2.5.9/src/parser.rs:63-70`), so a malformed database URL does not echo the password. +- `src/console/ci/e2e/runner.rs:80` logs the raw tracker configuration TOML. It is a CI tool, not the tracker binary; record it and decide. + +### B. What each protocol sends a client + +HTTP tracker (a bencoded `failure reason`, always HTTP 200; wrapper `packages/http-protocol/src/v1/responses/error.rs:21-25`): + +| Error family | Client text (shape) | Source | +| --- | --- | --- | +| authentication | `Tracker authentication error: Failed to read key: [, ]`, `Missing authentication key`, `Key has expired` | `packages/http-core/src/services/error_mapping.rs:4-21`, `packages/tracker-core/src/authentication/key/mod.rs:180-191` | +| whitelist | `Tracker whitelist error: The torrent: , is not whitelisted` | `packages/tracker-core/src/error.rs:104` | +| database (announce and scrape) | `Tracker announce error: Database error: ` | `packages/tracker-core/src/error.rs:79`, `:92`; `databases/error.rs` | +| query parse | `Bad request. Cannot parse query params: invalid param ` and per-parameter texts that echo the client's own values | `packages/http-protocol/src/v1/requests/announce.rs:216-245`, `:346-354`, `query.rs:102` | +| client IP | `Error resolving peer IP: missing or invalid right-most IP in the X-Forwarded-For header, which is mandatory when the tracker runs behind a reverse proxy` | `peer_ip_resolver.rs:112-121` | + +UDP tracker (the error packet message is `error.to_string()` of `udp_server::error::Error`, `handlers/error.rs:57-60`): + +| Error family | Client text (shape) | Source | +| --- | --- | --- | +| request parse | `error parsing request: {request_parse_error:?}` (Debug of a struct) | `packages/udp-server/src/error.rs:24` | +| connection cookie | `... Connection cookie error: cookie value is expired: , expected > ` (server timing values) | `packages/udp-core/src/connection_cookie.rs:112-118` | +| whitelist | `tracker announce error: Tracker core whitelist error: The torrent: , is not whitelisted` | `packages/udp-core/src/services/announce.rs:190-204` | +| database | `tracker announce error: Tracker core announce error: Database error: Failed to connect to database: error communicating with database: ` | `databases/error.rs:111-135` | +| internal | `internal server error: {message}` | `packages/udp-server/src/error.rs:36` | + +REST API (`packages/axum-rest-api-server/src/v1/responses.rs`): + +| Error family | Client text (shape) | Status | +| --- | --- | --- | +| any key, whitelist or reload failure | `Unhandled rejection: Err { reason: "failed to add key: " }` (Debug formatting of `ActionStatus`) | 500 | +| missing or wrong admin token | `Unhandled rejection: Err { reason: "unauthorized" }`, `"token not valid"`, `"unknown token provided"` | 500 | +| bad info-hash or key parameter | `Invalid URL: invalid infohash param: string "", expected a 40 character long string`; `Invalid URL: invalid auth key: string "", ` (echoes the supplied key) | 400 | +| feature disabled | `{"status":"err","reason":"private capability is disabled by configuration"}` | 409 | + +Database error text. `databases::error::Error` (`packages/tracker-core/src/databases/error.rs`) wraps the `sqlx` error and its `Display` (for example `error returned from database: (code: 2067) UNIQUE constraint failed: keys.key`). `rest-api-runtime-adapter` forwards `e.to_string()` into `AuthKeyError::Database(String)` and `WhitelistError::Database(String)`, which the REST response prints verbatim (`adapters/auth_key.rs:49-84`, `adapters/whitelist.rs:32-46`). Server-side error logs also carry the driver text (`statistics/event/handler.rs:108`, `:129`; `packages/udp-server/src/handlers/error.rs:103-121`), which is appropriate there. + +REST rejections raised by axum itself (verified on a running tracker): an unknown path such as `/api/v1/key/abc/extra` returns 404 with an empty body; a malformed JSON body returns 400 with `Failed to parse the request body as JSON: key must be a string at line 1 column 2`, which is serde's text and so a source error from a crate the workspace does not control (ADR rule 4). + +Event payloads. `packages/udp-server/src/event.rs:114-153` `ErrorKind` holds `.to_string()` of internal errors (including `Database(String)`); no other event type carries an error string. + +### C. Documentation on handling secrets (inventory) + +| Kind | Artifact | What it covers | Gap | +| --- | --- | --- | --- | +| Skill | `.claude/skills/handle-secrets/SKILL.md` (listed in `.claude/skills/README.md:118`) | `SecretString`, `expose_secret` only at the last boundary, never in logs, `Display` or errors, constant-time compare, redaction tests | configuration secrets only; the peer key and secrets carried in URLs are not named | +| Skill | `.claude/skills/handle-errors-in-code/SKILL.md` | a secret is never echoed or kept in an error; client text is the error's own message | no rule for what client text may say about infrastructure failures | +| ADR | `docs/adrs/20260822094338_adopt_secrecy_for_sensitive_values.md` | use `secrecy` directly; redacted diagnostics; keep manual masking for legacy URLs until migrated | the peer key and request logging are not covered | +| ADR | `docs/adrs/20261118045443_errors_do_not_record_source_locations.md` | rule 3 (a secret is never the offending input) and rule 4 (client text is the workspace error's `Display`) | does not say how much a `Display` may reveal | +| ADR | `docs/adrs/20261007085634_inject_the_udp_connection_cookie_cipher.md` | the cipher key prints as `CookieCipher([REDACTED])` | none | +| ADR | `docs/adrs/20260519000000_define_global_cli_output_contract.md`, section 7 | JSON output must not expose secrets; `mask_secrets()` | CLI output only | +| Security doc | `docs/security/analysis/reports/2026-09-04_rest-api-token-timing.md` | constant-time token comparison; recheck when a new secret-comparison site appears | none | +| Security docs | `SECURITY.md`, `docs/security/README.md`, `vulnerability-remediation.md`, `public-scanner-findings.md` | reporting and triage process | not code guidance | +| User doc | `docs/containers.md` | configuration through environment variables | teaches `?token=` URLs and a clear database URL | +| History | `docs/issues/closed/2079-adopt-secrecy-for-sensitive-configuration/`, `docs/issues/closed/1490-1978-decompose-database-configuration/` | how config secrets were migrated | none | +| Incidental | skills `implement-workflow`, `merge-pull-request`, `triage-github-security-findings`, `check-runner-health`; `.github/agents/committer.agent.md`, `clippy-fixer.agent.md` | CI, runner and commit-hygiene credentials | not about code secrets | + +There is no ADR on peer-key handling, request-log redaction or client-facing error text. + +## Scope + +### In Scope + +SI-A, secrets (a bug class): + +- Remove every cluster of A1 to A8 and A10 (a configuration error must not echo a secret value, for example by building the figment error message without the offending value or by rejecting a non-string secret with a fixed message): no error keeps or prints a key or token; request logging of both servers redacts the key path segment and the `token` query parameter (the maintainer's decision, 2026-11-22); the generated key is not logged in clear; the REST client strips the URL from transport errors; `Key` gets redacting `Debug` and no clear `Display` where a clear value is not needed. +- A rule for the peer key in the `handle-secrets` skill (and an ADR or an update of the secrecy ADR, decided in SI-A), and a fix of the `docs/containers.md` examples (A9). +- Tests that assert redaction without printing the secret, and a regression test per leak. + +SI-B, client error text (a design question): + +- An ADR that defines what a client may be told, per protocol and error family, and what must stay on the server (database driver text, internal error nesting, timing values, echo of client input). The ADR decides the text for database failures; the maintainer chose to decide it there. +- The implementation of that ADR for the HTTP tracker, the UDP tracker, the REST API and the event payloads, with each old and new text listed for approval, as the SI-3 and SI-4 specs do. +- A way for a developer to find the detail the client no longer sees (a `tracing` event on the server, perhaps with a request id the client can quote); the ADR decides. + +### Out of Scope + +- Removing source locations (EPIC #2912, SI-2 to SI-7). +- Changing authentication behaviour, key lifetimes or the REST API status codes and response shapes (EPIC #144, API v2). SI-B changes text only unless the ADR decides otherwise and says why. +- The general error-event contract (draft `docs/issues/drafts/generalize-error-events/`). +- The configuration-file secrets already covered by #2079, except the legacy v2 `Database.path` if SI-A decides to handle it. +- Server-side log content other than secrets (driver text in server logs is correct and stays). + +## Relation to EPIC #2912 + +Decided by the maintainer on 2026-11-22: this EPIC is standalone and linked. It is not a sub-issue of #2912, so #2912 keeps its single scope (source locations). Effects on #2912: + +- SI-4 (#2916, PR #2991) does not fix A1 or A2; it links this EPIC for the standing review finding. +- SI-5 (#2917): one interaction. Its AC2 says the startup error for a bad configuration file "names the file and the invalid key or value". For a secret option (the database password, an access token) the value must not be printed (A10). SI-5 should name the option and the expected type only for those options, or leave the value to SI-A; the maintainer decides which issue owns it. +- SI-6 (#2918) is unchanged. +- SI-7 (#384) is unchanged: it checks that no client reply holds a source path. Its out-of-scope note about other information in a reply (for example database error codes) points to SI-B. +- Order: nothing here blocks #2912. Any change to the text of the tracker-core errors lands after SI-4 merges, to avoid conflicting edits. + +## Subissues + +Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. + +| Order | Issue | Local Spec | Status | Notes | +| --- | --- | --- | --- | --- | +| 1 | #[To be assigned] - SI-A Keep secrets out of errors, logs and output | Not created | TODO | After SI-4 (#2916) merges. A bug class with the listed cases A1 to A9 | +| 2 | #[To be assigned] - SI-B Define and apply the client error text policy | Not created | TODO | Starts with an ADR; implementation after the maintainer accepts the ADR. May start in parallel with SI-A, but it touches the same error types, so run them one after the other | + +Both sub-issue specifications are drafted after this EPIC specification is merged. + +## Delivery Strategy + +One pull request per sub-issue, each spec-first. SI-A first, because it is a bug with known cases. SI-B writes the ADR first and waits for the maintainer's acceptance before code. + +For each subissue implementation in this EPIC, the default completion policy is: + +1. Run automatic checks (`linter all`, relevant tests, pre-push checks when applicable). +2. Run manual verification scenarios and record evidence. +3. Re-review acceptance criteria after implementation and update verification evidence. +4. Complete an evidence-based implementation review. Create or update an + issue-local retrospective for reusable lessons, material design changes, or + meaningful deviations from the plan; otherwise record why one was unnecessary + in the issue progress log. + +### Phase 1: secrets + +- Outcome: SI-A merged. +- Exit criteria: no log line produced by a real request holds a peer key or an admin token (shown on a running tracker); no error value or message holds one; the skill and ADR text cover the peer key. + +### Phase 2: client text + +- Outcome: the SI-B ADR accepted and applied. +- Exit criteria: the replies of the three protocols for each error family match the ADR; no database driver text reaches a client. + +## Progress Tracking + +### Workflow Checkpoints + +- [x] Epic spec drafted in `docs/issues/drafts/` and moved to `docs/issues/open/` +- [x] Epic spec reviewed and approved by user/maintainer +- [x] GitHub epic issue created and issue number added to this spec +- [ ] Subissues created and linked in this spec +- [ ] Subissue statuses kept up to date in the `Subissues` table +- [ ] For each implemented subissue: automatic checks completed and recorded +- [ ] For each implemented subissue: manual verification completed and recorded +- [ ] For each implemented subissue: acceptance criteria reviewed post-implementation +- [ ] For each implemented subissue: implementation completion review recorded +- [ ] Epic acceptance criteria reviewed and checked off +- [ ] Epic issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` + +### Progress Log + +- 2026-11-22 10:28 UTC - Claude Code (Claude Fable 5.2) - Drafted the EPIC from the inventory of the tree and the maintainer's decisions of 2026-11-22: an EPIC with two sub-issues, request-URI logging in scope (redact in both servers), standalone and linked to EPIC #2912, database text for clients decided in the SI-B ADR. Not approved; no GitHub issue created. +- 2026-11-22 13:24 UTC - Claude Code (Claude Fable 5.2) - The maintainer approved the specification. Created EPIC #2993 as `josecelano-bot` (labels `EPIC`, `Security`) and moved the specification to `docs/issues/open/`. GitHub sub-issue links wait for the maintainer (the bot account cannot add them). + +## Maintainer Decisions + +Recorded 2026-11-22 in the session that drafted this specification: + +1. The work is an EPIC with two sub-issues (SI-A secrets, SI-B client text), because the first is a bug class and the second a design question that needs an ADR. +2. Request-URI logging is in scope: redact the peer key and the `token` query parameter in both the HTTP tracker and the REST API. +3. The EPIC is standalone, linked from EPIC #2912 and SI-4, not a sub-issue of it. +4. What a client receives for database failures is decided in the SI-B ADR, not fixed in this specification. The user and host in database server messages (A11) are an operator-side exposure and a client-text question, so SI-B owns them. + +5. Principle for client text about a secret: help the legitimate user as much as possible without revealing the secret. The project is public, so an attacker can read the source, and security must not rely on hiding how the tracker works. A message may therefore state any fact about the client's own input (its length, that it holds a character outside the allowed set) and the state of the credential (not registered, expired), but never the secret itself. SI-B applies the same principle to the other error families. + +### Proposed messages for the peer key (to be confirmed in the SI-A specification) + +The key can be wrong for four different reasons, and each gets its own message. None of them needs the key: the client already has what it sent. + +| Case | Today | Proposed | What it tells an attacker | +| --- | --- | --- | --- | +| No key in the URL | `Missing authentication key` | `Missing authentication key: this tracker is private, use /announce/` | nothing new: the tracker is private | +| Malformed, wrong length | `Invalid format for authentication key param: expected 32 alphanumeric characters` (already without the key) | `Invalid authentication key: expected 32 characters, got 40` | the length of the client's own input, and the format, which is public in the source and the documentation | +| Malformed, wrong characters | the same text as above | `Invalid authentication key: only the characters 0-9, a-z and A-Z are allowed` (no position and no character) | the format, which is public | +| Well formed, not registered | `Failed to read key: ` | `Authentication key not registered` (or `Unknown authentication key`) | that this guess failed, which any reply reveals | +| Registered, expired | `Key has expired` | `Authentication key expired` (the expiry time may be added; SI-A decides) | that the key existed. It no longer works, and guessing a key by trial is not practical: 62^32 values | + +The REST API messages for an uploaded key (A2) follow the same pattern: the length or the character rule, never the key. + +## Acceptance Criteria + +- [ ] All required subissues are created and linked. +- [ ] Implementation order is explicit and justified. +- [ ] Dependencies and blockers are documented and current. +- [ ] Epic status reflects actual state of linked subissues. +- [ ] Every completed subissue includes automated verification evidence. +- [ ] Every completed subissue includes manual verification evidence. +- [ ] Every completed subissue includes post-implementation acceptance criteria review. +- [ ] Every completed subissue includes an implementation completion review. +- [ ] Documentation and governance updates are included when required. +- [ ] No error value keeps a peer key or an admin token, and no message prints one (A1, A2, A6, A10). +- [ ] No log line written for a real request on the HTTP tracker or the REST API holds a peer key or an admin token, shown on a running tracker (A3, A4, A5). +- [ ] The `handle-secrets` skill, and an ADR, state how the peer key is handled (A7), and `docs/containers.md` no longer teaches a pattern that logs a secret (A9). +- [ ] An accepted ADR defines the client text policy, and the replies of the HTTP tracker, the UDP tracker and the REST API follow it, shown on a running tracker. + +### Acceptance Verification + +| AC ID | Status (`TODO`/`DONE`) | Evidence | +| --- | --- | --- | +| AC1 | TODO | {issue/spec/PR links} | +| AC2 | TODO | {issue/spec/PR links} | +| AC3 | TODO | {issue/spec/PR links} | +| AC4 | TODO | {issue/spec/PR links} | +| AC5 | TODO | {issue/spec/PR links} | +| AC6 | TODO | {issue/spec/PR links} | +| AC7 | TODO | {issue/spec/PR links} | +| AC8 | TODO | {issue/spec/PR links} | +| AC9 | TODO | {issue/spec/PR links} | +| AC10 | TODO | {issue/spec/PR links} | +| AC11 | TODO | {issue/spec/PR links} | +| AC12 | TODO | {issue/spec/PR links} | +| AC13 | TODO | {issue/spec/PR links} | + +## Risks and Trade-offs + +- **Redacting the URI loses debugging value.** An operator can no longer see which key a client used. Mitigation: log a stable short fingerprint if the maintainer wants correlation; SI-A decides. +- **Hiding database detail from clients hides it from administrators.** The REST admin loses the driver text. Mitigation: the detail goes to a `tracing` event on the server, and the reply may carry a request id. +- **Changing client text breaks clients that match on it.** Today's text is unstable and unspecified, but a client may still match it. Mitigation: each sub-issue lists old and new texts for approval, and the ADR says whether any text is a contract. +- **Conflict with EPIC #2912.** Both touch tracker-core error types. Mitigation: SI-A and SI-B start after SI-4 merges. +- **Scope growth.** Mitigation: the Out of Scope list; API v2 status codes stay in EPIC #144. + +## References + +- Related issues: #2912 (EPIC, source locations), #2916 (SI-4, where the finding arose), #384 (original client-exposure report, SI-7 of #2912), #2079 (adopt `secrecy`, closed), #144 (API v2) +- Related PRs: #2991 (SI-4) +- Related ADRs: `docs/adrs/20260822094338_adopt_secrecy_for_sensitive_values.md`, `docs/adrs/20261118045443_errors_do_not_record_source_locations.md` +- Checked for overlap and found none: #2387 (lifecycle logs) keeps request logs out of its scope and points to #1166, which is an open discussion about `tracing` levels (for example ERROR for a wrong UDP connection id), not about what a log line may contain; #2411 (spam and abuse resistance) does not cover log redaction; EPIC #144 defines the error body and status codes of API v2 only, so SI-B covers v1 text and the two trackers +- Related drafts: `docs/issues/drafts/generalize-error-events/EPIC.md` +- Skills: `.claude/skills/handle-secrets/SKILL.md`, `.claude/skills/handle-errors-in-code/SKILL.md` From 66f71f43e808aa04b2c4776685ead713400ac32c Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:07:36 +0000 Subject: [PATCH 02/11] docs(issues): [#2993] draft the two sub-issue specifications of the EPIC Adds drafts for SI-A (keep secrets out of errors, logs and output) and SI-B (define and apply the client error text policy), links them from the EPIC table, and corrects the inventory: the health-check API server has the same request trace layer, though its routes carry no secret. Co-Authored-By: Claude Fable 5.2 --- .../ISSUE.md | 217 ++++++++++++++++++ .../ISSUE.md | 215 +++++++++++++++++ .../EPIC.md | 8 +- 3 files changed, 436 insertions(+), 4 deletions(-) create mode 100644 docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md create mode 100644 docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md diff --git a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md new file mode 100644 index 000000000..d44a02c0d --- /dev/null +++ b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md @@ -0,0 +1,217 @@ +--- +schema-version: 1 +doc-type: issue +issue-type: bug +status: draft +priority: p1 +epic: 2993 +github-issue: null +spec-path: docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md +branch: "{issue-number}-2993-si-a-keep-secrets-out-of-errors-and-logs" +related-pr: null +last-updated-utc: "2026-11-22 13:50" +semantic-links: + skill-links: + - create-issue + - fix-bug + - handle-secrets + - handle-errors-in-code + related-artifacts: + - .claude/skills/fix-bug/SKILL.md + - .claude/skills/create-issue/SKILL.md + - .claude/skills/handle-secrets/SKILL.md + - docs/issues/open/2993-secrets-and-client-error-text/EPIC.md + - docs/adrs/20260822094338_adopt_secrecy_for_sensitive_values.md + - docs/adrs/20261118045443_errors_do_not_record_source_locations.md +--- + + + +# Issue #[To be assigned] - SI-A Keep secrets out of errors, logs and output + +Parent EPIC: [Keep secrets out of errors, logs and client replies, and make client error text safe](../../open/2993-secrets-and-client-error-text/EPIC.md) (#2993). Sub-issue SI-A. + +## Goal + +No error value keeps a peer authentication key or a REST API admin token, no error message prints one, and no log line written for a real request or a configuration failure holds one. A legitimate user still gets a message that tells them what to fix. + +## Background + +The inventory of the EPIC (section "Inventory", items A1 to A11) lists every case found in the tree and reproduced on a running tracker. This issue owns the cases that are secrets: A1 to A8 and A10. A9 is a documentation fix that belongs here too. A11 (database server messages that name the user and host) is owned by SI-B. + +The rule already exists: rule 3 of the errors ADR (`docs/adrs/20261118045443_errors_do_not_record_source_locations.md`) says a secret is never the offending input in a message and the error does not keep it, and the `handle-secrets` skill forbids secrets in logs and error text. The code predates both for the peer key, which is not a `SecretString` and prints in clear wherever it is formatted. The skill and the secrecy ADR cover configuration secrets only; they do not name the peer key or secrets carried in URLs. + +The maintainer's principle (2026-11-22): help the legitimate user as much as possible without revealing the secret. Security does not rely on hiding how the tracker works, so a message may state facts about the client's own input (its length, a character outside the allowed set) and the state of the credential (not registered, expired), never the secret. + +## Scope + +### In Scope + +1. **Errors that keep or print a key (A1, A2).** + - `authentication::key::Error::UnableToReadKey` (`packages/tracker-core/src/authentication/key/mod.rs:180`) loses its `key` field. Its message becomes `Authentication key not registered` (wording confirmed in review). + - `PeerKeyError::InvalidKey` (`packages/tracker-core/src/error.rs:128`) and the REST `AuthKeyError::InvalidKey { key, reason }` (`packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs:31`) stop keeping the uploaded key. They keep the parse error, which already says what is wrong (length or characters), and the REST reply states the length that was received. + - The REST responses `invalid_auth_key_response` and `invalid_auth_key_param_response` stop echoing the key. +2. **Messages for the peer key** (the proposal in the EPIC, to confirm in review): `Missing authentication key: this tracker is private, use /announce/`; `Invalid authentication key: expected 32 characters, got `; `Invalid authentication key: only the characters 0-9, a-z and A-Z are allowed`; `Authentication key not registered`; `Authentication key expired`. The malformed-key texts are produced in `packages/http-protocol/src/v1/auth.rs` and `packages/tracker-core/src/authentication/key/peer_key.rs`; the length case needs the length passed to the error, not the key. +3. **Request logging (A3, A4).** The HTTP tracker, the REST API and the health-check API log `%uri` in the request event and the `DefaultMakeSpan` span records it again. Replace both with a redacted URI: the path segment after `/announce/`, `/scrape/` and `/api/v1/key/`, and the value of the `token` query parameter, are replaced by a fixed marker (`***`, the marker the configuration redaction uses). One tested function owns the rule, shared by the three servers; its home is decided at implementation (a small module in an existing shared package, not a new package unless the review asks for it). The span must not record the raw URI either: use a custom `MakeSpan`. +4. **The generated key (A5).** Remove the `tracing::debug!` lines that print the generated key (`packages/tracker-core/src/authentication/key/mod.rs:113`, `:120`). +5. **The type (A7).** `Key` gets a redacting `Debug` (`Key([REDACTED])`). Its `Display` stays only where the key is deliberately handed to its owner or persisted (the generate and add responses, the database store), and each remaining use is listed in the issue's evidence. `PeerKey`'s manual `Display` is checked the same way. Tests assert the redacted text without printing a test secret (`handle-secrets` skill). +6. **The REST client (A6).** The client strips the URL from `reqwest` errors (`without_url`) before it wraps them, and sends the token in the `Authorization: Bearer` header instead of the query string, which the server already accepts. The plain `String` token fields (A8) become `SecretString` where that is practical; if a field cannot change without a breaking change, record why. +7. **Configuration errors (A10).** A configuration error does not print the value of a secret option. For the `figment` error of a secret field (the database password, an access token), the loader reports the option path and the expected type with a fixed message and no value. How it is detected (the key path of the `figment` error against a list of secret paths, or reading the secret fields as strings and rejecting other types with a fixed message) is decided at implementation and recorded. +8. **Documentation (A9 and the gap).** Update the `handle-secrets` skill and the secrecy ADR (or add an ADR if the review prefers) with the rule for the peer key and for secrets carried in URLs; fix `docs/containers.md` so the examples use the `Authorization` header and the v3 network database fields instead of `?token=` and a `mysql://` `path`. + +### Out of Scope + +- The wording of client text for non-secret errors, and database text for clients (SI-B). +- Source locations in messages (EPIC #2912). A message this issue rewrites must not gain one. +- The user and host in database server messages (SI-B). +- Changing authentication behaviour, key lifetimes or REST status codes. +- Moving the peer key out of the URL: BEP 3 clients put it there, and the tracker protocol fixes it. + +## Architectural Decisions + +- Related ADRs: `docs/adrs/20260822094338_adopt_secrecy_for_sensitive_values.md`, `docs/adrs/20261118045443_errors_do_not_record_source_locations.md`. +- ADRs to create: none known. The peer-key rule may be recorded by amending the secrecy ADR; decide in review. + +## Design and Ownership Review + +Not applicable: the work changes error types, a log formatting function, a type's `Debug` and documentation. It adds no child process, asynchronous I/O, network readiness, resource cleanup or reusable test fixture. + +## Bug-Fix Process + +This is substantively a bug (a secret printed to a client and to logs), so it follows `.claude/skills/fix-bug/SKILL.md`: + +- analysis: the call paths and audiences are in the EPIC inventory; re-check them against the tree before the first change, because SI-4 (#2916) rewrites the tracker-core errors first; +- real-artifact reproduction: run a tracker and send the requests of the manual scenarios below; record each reply and the log lines. The EPIC's session already reproduced them on a debug build, so the baseline exists in the EPIC's progress log; repeat it on the commit this issue starts from; +- regression-test boundary: see Regression Test Strategy; +- red regression-test evidence, production fix, green test evidence, and the same reproduction run again after the last production change, all recorded in `manual-verification-evidence.md`. + +## Regression Test Strategy + +- **Errors**: a unit test per changed variant that builds the error from a unique test key and asserts that neither `Display` nor `Debug` contains it, and that the message still names what failed. Write it first and record its red output. +- **Log redaction**: a unit test of the shared redaction function over the URI shapes (`/announce/?...`, `/scrape/`, `/api/v1/key/?token=`, a bare `?token=`, a URI with no secret, a percent-encoded key). A test through each server captures the tracing output with a unique test key and token and asserts neither appears in it. +- **Generated key**: a test that captures the debug output of key generation. +- **Configuration**: a test that loads a configuration with a numeric database password and a numeric access token and asserts the error contains the option path and not the value. +- **REST client**: a test that forces a transport error and asserts the text holds neither the URL query nor the token. +- **Real boundary**: the existing protocol tests (`packages/axum-http-server/tests`, the REST API server tests) get assertions that a failure reason and a REST error hold no key. + +## Implementation Plan + +Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. + +| ID | Status | Task | Notes / Expected Output | +| --- | --- | --- | --- | +| T1 | TODO | Baseline reproduction | The EPIC cases A1 to A6 and A10 reproduced on the starting commit; evidence recorded. Starts after SI-4 (#2916) merges. | +| T2 | TODO | Red tests | Unit tests for the errors, the redaction function, the generated key, the configuration error and the REST client; protocol assertions; red output recorded. | +| T3 | TODO | Key errors and messages | A1, A2 and the new peer-key messages; the REST responses stop echoing the key. | +| T4 | TODO | `Key` type | Redacting `Debug`; remaining `Display` uses listed and justified. | +| T5 | TODO | Request logging | The shared redaction function; custom `MakeSpan` and `on_request` in the three servers; the generated-key log lines removed. | +| T6 | TODO | REST client | `without_url`, header token, `SecretString` where practical. | +| T7 | TODO | Configuration errors | A10: no secret value in a configuration error. | +| T8 | TODO | Documentation | `handle-secrets` skill, the ADR change, `docs/containers.md`. | +| T9 | TODO | Final recheck | The baseline reproduction repeated after the last production change. | + +## Commit Points + +| Task | Coherent change set | Commit policy | +| --- | --- | --- | +| T2 | The red tests | Commit after focused validation and required review. | +| T3 | Key errors, messages and REST responses | Commit after focused validation and required review. | +| T4 | `Key` and `PeerKey` formatting | Commit after focused validation and required review. | +| T5 | Redaction function and the three servers | Commit after focused validation and required review. | +| T6 | REST client | Commit after focused validation and required review. | +| T7 | Configuration errors | Commit after focused validation and required review. | +| T8 | Skill, ADR and documentation | Commit after focused validation and required review. | + +## Progress Tracking + +### Workflow Checkpoints + +- [x] Folder-style spec drafted in `docs/issues/drafts/` +- [ ] Spec reviewed and approved by user/maintainer +- [ ] GitHub issue created and issue number added to this spec +- [ ] Spec-only PR merged into `develop` before implementation +- [ ] Implementation completed +- [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) +- [ ] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` +- [ ] Acceptance criteria reviewed after implementation and updated with evidence +- [ ] Evidence-based implementation completion review recorded +- [ ] Reviewer validated acceptance criteria and updated checkboxes +- [ ] Committer verified spec progress is up to date before commit +- [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` + +### Progress Log + +- 2026-11-22 13:50 UTC - Claude Code (Claude Fable 5.2) - Drafted from the EPIC inventory after the maintainer asked that the sub-issue specifications be part of the EPIC pull request. Not approved; no GitHub issue created. + +## Acceptance Criteria + +- [ ] AC1: No error value keeps a peer key or an admin token, and no `Display` or `Debug` of an error prints one. +- [ ] AC2: A failure reason for a bad, unknown, expired or missing key tells the user which of the four cases it is, and holds no key. +- [ ] AC3: No log line written for a request to the HTTP tracker, the REST API or the health-check API holds a peer key or an admin token, shown on a running tracker with `trace_filter = "debug"`. +- [ ] AC4: Generating a key does not write it to the log. +- [ ] AC5: `Key` prints as `Key([REDACTED])` in `Debug`, and every remaining `Display` use is deliberate and listed. +- [ ] AC6: A transport error of the REST client holds neither the token nor the URL query. +- [ ] AC7: A configuration error for a secret option names the option and the expected type and does not print the value. +- [ ] AC8: The `handle-secrets` skill and an ADR state how the peer key and URL-borne secrets are handled, and `docs/containers.md` no longer teaches `?token=` or a `mysql://` `path`. +- [ ] `linter all` exits with code `0` +- [ ] Relevant tests pass +- [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` +- [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior + +## Verification Plan + +### Automatic Checks + +- `linter all` +- The unit and protocol tests named in the Regression Test Strategy +- Pre-push checks + +### Manual Verification Scenarios + +Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. + +| ID | Scenario | Human-oriented command/steps | Expected Result | Status | Evidence | +| --- | --- | --- | --- | --- | --- | +| M1 | Wrong peer key on a private tracker | Announce with an unregistered key, a 14-character key, a key with a `-`, an expired key, and no key | Five failure reasons, one per case, none holding the key | TODO | `manual-verification-evidence.md` section V1 | +| M2 | REST key errors | `POST /api/v1/keys` with a short key; `DELETE /api/v1/key/` | 400 texts that state the length or the rule and not the key | TODO | `manual-verification-evidence.md` section V2 | +| M3 | Request logs | With `trace_filter = "debug"`, send an announce with a key, a REST call with `?token=`, and a key delete; read the log | No line holds the key or the token; the `uri=` fields show the marker | TODO | `manual-verification-evidence.md` section V3 | +| M4 | Generated key | `POST /api/v1/key/3600` with `trace_filter = "debug"` | The log has no `Generated key` line with the key | TODO | `manual-verification-evidence.md` section V4 | +| M5 | Configuration error | Start the tracker with `password = 987654321` and with a numeric access token | The error names the option and the expected type, not the number | TODO | `manual-verification-evidence.md` section V5 | +| M6 | REST client | Point the client at a closed port with a token | The error text holds no token | TODO | `manual-verification-evidence.md` section V6 | + +Notes: manual verification is mandatory even when automated tests pass. Record the toolchain for every command, and create `manual-verification-evidence.md` from `docs/templates/MANUAL-VERIFICATION-EVIDENCE.md`. + +### Disposable Verification Scripts + +None planned. The UDP and HTTP probes of the EPIC session were ad-hoc commands; promote any durable check to a Rust test. + +### Acceptance Verification + +| AC ID | Status (`TODO`/`DONE`) | Evidence | +| --- | --- | --- | +| AC1 | TODO | {test/log/PR link} | +| AC2 | TODO | {test/log/PR link} | +| AC3 | TODO | {test/log/PR link} | +| AC4 | TODO | {test/log/PR link} | +| AC5 | TODO | {test/log/PR link} | +| AC6 | TODO | {test/log/PR link} | +| AC7 | TODO | {test/log/PR link} | +| AC8 | TODO | {test/log/PR link} | + +## Risks and Trade-offs + +- **Redacting the URI loses debugging value.** An operator cannot see which key a client used. Mitigation: if correlation is needed, log a short stable fingerprint (a truncated hash) instead of the key; decide in review. +- **Conflict with SI-4 (#2916).** Both rewrite the tracker-core key errors. Mitigation: start after SI-4 merges. +- **A breaking change in a public error enum.** `UnableToReadKey` loses a field. Mitigation: tracker-core is not published yet, and the enum is `#[non_exhaustive]`. +- **Moving the REST client token to the header** breaks nothing on the server, which accepts both, but changes what a proxy log sees. Mitigation: record it in the release notes. +- **Detecting secret options in a `figment` error** can miss a new secret option. Mitigation: derive the list from the `SecretString` fields, or test that each secret field is covered. + +## Implementation Completion Review + +- Retrospective: `Not yet assessed` +- If needed, create `implementation-retrospective.md` from `docs/templates/IMPLEMENTATION-RETROSPECTIVE.md` in this directory; otherwise record in the progress log why none was needed. + +## References + +- Related issues: #2993 (EPIC), #2912, #2916 (SI-4, where the finding arose), #2917 (SI-5, startup errors), #2079 (adopt `secrecy`) +- Related ADRs: `docs/adrs/20260822094338_adopt_secrecy_for_sensitive_values.md`, `docs/adrs/20261118045443_errors_do_not_record_source_locations.md` diff --git a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md new file mode 100644 index 000000000..d3f6aaf92 --- /dev/null +++ b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md @@ -0,0 +1,215 @@ +--- +schema-version: 1 +doc-type: issue +issue-type: enhancement +status: draft +priority: p2 +epic: 2993 +github-issue: null +spec-path: docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md +branch: "{issue-number}-2993-si-b-client-error-text-policy" +related-pr: null +last-updated-utc: "2026-11-22 13:50" +semantic-links: + skill-links: + - create-issue + - create-adr + - handle-errors-in-code + related-artifacts: + - .claude/skills/create-issue/SKILL.md + - .claude/skills/create-adr/SKILL.md + - .claude/skills/handle-errors-in-code/SKILL.md + - docs/issues/open/2993-secrets-and-client-error-text/EPIC.md + - docs/adrs/20261118045443_errors_do_not_record_source_locations.md + - docs/issues/open/144-api-v2-correct-response-codes/EPIC.md +--- + + + +# Issue #[To be assigned] - SI-B Define and apply the client error text policy + +Parent EPIC: [Keep secrets out of errors, logs and client replies, and make client error text safe](../../open/2993-secrets-and-client-error-text/EPIC.md) (#2993). Sub-issue SI-B. + +## Goal + +An accepted ADR says what an error reply may tell a client of the HTTP tracker, the UDP tracker and the REST API, and the three protocols follow it: the text helps a legitimate user fix the problem, and carries no database driver text, no internal error nesting, no server timing value and no Rust type name. + +## Background + +Section B of the EPIC inventory lists what each protocol sends today, reproduced on a running tracker: + +- HTTP tracker: `Tracker announce error: Database error: `; nested prefixes that mirror the Rust error tree; query parse texts that echo the client's own values. +- UDP tracker: the full `Display` chain of the server error. A wrong connection id returns `cookie value is expired: , expected > 1795353220.6572893` (the server clock and the decoded cookie); a short packet returns `error parsing request: SendableRequestParseError { message: "Couldn't parse action", ... }` (a Rust type name). +- REST API: every key, whitelist and reload failure, and a missing or wrong token, is a 500 with `Unhandled rejection: Err { reason: "..." }`; database failures put `e.to_string()` of the driver error in it (`UNIQUE constraint failed: keys.key`); a malformed JSON body returns serde's own text. +- A database server message can name the database user and the client address (`Access denied for user 'db_user'@'172.17.0.1'`). Today it reaches the operator only; it would reach a client wherever driver text is forwarded (EPIC item A11). +- The UDP error event payload (`packages/udp-server/src/event.rs:114-153`) holds the same strings. + +Rule 4 of the errors ADR says client text is the workspace error's own `Display` and that a source error from a crate the workspace does not control is not formatted into client text. It does not say how much a workspace `Display` may reveal, and the database errors break it today, because their `Display` includes the `sqlx` source. + +The maintainer's decisions (2026-11-22): the text for database failures is decided in this issue's ADR, and the principle is to help the legitimate user as much as possible without revealing a secret. The project is public, so the policy does not rely on hiding how the tracker works; it removes what a client cannot act on and what changes with the implementation. + +## Scope + +### In Scope + +1. **An ADR** (root, `docs/adrs/`, because it is a cross-package protocol decision) that decides: + - the classes of error a client can receive (the client's own bad input; an authorization decision such as not whitelisted or key not registered; a failure inside the tracker) and what each class may say; + - the text for a failure inside the tracker, including database failures. Options to weigh: a fixed generic text; the name of the failed operation without driver text; either of them with a request id the client can quote, since the HTTP tracker and the REST API already return `x-request-id`; + - whether a known cause keeps a specific message (a duplicate key is the client's mistake, not an internal failure); + - whether the reply mirrors the Rust error nesting (`tracker announce error: Tracker core whitelist error: ...`) or is one sentence; + - whether client text may echo the client's own input, and with what limits (length, escaping); + - what the UDP connection-id error says without the server clock; + - whether any reply text is a contract that clients may match, or all of it is free to change; + - where the detail goes: a `tracing` event on the server at the site of the failure, with the request id where one exists. Today the REST API logs a 500 with no reason, so the operator cannot tell why a request failed; + - what an event payload may carry (the UDP `ErrorKind` strings), in line with the events ADR (`docs/adrs/20260727000000_events_are_objective_facts.md`). +2. **The implementation of the ADR**, after the maintainer accepts it: the HTTP tracker (`packages/http-core/src/services/error_mapping.rs`, `packages/http-protocol`), the UDP tracker (`packages/udp-server/src/error.rs`, `packages/udp-server/src/handlers/error.rs`, `packages/udp-core/src/connection_cookie.rs`), the REST API (`packages/rest-api-runtime-adapter/src/v1/adapters/`, `packages/axum-rest-api-server/src/v1/responses.rs`, the JSON rejection) and the UDP error event. Each old and new text is listed in this specification for approval before the code changes, as the SI-3 and SI-4 specifications of EPIC #2912 do. +3. **The wrong label**: `From<(SqlxError, Driver)>` maps every `sqlx::Error::Database` to `InvalidQuery`, so an authentication failure reads `The MySQL query was malformed`. Fix the mapping or the wording as the ADR decides. +4. **The skill**: update `handle-errors-in-code` with the policy. + +### Out of Scope + +- Secrets in errors and logs (SI-A). +- Source locations (EPIC #2912). +- REST status codes and the response shape of API v1: v1 is additive-only, and correct codes and a structured error body are API v2 (EPIC #144). This issue changes v1 text only. The ADR should say how the v2 error model relates to this policy so the two do not diverge. +- The general error-event contract (draft `docs/issues/drafts/generalize-error-events/`). This issue changes only what the existing UDP error event carries, if the ADR decides it must change. +- Server-side log content: driver text in a server log is correct and stays. +- Log levels for client errors (#1166). + +## Architectural Decisions + +- Related ADRs: `docs/adrs/20261118045443_errors_do_not_record_source_locations.md` (rule 4), `docs/adrs/20260727000000_events_are_objective_facts.md`, `docs/adrs/20260623200526_adopt_contract-first_architecture_for_rest_api.md`. +- ADRs to create: "Client error text policy" (title to settle), in `docs/adrs/`. It may amend rule 4 of the errors ADR; say so in both. + +## Design and Ownership Review + +Not applicable: the work is a decision record and changes to error text and error mapping. It adds no child process, asynchronous I/O, network readiness, resource cleanup or reusable test fixture. + +## Bug-Fix Process + +The driver text in client replies and the wrong `InvalidQuery` label are bugs against rule 4 of the errors ADR, so the implementation phase follows `.claude/skills/fix-bug/SKILL.md`: baseline reproduction on a running tracker (the requests of the manual scenarios below), red tests, the change, green tests, and the same reproduction after the last production change, recorded in `manual-verification-evidence.md`. The ADR phase is not a bug fix. + +## Regression Test Strategy + +- **Unit**: for each error family, a test at the mapping seam (`error_mapping.rs`, the REST adapters, the UDP `From` conversions) that builds the error with a source carrying a unique marker string and asserts the client text does not contain it. +- **Real boundary**: one test per protocol with the existing test servers asserting the reply for a forced database failure (a duplicate insert) holds no driver text, and that the server log holds the detail. +- **UDP**: tests that the connection-id error holds no clock value and the parse error holds no type name. +- A helper that forbids known driver markers (`sqlx`, `error returned from database`, `constraint failed`, `Access denied`) in client text, used by the protocol tests. + +## Implementation Plan + +Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. + +| ID | Status | Task | Notes / Expected Output | +| --- | --- | --- | --- | +| T1 | TODO | Draft the ADR | The decisions listed in the scope, with the options and the reasons; a table of every current client text and its proposed text. Its own pull request. | +| T2 | TODO | Maintainer accepts the ADR | No code before this. Update this specification with the approved texts. | +| T3 | TODO | Baseline reproduction and red tests | Evidence recorded; red output recorded. | +| T4 | TODO | Database errors and the server-side event | Driver text stays in the source and the log; the `tracing` event exists; the `InvalidQuery` label is right. | +| T5 | TODO | HTTP tracker text | As the ADR decides. | +| T6 | TODO | UDP tracker text and the error event | As the ADR decides. | +| T7 | TODO | REST API text | As the ADR decides, within v1's additive-only rule. | +| T8 | TODO | Skill and documentation | `handle-errors-in-code`; any documented example reply. | +| T9 | TODO | Final recheck | The baseline reproduction repeated after the last production change. | + +## Commit Points + +| Task | Coherent change set | Commit policy | +| --- | --- | --- | +| T1 | The ADR and the index entry | Commit after focused validation and required review. | +| T3 | The red tests | Commit after focused validation and required review. | +| T4 | Database error mapping and the tracing event | Commit after focused validation and required review. | +| T5 | HTTP tracker text | Commit after focused validation and required review. | +| T6 | UDP tracker text and event | Commit after focused validation and required review. | +| T7 | REST API text | Commit after focused validation and required review. | +| T8 | Skill and documentation | Commit after focused validation and required review. | + +## Progress Tracking + +### Workflow Checkpoints + +- [x] Folder-style spec drafted in `docs/issues/drafts/` +- [ ] Spec reviewed and approved by user/maintainer +- [ ] GitHub issue created and issue number added to this spec +- [ ] Spec-only PR merged into `develop` before implementation +- [ ] ADR accepted +- [ ] Implementation completed +- [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) +- [ ] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` +- [ ] Acceptance criteria reviewed after implementation and updated with evidence +- [ ] Evidence-based implementation completion review recorded +- [ ] Reviewer validated acceptance criteria and updated checkboxes +- [ ] Committer verified spec progress is up to date before commit +- [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` + +### Progress Log + +- 2026-11-22 13:50 UTC - Claude Code (Claude Fable 5.2) - Drafted from the EPIC inventory after the maintainer asked that the sub-issue specifications be part of the EPIC pull request. Not approved; no GitHub issue created. + +## Acceptance Criteria + +- [ ] AC1: An accepted ADR defines the client error text policy and answers each question listed in the scope. +- [ ] AC2: No reply of the HTTP tracker, the UDP tracker or the REST API holds database driver text, shown by a test through each protocol server and on a running tracker. +- [ ] AC3: A database failure leaves a `tracing` event on the server with the detail, and the operator can relate it to the client's reply. +- [ ] AC4: The UDP connection-id error holds no server clock value, and the UDP parse error holds no Rust type name. +- [ ] AC5: Every changed client text is listed, old and new, in this specification and was approved before the change. +- [ ] AC6: The `handle-errors-in-code` skill states the policy. +- [ ] `linter all` exits with code `0` +- [ ] Relevant tests pass +- [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` +- [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior + +## Verification Plan + +### Automatic Checks + +- `linter all` +- The unit and protocol tests named in the Regression Test Strategy +- Pre-push checks + +### Manual Verification Scenarios + +Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. + +| ID | Scenario | Human-oriented command/steps | Expected Result | Status | Evidence | +| --- | --- | --- | --- | --- | --- | +| M1 | REST database failure | Add the same key twice through the REST API; read the reply and the server log | The reply follows the ADR and holds no driver text; the log holds the detail | TODO | `manual-verification-evidence.md` section V1 | +| M2 | HTTP and UDP whitelist rejection | Announce a non-whitelisted info-hash over HTTP and over UDP | One clear sentence each, no nesting beyond what the ADR allows | TODO | `manual-verification-evidence.md` section V2 | +| M3 | UDP connection id and short packet | Announce with a wrong connection id; send a 3-byte packet | No clock value; no type name | TODO | `manual-verification-evidence.md` section V3 | +| M4 | Database down | Stop the database of a MySQL or PostgreSQL tracker and send an announce that needs it, and a REST key request | The client text follows the ADR and names neither the user nor the host; the log holds them | TODO | `manual-verification-evidence.md` section V4 | +| M5 | REST bad token and bad JSON | Call the API with a wrong token and with a malformed JSON body | Text as the ADR decides, within v1's rules | TODO | `manual-verification-evidence.md` section V5 | + +Notes: manual verification is mandatory even when automated tests pass. Record the toolchain for every command, and create `manual-verification-evidence.md` from `docs/templates/MANUAL-VERIFICATION-EVIDENCE.md`. + +### Disposable Verification Scripts + +A short UDP probe (connect, announce, raw packet) is needed for M2 and M3, because no maintained tool sends a wrong connection id or a truncated packet. Keep it in this issue's folder; the implementer removes it at close-out unless it is promoted to a Rust test. If it is written in Python, record why Rust was not suitable. + +### Acceptance Verification + +| AC ID | Status (`TODO`/`DONE`) | Evidence | +| --- | --- | --- | +| AC1 | TODO | {test/log/PR link} | +| AC2 | TODO | {test/log/PR link} | +| AC3 | TODO | {test/log/PR link} | +| AC4 | TODO | {test/log/PR link} | +| AC5 | TODO | {test/log/PR link} | +| AC6 | TODO | {test/log/PR link} | + +## Risks and Trade-offs + +- **Hiding detail from the REST administrator.** The administrator is trusted and today reads the driver text in the reply. Mitigation: the detail goes to the server log with the request id; the ADR may allow more for the authenticated REST API than for the public trackers. +- **Clients that match on text.** Mitigation: list old and new texts; the ADR says whether any text is a contract. +- **Divergence from API v2.** Mitigation: the ADR names how the v2 error model (EPIC #144) relates to the policy. +- **Over-generic messages that help nobody.** Mitigation: the maintainer's principle; a known client mistake keeps a specific message. +- **Conflict with SI-A and SI-4.** All three touch the tracker-core errors. Mitigation: run them one after the other: SI-4, then SI-A, then this issue's code. + +## Implementation Completion Review + +- Retrospective: `Not yet assessed` +- If needed, create `implementation-retrospective.md` from `docs/templates/IMPLEMENTATION-RETROSPECTIVE.md` in this directory; otherwise record in the progress log why none was needed. + +## References + +- Related issues: #2993 (EPIC), #2912, #384 (the 2023 report about what error replies reveal), #144 (API v2), #1166 (log levels) +- Related ADRs: `docs/adrs/20261118045443_errors_do_not_record_source_locations.md`, `docs/adrs/20260727000000_events_are_objective_facts.md` +- Related drafts: `docs/issues/drafts/generalize-error-events/EPIC.md` diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md index 63915d77c..bc591f1e8 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -68,7 +68,7 @@ Checked and found safe, so that the spec does not redo it: - No `databases::error::Error` variant has a URL, DSN or password field; the connection URL goes only to `from_str`. - No event payload, metric label or health-check output carries a key, token or credential. - The `Authorization: Bearer` header is not logged (`include_headers` is off). -- The health-check API server has no `TraceLayer`. +- The health-check API server has the same `TraceLayer` and logs `%uri` (`packages/axum-health-check-api-server/src/server.rs:151-167`), but its routes (`/`, `/health_check`) carry no secret. SI-A gives it the same redaction function so that the three servers behave alike. - No `#[instrument]` takes a key, token or database URL without skipping it. Verified by running experiments (2026-11-22, a debug build of the tracker; MySQL 8.0 and PostgreSQL 16 in local containers): @@ -179,10 +179,10 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | Order | Issue | Local Spec | Status | Notes | | --- | --- | --- | --- | --- | -| 1 | #[To be assigned] - SI-A Keep secrets out of errors, logs and output | Not created | TODO | After SI-4 (#2916) merges. A bug class with the listed cases A1 to A9 | -| 2 | #[To be assigned] - SI-B Define and apply the client error text policy | Not created | TODO | Starts with an ADR; implementation after the maintainer accepts the ADR. May start in parallel with SI-A, but it touches the same error types, so run them one after the other | +| 1 | #[To be assigned] - SI-A Keep secrets out of errors, logs and output | `docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md` | TODO | After SI-4 (#2916) merges. A bug class with the listed cases A1 to A9 | +| 2 | #[To be assigned] - SI-B Define and apply the client error text policy | `docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md` | TODO | Starts with an ADR; implementation after the maintainer accepts the ADR. May start in parallel with SI-A, but it touches the same error types, so run them one after the other | -Both sub-issue specifications are drafted after this EPIC specification is merged. +Both sub-issue specifications are drafts until the maintainer approves them; their GitHub issues are created then. ## Delivery Strategy From 9342ea8ed2c9c854814e1369bc9921a2751ab375 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:09:00 +0000 Subject: [PATCH 03/11] docs(issues): [#2993] list A10 and A11 in the inventory table and state what was reproduced Co-Authored-By: Claude Fable 5.2 --- docs/issues/open/2993-secrets-and-client-error-text/EPIC.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md index bc591f1e8..f40485fb5 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -61,6 +61,8 @@ Paths are relative to the repository root. Every item was read in the code, and | A7 | `packages/tracker-core/src/authentication/key/peer_key.rs:127-128`, `:46-47`, `:71-75` (`Key` and `PeerKey` derive `Debug`, `Display`, `Serialize`) | the peer key prints in clear wherever the value is formatted | any log or error that formats a `Key` | | A8 | `packages/axum-rest-api-server/src/v1/middlewares/auth.rs:62-65` (`QueryParams { token: Option }` derives `Debug`); `packages/rest-api-client/src/connection_info.rs:7-9` (`api_token: Option`) | plain `String` tokens; no log of them was found | none today; a latent risk | | A9 | `docs/containers.md` (lines about 492-562) | the documentation teaches `?token=` URLs and a `mysql://user:password@host` URL in config and environment | readers; the request log then records the token. The MySQL example (`path = "mysql://db_user:...@mysql:3306/torrust_tracker"`) is also stale: the v3 schema refuses `path` for a network database (`packages/configuration/src/v3_0_0/database.rs:203-204`) | +| A10 | `packages/configuration/src/v3_0_0/mod.rs:409` (`figment.extract()`), wrapped by `Error::ConfigError` (`packages/configuration/src/lib.rs:335`) | a configuration error prints the offending value, so a numeric database password or access token is printed (details below) | the operator: stderr and the server log | +| A11 | `packages/tracker-core/src/databases/error.rs:111-135` (`From<(SqlxError, Driver)>` keeps the `sqlx` text) | a database server message names the database user and the client address (details below). Not a secret; owned by SI-B | the operator today; a client wherever driver text is forwarded | Checked and found safe, so that the spec does not redo it: @@ -73,7 +75,7 @@ Checked and found safe, so that the spec does not redo it: Verified by running experiments (2026-11-22, a debug build of the tracker; MySQL 8.0 and PostgreSQL 16 in local containers): -- A1 to A9 above were reproduced on a running tracker: the announce failure reason `Tracker authentication error: Failed to read key: , ` carried the sent key, and the request log held `uri=/announce/?...` and `uri=/api/v1/stats?token=`. With `Authorization: Bearer`, the admin token did not appear in the log, so the header form is the safe way to call the API today. +- A1, A3 and A4 were reproduced on a running tracker (A2 and A5 in the next item, A10 and A11 below). A6, A7 and A8 were confirmed by reading the code, and A9 is documentation. For A1, A3 and A4: the announce failure reason `Tracker authentication error: Failed to read key: , ` carried the sent key, and the request log held `uri=/announce/?...` and `uri=/api/v1/stats?token=`. With `Authorization: Bearer`, the admin token did not appear in the log, so the header form is the safe way to call the API today. - More reproductions on the same build. A2: `POST /api/v1/keys` with a 14-character key returned 400 `Invalid URL: invalid auth key: string "", Invalid key length. Key must be have 32 chars, `. A5: with `trace_filter = "debug"`, `POST /api/v1/key/3600` wrote `Generated key: , valid for: ...` to the log. A4: `DELETE /api/v1/key/` wrote `uri=/api/v1/key/`. A duplicate key returned 500 `Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, " }`. The ERROR log lines for a 500 reply hold the status and the request id but not the body, so the server log does not tell an operator why the request failed. - A6 by reading: `reqwest` appends `for url ()` to its `Display` (`reqwest-0.13.5/src/error.rs:300-302`), and the REST client has no header form: it always adds the token to the query string (`packages/rest-api-client/src/v1/client.rs:369-370`). Its users in the workspace are the REST server tests and the qBittorrent end-to-end tool (`src/console/ci/qbittorrent_e2e/tracker/client.rs`). - UDP replies, on a public tracker with `listed = true`: a non-whitelisted announce returned `tracker announce error: Tracker core whitelist error: The torrent: , is not whitelisted, `; an announce with a wrong connection id returned `tracker announce error: Connection cookie error: cookie value is expired: , expected > 1795353220.6572893`, which gives the client the server clock and the decoded value of the cookie it sent; a 3-byte packet returned `error parsing request: SendableRequestParseError { message: "Couldn't parse action", opt_connection_id: None, opt_transaction_id: None }`, a Rust type name in client text. From 82008cf86ff4a378355657481cd055ca6509e58e Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:10:03 +0000 Subject: [PATCH 04/11] docs(issues): [#2993] mark the quoted key-length message as verbatim Co-Authored-By: Claude Fable 5.2 --- docs/issues/open/2993-secrets-and-client-error-text/EPIC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md index f40485fb5..1da36852e 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -76,7 +76,7 @@ Checked and found safe, so that the spec does not redo it: Verified by running experiments (2026-11-22, a debug build of the tracker; MySQL 8.0 and PostgreSQL 16 in local containers): - A1, A3 and A4 were reproduced on a running tracker (A2 and A5 in the next item, A10 and A11 below). A6, A7 and A8 were confirmed by reading the code, and A9 is documentation. For A1, A3 and A4: the announce failure reason `Tracker authentication error: Failed to read key: , ` carried the sent key, and the request log held `uri=/announce/?...` and `uri=/api/v1/stats?token=`. With `Authorization: Bearer`, the admin token did not appear in the log, so the header form is the safe way to call the API today. -- More reproductions on the same build. A2: `POST /api/v1/keys` with a 14-character key returned 400 `Invalid URL: invalid auth key: string "", Invalid key length. Key must be have 32 chars, `. A5: with `trace_filter = "debug"`, `POST /api/v1/key/3600` wrote `Generated key: , valid for: ...` to the log. A4: `DELETE /api/v1/key/` wrote `uri=/api/v1/key/`. A duplicate key returned 500 `Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, " }`. The ERROR log lines for a 500 reply hold the status and the request id but not the body, so the server log does not tell an operator why the request failed. +- More reproductions on the same build. A2: `POST /api/v1/keys` with a 14-character key returned 400 `Invalid URL: invalid auth key: string "", Invalid key length. Key must be have 32 chars, `. The text is verbatim, including the grammar slip "must be have" (`packages/tracker-core/src/authentication/key/peer_key.rs:195`); SI-A replaces this message. A5: with `trace_filter = "debug"`, `POST /api/v1/key/3600` wrote `Generated key: , valid for: ...` to the log. A4: `DELETE /api/v1/key/` wrote `uri=/api/v1/key/`. A duplicate key returned 500 `Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, " }`. The ERROR log lines for a 500 reply hold the status and the request id but not the body, so the server log does not tell an operator why the request failed. - A6 by reading: `reqwest` appends `for url ()` to its `Display` (`reqwest-0.13.5/src/error.rs:300-302`), and the REST client has no header form: it always adds the token to the query string (`packages/rest-api-client/src/v1/client.rs:369-370`). Its users in the workspace are the REST server tests and the qBittorrent end-to-end tool (`src/console/ci/qbittorrent_e2e/tracker/client.rs`). - UDP replies, on a public tracker with `listed = true`: a non-whitelisted announce returned `tracker announce error: Tracker core whitelist error: The torrent: , is not whitelisted, `; an announce with a wrong connection id returned `tracker announce error: Connection cookie error: cookie value is expired: , expected > 1795353220.6572893`, which gives the client the server clock and the decoded value of the cookie it sent; a 3-byte packet returned `error parsing request: SendableRequestParseError { message: "Couldn't parse action", opt_connection_id: None, opt_transaction_id: None }`, a Rust type name in client text. - UDP trackers are not started in private mode (`Could not start UDP trackers while in private mode. UDP is not safe for private trackers!`), so the peer key never travels over UDP. From 226ab9cb2e6f8af0593f3cd59a97f9e26b7128a8 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:19:29 +0000 Subject: [PATCH 05/11] docs(pr-reviews): [#2994] record review round 1 Round 1: review 6012624473 by Copilot, seven inline comments (F1 to F7). F1 and F4 are fixed by earlier commits of this branch, F5 needs no change (template text), and F2, F3, F6 and F7 repeat F1 or F5. All seven threads have a reply and are resolved. Co-Authored-By: Claude Fable 5.2 --- docs/pr-reviews/pr-2994-review/PR-REVIEW.md | 172 ++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 docs/pr-reviews/pr-2994-review/PR-REVIEW.md diff --git a/docs/pr-reviews/pr-2994-review/PR-REVIEW.md b/docs/pr-reviews/pr-2994-review/PR-REVIEW.md new file mode 100644 index 000000000..48314f84d --- /dev/null +++ b/docs/pr-reviews/pr-2994-review/PR-REVIEW.md @@ -0,0 +1,172 @@ +--- +semantic-links: + skill-links: + - process-pr-review + related-artifacts: + - .claude/skills/process-pr-review/SKILL.md +--- + + + +# PR #2994 Review Audit + +Source: pull-request reviews and inline review threads for . + +## Ownership + +The PR author owns this tracked audit record. Reviewers, including repository review agents, +deliver findings through GitHub and have no repository-artifact obligation. + +- Post-merge workflow approval: N/A + +## Status Values + +- Relationship: `ORIGINAL`, `RE_RAISE_OF:` +- Disposition: `FIXED`, `NO_ACTION`, `SUPERSEDED`, `FOLLOW_UP` +- Thread state: `OPEN`, `RESOLVED`, `NON_RESOLVABLE`, `SUPERSEDED`. `OPEN` applies prospectively + to audits created or updated for approved follow-up work; historical audits remain valid without + bulk migration. +- Severity: `Blocker`, `Major`, `Minor`, `Nit`, `Suggestion`; append `(inferred)` when derived + from free prose. +- Author class: `Copilot`, `Human`, `Unknown` +- Category: `link-integrity`, `formatting`, `metadata`, `testing`, `correctness`, + `documentation`, `maintainability`, `security`, `other` +- An outdated thread whose concern was fixed is `FIXED`/`RESOLVED`, even when GitHub marks the + original thread outdated after the push. For in-PR feedback, use `NO_ACTION`/`SUPERSEDED` only + for a duplicate, superseded, or no-change concern. A post-merge `NO_ACTION` requires maintainer + approval to decline the follow-up work. +- When the current identity cannot resolve a thread (`viewerCanResolve` is `false`), keep the + disposition established from the current tree and record `Thread state=OPEN`. The reviewer or PR + author resolves it; permission says nothing about whether the concern was fixed. + +## Findings + +Round 1 covers review 6012624473 (Copilot, COMMENTED, submitted 2026-11-22T14:05:07Z, a lite review) with seven inline comments on `docs/issues/open/2993-secrets-and-client-error-text/EPIC.md`. Its body is an overview with no finding beyond the inline comments; its warning that the full agentic review did not start is context and makes no row. The comments carry no `[Severity]` bracket. The audit severity scale has no medium or low level, so this audit maps the overview's `Medium severity` badge (F1 to F3) to `Minor (inferred)` and its `Low severity` badge (F4 to F7) to `Nit (inferred)`, as the PR #2990 audit does. The seven comments are three texts: F2 and F3 repeat F1 on other lines, and F6 and F7 repeat F5, so they are re-raises with their own rows. + +| Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | +| ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | +| F1 | review-finding:pr-2994-f1 | Copilot | Minor (inferred) | documentation | ORIGINAL | FIXED | RESOLVED | +| F2 | review-finding:pr-2994-f2 | Copilot | Minor (inferred) | documentation | RE_RAISE_OF:F1 | NO_ACTION | SUPERSEDED | +| F3 | review-finding:pr-2994-f3 | Copilot | Minor (inferred) | documentation | RE_RAISE_OF:F1 | NO_ACTION | SUPERSEDED | +| F4 | review-finding:pr-2994-f4 | Copilot | Nit (inferred) | documentation | ORIGINAL | FIXED | RESOLVED | +| F5 | review-finding:pr-2994-f5 | Copilot | Nit (inferred) | documentation | ORIGINAL | NO_ACTION | SUPERSEDED | +| F6 | review-finding:pr-2994-f6 | Copilot | Nit (inferred) | documentation | RE_RAISE_OF:F5 | NO_ACTION | SUPERSEDED | +| F7 | review-finding:pr-2994-f7 | Copilot | Nit (inferred) | documentation | RE_RAISE_OF:F5 | NO_ACTION | SUPERSEDED | + +## Finding Details + +### F1 - A10 and A11 are missing from the A table and the "A1 to A9 were reproduced" sentence is inaccurate + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421443 +- Concern: The inventory numbering is inconsistent: A10 and A11 are introduced later but are not in the A table, and "A1 to A9 above were reproduced on a running tracker" is inaccurate because A9 is documentation and A10 and A11 are also part of the verified set. Copilot suggests adding A10 and A11 to the table and making the verification bullet match what was reproduced. +- Solution: The A table has rows A10 and A11. The verification bullet says which items were reproduced on a running tracker (A1, A3, A4; A2 and A5 in the next item; A10 and A11 below), which were confirmed by reading the code (A6, A7, A8), and that A9 is documentation. Copilot's example wording "A1–A8, A10–A11" was not used because A6 to A8 were not reproduced on a running tracker. +- Current-tree verification: `grep -c '^| A1[01] |' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 2; `grep -c 'A1 to A9 above were reproduced' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 0; the verification bullet reads "A1, A3 and A4 were reproduced on a running tracker (A2 and A5 in the next item, A10 and A11 below). A6, A7 and A8 were confirmed by reading the code, and A9 is documentation." +- Resolution reference: `docs(issues): [#2993] list A10 and A11 in the inventory table and state what was reproduced` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463288 + +### F2 - Same inventory-numbering comment on the first verification bullet + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421459 +- Concern: Same text as F1, anchored on original line 76 of the reviewed commit (the verification bullet). +- Solution: No separate change: F1's fix covers it. +- Current-tree verification: Same as F1: `grep -c '^| A1[01] |' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 2; `grep -c 'A1 to A9 above were reproduced' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 0; the verification bullet reads "A1, A3 and A4 were reproduced on a running tracker (A2 and A5 in the next item, A10 and A11 below). A6, A7 and A8 were confirmed by reading the code, and A9 is documentation." +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463401 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463401 + +### F3 - Same inventory-numbering comment on the A10 and A11 bullets + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421468 +- Concern: Same text as F1, anchored on the A11 bullet (line 84 of the current file). +- Solution: No separate change: F1's fix covers it. +- Current-tree verification: Same as F1: `grep -c '^| A1[01] |' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 2; `grep -c 'A1 to A9 above were reproduced' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 0; the verification bullet reads "A1, A3 and A4 were reproduced on a running tracker (A2 and A5 in the next item, A10 and A11 below). A6, A7 and A8 were confirmed by reading the code, and A9 is documentation." +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463527 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463527 + +### F4 - "Key must be have 32 chars" reads like an error in the spec + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421476 +- Concern: The excerpt "Key must be have 32 chars" reads like a grammatical error. Copilot asks to mark it as verbatim (a note or "[sic]") if it is the system's output, or to correct it if paraphrased, and suggests naming this message quality issue in the motivation of SI-B. +- Solution: The A2 reproduction says the text is verbatim, including the grammar slip "must be have", cites the source line, and says SI-A replaces the message. The suggestion to add it to SI-B's motivation was not taken: the message is about a peer key, and In Scope item 2 of the SI-A draft (`docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md`) owns the new key messages. +- Current-tree verification: `grep -c 'The text is verbatim, including the grammar slip "must be have"' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 1; `packages/tracker-core/src/authentication/key/peer_key.rs:195` reads `#[error("Invalid key length. Key must be have 32 chars")]`; line 54 of the SI-A draft proposes `Invalid authentication key: expected 32 characters, got `. +- Resolution reference: `docs(issues): [#2993] mark the quoted key-length message as verbatim` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463632 + +### F5 - 'Subissues', 'sub-issue' and 'subissue' are used inconsistently + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421494 +- Concern: The document uses 'Subissues', 'sub-issue' and 'subissue'. Copilot recommends one form (for example 'sub-issue' / 'Sub-issues') throughout. +- Solution: No change. Every line with "Subissues" or "subissue" (the `## Subissues` heading, the Delivery Strategy sentence, the Workflow Checkpoints and the Acceptance Criteria items) is unchanged text of the repository template `docs/templates/EPIC.md`, which other EPIC specifications share. The prose written for this specification uses "sub-issue". Changing the template wording is outside this specification-only pull request. +- Current-tree verification: `grep -ci 'subissue' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 14 (lines 178, 193, 220 to 225, 261 and 264 to 268), and `grep -qFx` finds each of those 14 lines unchanged in `docs/templates/EPIC.md`; `grep -c 'sub-issue' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 11, none of them a template line. `docs/issues/open/2912-remove-source-locations-from-errors/EPIC.md` has the same `## Subissues` heading. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463773 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463773 + +### F6 - Same terminology comment on the sub-issue drafts sentence + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421514 +- Concern: Same text as F5, anchored on original line 185 of the reviewed commit. +- Solution: No separate change: same disposition as F5. +- Current-tree verification: Same as F5: `grep -ci 'subissue' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 14 (lines 178, 193, 220 to 225, 261 and 264 to 268), and `grep -qFx` finds each of those 14 lines unchanged in `docs/templates/EPIC.md`; `grep -c 'sub-issue' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 11, none of them a template line. `docs/issues/open/2912-remove-source-locations-from-errors/EPIC.md` has the same `## Subissues` heading. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463980 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658463980 + +### F7 - Same terminology comment on the Delivery Strategy sentence + +- PR number: 2994 +- Source review ID: 6012624473 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658421527 +- Concern: Same text as F5, anchored on line 193 ("For each subissue implementation in this EPIC, ..."). +- Solution: No separate change: same disposition as F5. Line 193 is a template line. +- Current-tree verification: Same as F5: `grep -ci 'subissue' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 14 (lines 178, 193, 220 to 225, 261 and 264 to 268), and `grep -qFx` finds each of those 14 lines unchanged in `docs/templates/EPIC.md`; `grep -c 'sub-issue' docs/issues/open/2993-secrets-and-client-error-text/EPIC.md` prints 11, none of them a template line. `docs/issues/open/2912-remove-source-locations-from-errors/EPIC.md` has the same `## Subissues` heading. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658464189 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658464189 + +## Processing Log + +- 2026-11-22 14:16 UTC - Started audit. Round 1: review 6012624473 (Copilot, COMMENTED, submitted 14:05:07Z) with seven inline comments, F1 to F7. Fetched the seven review threads with GraphQL as `josecelano-bot`: all unresolved, `viewerCanResolve` true for each. The fixes of F1 and F4 were already committed (committer times 14:09:00Z and 14:10:03Z) and on the pull request head. Checked each disposition against the current tree with the commands in the detail entries. +- 2026-11-22 14:17 UTC - Replied on the seven threads as `josecelano-bot` (reply `created_at` 14:17:20Z to 14:17:34Z) and recorded the reply URLs. +- 2026-11-22 14:18 UTC - A copy of the audit validator that calls `gh-bot` exits 0 (7 rows, 0 failures). After it, `github-review-threads reply-status` reported `all_replied` (7 of 7) and the seven threads were resolved as `josecelano-bot`. A new GraphQL fetch shows 7 threads, 0 unresolved. This record is not committed yet. + +## Completion Rules + +- Re-derive the reply claim against the current tree before replying or resolving a thread. +- Reply on every resolvable thread before resolving it. +- For an outdated thread whose concern was fixed, record `Disposition=FIXED` and + `Thread state=RESOLVED`, even if GitHub marks the thread outdated after the push. For a + duplicate, superseded, or no-change in-PR thread, reply exactly + `Superseded by : .`, record `Disposition=NO_ACTION` and + `Thread state=SUPERSEDED`, then resolve it. A post-merge `NO_ACTION` requires maintainer + approval to decline the follow-up work. When the current identity cannot resolve a thread + (`viewerCanResolve` is `false`), still reply, keep the disposition established from the current + tree, and record `Thread state=OPEN`; the reviewer or PR author resolves it. +- A consolidated PR conversation response may cover multiple review rounds only when it names + every review ID and every finding ID with its disposition and resolution reference. Record its + durable URL in each related row. +- Cite a fix by its unique Conventional Commit subject or durable reply URL, never by a branch SHA + that can change after a rebase. +- Refresh review threads using GraphQL and confirm that no unresolved actionable thread remains. From d7d15dcce38db352cde1d902aecb8a849b4e2ae9 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:47:25 +0000 Subject: [PATCH 06/11] docs(issues): [#2993] record the reproductions of the EPIC inventory as manual verification evidence Co-Authored-By: Claude Fable 5.2 --- cspell.json | 1 + .../ISSUE.md | 2 +- .../ISSUE.md | 2 +- .../EPIC.md | 2 +- .../evidence/output.txt | 63 +++++ .../evidence/reproduce.sh | 64 +++++ .../evidence/udp_probe.py | 22 ++ .../manual-verification-evidence.md | 240 ++++++++++++++++++ 8 files changed, 393 insertions(+), 3 deletions(-) create mode 100644 docs/issues/open/2993-secrets-and-client-error-text/evidence/output.txt create mode 100755 docs/issues/open/2993-secrets-and-client-error-text/evidence/reproduce.sh create mode 100644 docs/issues/open/2993-secrets-and-client-error-text/evidence/udp_probe.py create mode 100644 docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md diff --git a/cspell.json b/cspell.json index 2f114e084..8189530d2 100644 --- a/cspell.json +++ b/cspell.json @@ -25,6 +25,7 @@ "packages/tracker-core/docs/benchmarking/machine/*.txt", "docs/issues/*/2850-non-negative-number-of-bytes/evidence/*.txt", "docs/issues/*/2915-2912-si-3-http-tracker-request-errors/evidence/*.txt", + "docs/issues/*/2993-secrets-and-client-error-text/evidence/*.txt", ".github/labels.json", "/project-words.txt", "repomix-output.xml", diff --git a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md index d44a02c0d..ddc349218 100644 --- a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md +++ b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md @@ -81,7 +81,7 @@ Not applicable: the work changes error types, a log formatting function, a type' This is substantively a bug (a secret printed to a client and to logs), so it follows `.claude/skills/fix-bug/SKILL.md`: - analysis: the call paths and audiences are in the EPIC inventory; re-check them against the tree before the first change, because SI-4 (#2916) rewrites the tracker-core errors first; -- real-artifact reproduction: run a tracker and send the requests of the manual scenarios below; record each reply and the log lines. The EPIC's session already reproduced them on a debug build, so the baseline exists in the EPIC's progress log; repeat it on the commit this issue starts from; +- real-artifact reproduction: run a tracker and send the requests of the manual scenarios below; record each reply and the log lines. The EPIC's session reproduced them, and the commands, configuration and output are in the EPIC's `manual-verification-evidence.md`; repeat that baseline on the commit this issue starts from, because SI-4 changes the texts first; - regression-test boundary: see Regression Test Strategy; - red regression-test evidence, production fix, green test evidence, and the same reproduction run again after the last production change, all recorded in `manual-verification-evidence.md`. diff --git a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md index d3f6aaf92..f30b37935 100644 --- a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md +++ b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md @@ -36,7 +36,7 @@ An accepted ADR says what an error reply may tell a client of the HTTP tracker, ## Background -Section B of the EPIC inventory lists what each protocol sends today, reproduced on a running tracker: +Section B of the EPIC inventory lists what each protocol sends today, reproduced on a running tracker (commands and output in the EPIC's [`manual-verification-evidence.md`](../../open/2993-secrets-and-client-error-text/manual-verification-evidence.md)): - HTTP tracker: `Tracker announce error: Database error: `; nested prefixes that mirror the Rust error tree; query parse texts that echo the client's own values. - UDP tracker: the full `Display` chain of the server error. A wrong connection id returns `cookie value is expired: , expected > 1795353220.6572893` (the server clock and the decoded cookie); a short packet returns `error parsing request: SendableRequestParseError { message: "Couldn't parse action", ... }` (a Rust type name). diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md index 1da36852e..a9840af22 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -73,7 +73,7 @@ Checked and found safe, so that the spec does not redo it: - The health-check API server has the same `TraceLayer` and logs `%uri` (`packages/axum-health-check-api-server/src/server.rs:151-167`), but its routes (`/`, `/health_check`) carry no secret. SI-A gives it the same redaction function so that the three servers behave alike. - No `#[instrument]` takes a key, token or database URL without skipping it. -Verified by running experiments (2026-11-22, a debug build of the tracker; MySQL 8.0 and PostgreSQL 16 in local containers): +Verified by running experiments (2026-11-22, a debug build of the tracker; MySQL 8.0 and PostgreSQL 16 in local containers). The commands, configuration files and output are in [`manual-verification-evidence.md`](manual-verification-evidence.md): - A1, A3 and A4 were reproduced on a running tracker (A2 and A5 in the next item, A10 and A11 below). A6, A7 and A8 were confirmed by reading the code, and A9 is documentation. For A1, A3 and A4: the announce failure reason `Tracker authentication error: Failed to read key: , ` carried the sent key, and the request log held `uri=/announce/?...` and `uri=/api/v1/stats?token=`. With `Authorization: Bearer`, the admin token did not appear in the log, so the header form is the safe way to call the API today. - More reproductions on the same build. A2: `POST /api/v1/keys` with a 14-character key returned 400 `Invalid URL: invalid auth key: string "", Invalid key length. Key must be have 32 chars, `. The text is verbatim, including the grammar slip "must be have" (`packages/tracker-core/src/authentication/key/peer_key.rs:195`); SI-A replaces this message. A5: with `trace_filter = "debug"`, `POST /api/v1/key/3600` wrote `Generated key: , valid for: ...` to the log. A4: `DELETE /api/v1/key/` wrote `uri=/api/v1/key/`. A duplicate key returned 500 `Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, " }`. The ERROR log lines for a 500 reply hold the status and the request id but not the body, so the server log does not tell an operator why the request failed. diff --git a/docs/issues/open/2993-secrets-and-client-error-text/evidence/output.txt b/docs/issues/open/2993-secrets-and-client-error-text/evidence/output.txt new file mode 100644 index 000000000..152f36c85 --- /dev/null +++ b/docs/issues/open/2993-secrets-and-client-error-text/evidence/output.txt @@ -0,0 +1,63 @@ +### V1-V5 private tracker, sqlite +--- V1 announce, unregistered key +d14:failure reason141:Tracker authentication error: Failed to read key: TestPeerKey000000000000000000001, packages/tracker-core/src/authentication/service.rs:98:27e +--- V1 announce, no key +d14:failure reason108:Tracker authentication error: Missing authentication key, packages/http-core/src/services/announce.rs:308:27e +--- V1 announce, 14-character key +d14:failure reason110:Tracker authentication error: Invalid format for authentication key param: expected 32 alphanumeric characterse +--- V2 REST add 14-character key +Invalid URL: invalid auth key: string "ShortTestKey01", Invalid key length. Key must be have 32 chars, packages/tracker-core/src/authentication/handler.rs:108:46 [400] +--- V2 REST delete malformed key +Invalid auth key id param "BadTestKey" [400] +--- V3 REST wrong token in query +Unhandled rejection: Err { reason: "token not valid" } [500] +--- V4 REST generate key (reply not shown) +[200] +--- V5 REST duplicate key (sqlite) +{"key":"TestPeerKey000000000000000000002","valid_until":1795358731,"expiry_time":"2026-11-22 14:45:31 UTC"} [200] +Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, packages/tracker-core/src/databases/driver/sqlite/auth_key_store.rs:74:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500] +--- V5 REST malformed JSON +Failed to parse the request body as JSON: key must be a string at line 1 column 2 [400] +--- V5 REST unknown path +[404] +--- log: uri fields holding a test key or token +uri=/announce/ShortTestKey01?info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0 +uri=/announce/TestPeerKey000000000000000000001?info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0 +uri=/api/v1/key/BadTestKey +uri=/api/v1/stats?token=WrongTestToken0001 +--- log: lines holding the admin token sent in the header: 0 (the startup configuration dump prints it as ***) +--- log: 'Generated key' lines: 1; lines holding the generated key: 1 +2026-11-22T14:43:51.142622Z DEBUG request{method=POST uri=/api/v1/key/3600 version=HTTP/1.1}: torrust_tracker_core::authentication::key: Generated key: , valid for: 3600s seconds +--- log: lines for the 500 reply +2026-11-22T14:43:51.138915Z ERROR request{method=GET uri=/api/v1/stats?token=WrongTestToken0001 version=HTTP/1.1}: API: response latency_ms=0 status_code=500 Internal Server Error server_socket_addr=127.0.0.1:41212 service_binding=http://127.0.0.1:41212/ request_id=79d28710-5453-4595-b6a5-7aaf83e34e8c + +### V6 UDP, public listed tracker, sqlite +--- UDP announce, not whitelisted +tracker announce error: Tracker core whitelist error: The torrent: 0000000000000000000000000000000000000000, is not whitelisted, packages/tracker-core/src/whitelist/authorization.rs:61:23 +--- UDP announce, wrong connection id +tracker announce error: Connection cookie error: cookie value is expired: -0.0…010544892055975403, expected > 1795358512.2066972 +--- UDP 3-byte packet +error parsing request: SendableRequestParseError { message: "Couldn't parse action", opt_connection_id: None, opt_transaction_id: None } +--- HTTP announce, not whitelisted +d14:failure reason158:Tracker whitelist error: The torrent: 0000000000000000000000000000000000000000, is not whitelisted, packages/tracker-core/src/whitelist/authorization.rs:61:23e + +### V7 configuration errors +--- pw-int +Failed processing the configuration: invalid type: found signed int `987654321`, expected a string for key "default.core.database.password" in TOML source string, packages/configuration/src/v3_0_0/mod.rs:409:28, packages/configuration/src/lib.rs:258:56 +--- token-int +Failed processing the configuration: invalid type: found signed int `424242`, expected a string for key "default.http_api.access_tokens.admin" in TOML source string, packages/configuration/src/v3_0_0/mod.rs:409:28, packages/configuration/src/lib.rs:258:56 + +### V8 database server messages (MySQL 8.0, PostgreSQL 16) +--- mysql-bad (wrong credentials) +The MySQL query was malformed: error returned from database: 1045 (28000): Access denied for user 'db_user'@'172.17.0.1' (using password: YES), packages/tracker-core/src/databases/driver/mysql/schema_migrator.rs:86:41 +--- pg-bad (wrong credentials) +Failed to apply PostgreSQL schema migrations: while executing migrations: error returned from database: password authentication failed for user "db_user", packages/tracker-core/src/databases/driver/postgres/schema_migrator.rs:12:9 +--- mysql duplicate key +{"key":"TestPeerKey000000000000000000003","valid_until":1795358744,"expiry_time":"2026-11-22 14:45:44 UTC"} [200] +Unhandled rejection: Err { reason: "failed to add key: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key', packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs:72:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500] +log lines holding the key: 1 +2026-11-22T14:44:04.850783Z DEBUG request{method=POST uri=/api/v1/keys version=HTTP/1.1}: torrust_located_error: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key', packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs:72:2 +--- pg duplicate key +{"key":"TestPeerKey000000000000000000003","valid_until":1795358746,"expiry_time":"2026-11-22 14:45:46 UTC"} [200] +Unhandled rejection: Err { reason: "failed to add key: The PostgreSQL query was malformed: error returned from database: duplicate key value violates unique constraint \"keys_key_key\", packages/tracker-core/src/databases/driver/postgres/auth_key_store.rs:72:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500] +log lines holding the key: 0 diff --git a/docs/issues/open/2993-secrets-and-client-error-text/evidence/reproduce.sh b/docs/issues/open/2993-secrets-and-client-error-text/evidence/reproduce.sh new file mode 100755 index 000000000..946bc07ec --- /dev/null +++ b/docs/issues/open/2993-secrets-and-client-error-text/evidence/reproduce.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# Usage: run.sh . Reproduces the EPIC #2993 inventory cases. Test values only. +set -u +BIN=$1; W=$2; mkdir -p "$W"; cd "$W" || exit 1 +strip(){ sed 's/\x1b\[[0-9;]*m//g'; } +hdr='[metadata] +app = "torrust-tracker" +purpose = "configuration" +schema_version = "3.0.0" +[logging] +trace_filter = "debug" +trace_style = "full" +' +start(){ ("$BIN" --config-toml-path "$1" > "$2" 2>&1 & echo $! > "$2.pid"); for _ in $(seq 1 30); do curl -s -o /dev/null "http://127.0.0.1:$3/api/health_check" && return; sleep 1; done; } +stop(){ kill "$(cat "$1.pid")" 2>/dev/null; sleep 1; } +H='Authorization: Bearer TestAdminToken0001' +IH='info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0' + +echo "### V1-V5 private tracker, sqlite" +printf '%s[core]\nlisted = false\nprivate = true\n[core.database]\ndriver = "sqlite3"\npath = "%s/private.db"\n[http_api]\nbind_address = "127.0.0.1:41212"\n[http_api.access_tokens]\nadmin = "TestAdminToken0001"\n[[http_trackers]]\nbind_address = "127.0.0.1:47070"\n[health_check_api]\nbind_address = "127.0.0.1:41313"\n' "$hdr" "$W" > private.toml +rm -f private.db*; start private.toml private.log 41212 +echo "--- V1 announce, unregistered key"; curl -s "http://127.0.0.1:47070/announce/TestPeerKey000000000000000000001?$IH"; echo +echo "--- V1 announce, no key"; curl -s "http://127.0.0.1:47070/announce?$IH"; echo +echo "--- V1 announce, 14-character key"; curl -s "http://127.0.0.1:47070/announce/ShortTestKey01?$IH"; echo +echo "--- V2 REST add 14-character key"; curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{"key":"ShortTestKey01","seconds_valid":100}' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys +echo "--- V2 REST delete malformed key"; curl -s -X DELETE -H "$H" -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/key/BadTestKey +echo "--- V3 REST wrong token in query"; curl -s -w ' [%{http_code}]\n' "http://127.0.0.1:41212/api/v1/stats?token=WrongTestToken0001" +echo "--- V4 REST generate key (reply not shown)"; curl -s -o gen.json -X POST -H "$H" -w '[%{http_code}]\n' http://127.0.0.1:41212/api/v1/key/3600 +echo "--- V5 REST duplicate key (sqlite)"; for _ in 1 2; do curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{"key":"TestPeerKey000000000000000000002","seconds_valid":100}' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys; done +echo "--- V5 REST malformed JSON"; curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{bad' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys +echo "--- V5 REST unknown path"; curl -s -o /dev/null -X GET -H "$H" -w '[%{http_code}]\n' http://127.0.0.1:41212/api/v1/key/abc/extra +stop private.log +echo "--- log: uri fields holding a test key or token"; strip < private.log | grep -o -E 'uri=[^ ]*(TestPeerKey|ShortTestKey|BadTestKey|WrongTestToken)[^ ]*' | sort -u +echo "--- log: lines holding the admin token sent in the header: $(strip < private.log | grep -c TestAdminToken0001) (the startup configuration dump prints it as ***)" +GK=$(sed -E 's/.*"key":"([^"]+)".*/\1/' gen.json); echo "--- log: 'Generated key' lines: $(strip < private.log | grep -c 'Generated key'); lines holding the generated key: $(strip < private.log | grep -c "$GK")" +strip < private.log | grep 'Generated key' | sed "s/$GK//" | cut -c1-200 +echo "--- log: lines for the 500 reply"; strip < private.log | grep -E 'status_code=500' | head -1 | cut -c1-330 + +echo; echo "### V6 UDP, public listed tracker, sqlite" +printf '%s[core]\nlisted = true\nprivate = false\n[core.database]\ndriver = "sqlite3"\npath = "%s/public.db"\n[http_api]\nbind_address = "127.0.0.1:41212"\n[http_api.access_tokens]\nadmin = "TestAdminToken0001"\n[[udp_trackers]]\nbind_address = "127.0.0.1:46969"\n[[http_trackers]]\nbind_address = "127.0.0.1:47070"\n[health_check_api]\nbind_address = "127.0.0.1:41313"\n' "$hdr" "$W" > public.toml +rm -f public.db*; start public.toml public.log 41212 +python3 -I "$(dirname "$0")/udp_probe.py" 46969 +echo "--- HTTP announce, not whitelisted"; curl -s "http://127.0.0.1:47070/announce?$IH"; echo +stop public.log +echo "--- private mode refuses UDP:"; strip < private.log | grep -o 'Could not start UDP trackers.*' | head -1 + +echo; echo "### V7 configuration errors" +db='[core]\nlisted = false\nprivate = false\n[core.database]\ndriver = "mysql"\nhost = "127.0.0.1"\nuser = "db_user"\ndatabase = "torrust_tracker"\n' +printf "%s${db}port = 3306\npassword = 987654321\n" "$hdr" > pw-int.toml +printf "%s${db}port = 3306\npassword = \"x\"\n[http_api]\nbind_address = \"127.0.0.1:0\"\n[http_api.access_tokens]\nadmin = 424242\n" "$hdr" > token-int.toml +# shellcheck disable=SC2016 # the backticks are literal sed text +for n in pw-int token-int; do echo "--- $n"; timeout 20 "$BIN" --config-toml-path $n.toml 2>&1 | strip | grep '^Tracker startup failed' | sed 's/.*explicit configuration file `[^`]*`: //'; done + +echo; echo "### V8 database server messages (MySQL 8.0, PostgreSQL 16)" +docker run -d --rm --name ev2993-mysql -e MYSQL_ROOT_PASSWORD=TestDbPassword01 -e MYSQL_DATABASE=torrust_tracker -p 127.0.0.1:33061:3306 mysql:8.0 >/dev/null +docker run -d --rm --name ev2993-pg -e POSTGRES_PASSWORD=TestDbPassword01 -e POSTGRES_DB=torrust_tracker -p 127.0.0.1:54321:5432 postgres:16 >/dev/null +for _ in $(seq 1 60); do docker exec ev2993-mysql mysql -h127.0.0.1 -uroot -pTestDbPassword01 -e 'select 1' >/dev/null 2>&1 && break; sleep 2; done +for _ in $(seq 1 30); do docker exec ev2993-pg pg_isready -q && break; sleep 2; done; sleep 3 +mk(){ printf '%s[core]\nlisted = false\nprivate = true\n[core.database]\ndriver = "%s"\nhost = "127.0.0.1"\nport = %s\nuser = "%s"\npassword = "%s"\ndatabase = "torrust_tracker"\n[http_api]\nbind_address = "127.0.0.1:41212"\n[http_api.access_tokens]\nadmin = "TestAdminToken0001"\n[health_check_api]\nbind_address = "127.0.0.1:41313"\n' "$hdr" "$1" "$2" "$3" "$4" > "$5"; } +mk mysql 33061 db_user WrongTestPassword mysql-bad.toml; mk postgresql 54321 db_user WrongTestPassword pg-bad.toml +for n in mysql-bad pg-bad; do echo "--- $n (wrong credentials)"; timeout 40 "$BIN" --config-toml-path $n.toml 2>&1 | strip | grep '^Tracker startup failed' | sed 's/.*schema permissions: //'; done +mk mysql 33061 root TestDbPassword01 mysql.toml; mk postgresql 54321 postgres TestDbPassword01 pg.toml +for n in mysql pg; do echo "--- $n duplicate key"; start $n.toml $n.log 41212; for _ in 1 2; do curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{"key":"TestPeerKey000000000000000000003","seconds_valid":100}' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys; done; stop $n.log; echo "log lines holding the key: $(strip < $n.log | grep -c TestPeerKey000000000000000000003)"; strip < $n.log | grep TestPeerKey000000000000000000003 | cut -c1-330; done +docker stop ev2993-mysql ev2993-pg >/dev/null diff --git a/docs/issues/open/2993-secrets-and-client-error-text/evidence/udp_probe.py b/docs/issues/open/2993-secrets-and-client-error-text/evidence/udp_probe.py new file mode 100644 index 000000000..7023af9ea --- /dev/null +++ b/docs/issues/open/2993-secrets-and-client-error-text/evidence/udp_probe.py @@ -0,0 +1,22 @@ +# Usage: python3 -I udp_probe.py . Sends a BEP 15 connect, then an announce with the +# connection id, an announce with a wrong connection id, and a 3-byte packet; prints each reply's message. +import socket, struct, sys +a = ("127.0.0.1", int(sys.argv[1])) +s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +s.settimeout(4) +def rx(): + try: + return s.recvfrom(2048)[0] + except OSError as e: + return repr(e) +def ann(c): + return (struct.pack(">QII", c, 1, 7) + b"\x00" * 20 + b"-qB00000000000000001" + + struct.pack(">QQQiIIiH", 0, 0, 0, 0, 0, 0, -1, 6881)) +s.sendto(struct.pack(">QII", 0x41727101980, 0, 9), a) +r = rx() +cid = struct.unpack(">Q", r[8:16])[0] +for label, pkt in (("announce, not whitelisted", ann(cid)), ("announce, wrong connection id", ann(cid ^ 0xFF)), ("3-byte packet", b"\x00\x01\x02")): + s.sendto(pkt, a) + r = rx() + print("--- UDP " + label) + print(r[8:].decode(errors="replace") if isinstance(r, bytes) else r) diff --git a/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md b/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md new file mode 100644 index 000000000..44f3a661e --- /dev/null +++ b/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md @@ -0,0 +1,240 @@ +--- +doc-type: manual-verification-evidence +issue-spec: docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +last-updated-utc: "2026-11-22 14:50" +--- + +# Manual Verification Evidence + + + +## Purpose + +Record the reproductions behind the inventory of EPIC #2993: what a running tracker sends to +clients and writes to its log today. It is the baseline the sub-issues SI-A and SI-B repeat before +they change anything. Nothing here is a fix; every result shows current behavior. + +## Preserving Verification Artifacts + +- [`evidence/reproduce.sh`](evidence/reproduce.sh): the script that ran every request below. It + writes the tracker configuration files it uses, so they are in the script. + After the run it was edited to satisfy ShellCheck (`cd ... || exit 1`, loop variables renamed to + `_`, one `shellcheck disable` comment) and the private-mode UDP line it printed empty was dropped + from the output; the edited script was not run again. +- [`evidence/udp_probe.py`](evidence/udp_probe.py): the UDP requests of V6. +- [`evidence/output.txt`](evidence/output.txt): the complete output of the run. Two edits were made + to it: the scratch work directory is shown as ``, and the long run of zeros in the UDP + cookie value is shortened to `-0.0…0`. The generated key of V4 was replaced by + `` by the script itself. + +All keys, tokens and passwords are test values made up for this run (`TestPeerKey...`, +`TestAdminToken0001`, `TestDbPassword01`). The databases were local containers that were removed +after the run. + +The script is disposable. Python is used for the UDP probe because it needs only a few lines of +socket code and no build; the sub-issues promote the durable checks to Rust tests, as their +specifications say. The EPIC owner removes both scripts when the EPIC closes, unless a sub-issue +still uses them. + +## Environment and Prerequisites + +- Date and time (UTC): 2026-11-22 14:43 to 14:45. +- Artifact under test: `target/debug/torrust-tracker`, built with `cargo build --bin torrust-tracker` + (`rustc 1.100.0 (0ef1bc386 2026-11-09)`, the stable toolchain of the checkout) from a tree whose + code equals `develop` at `98fa27df2` (the branch adds documentation only; + `git diff --stat 98fa27df2 HEAD -- packages src Cargo.toml Cargo.lock console contrib` is empty). + This is before the SI-4 pull request of EPIC #2912 (#2991), so replies still hold source locations. +- Operating system / environment: Linux 7.0.0-43-generic; Docker 28.3.3; images `mysql:8.0` and + `postgres:16`; `curl`; `python3 -I`. +- Prerequisites and setup performed: none beyond the build. The script starts and stops the + trackers and the two database containers. +- Command: `bash evidence/reproduce.sh `. + +An earlier run on the same day used an older debug build (file date 2026-11-19, commit not +recorded) and gave the same texts. Only the run above is evidence. + +## Analysis + +Three configurations are used: a private tracker on SQLite with the HTTP tracker and the REST API +(V1 to V5); a public tracker with `listed = true`, because UDP trackers are not started in private +mode (V6); and trackers on MySQL and PostgreSQL (V8). V7 needs no running tracker: the +configuration fails to load. `trace_filter = "debug"` is set everywhere so that the DEBUG lines are +visible. + +## Verification Processes + +Each process lists the request and the observed result, copied from `evidence/output.txt`. + +### V1 - Peer key errors of the HTTP tracker (inventory A1) + +- `GET /announce/TestPeerKey000000000000000000001?...` (well formed, not registered): + + ```text + d14:failure reason141:Tracker authentication error: Failed to read key: TestPeerKey000000000000000000001, packages/tracker-core/src/authentication/service.rs:98:27e + ``` + +- `GET /announce?...` (no key): + + ```text + d14:failure reason108:Tracker authentication error: Missing authentication key, packages/http-core/src/services/announce.rs:308:27e + ``` + +- `GET /announce/ShortTestKey01?...` (14 characters): + + ```text + d14:failure reason110:Tracker authentication error: Invalid format for authentication key param: expected 32 alphanumeric characterse + ``` + +Conclusion: only the "not registered" case echoes the key. The malformed case already omits it and +does not say what is wrong with it (the length). + +### V2 - REST API key errors (inventory A2) + +- `POST /api/v1/keys` with `{"key":"ShortTestKey01","seconds_valid":100}`: + + ```text + Invalid URL: invalid auth key: string "ShortTestKey01", Invalid key length. Key must be have 32 chars, packages/tracker-core/src/authentication/handler.rs:108:46 [400] + ``` + +- `DELETE /api/v1/key/BadTestKey`: + + ```text + Invalid auth key id param "BadTestKey" [400] + ``` + +Conclusion: both replies echo the supplied key. + +### V3 - Request logs (inventory A3, A4) + +The `uri=` fields of the server log after V1, V2 and a `GET /api/v1/stats?token=WrongTestToken0001` +(which answered `Unhandled rejection: Err { reason: "token not valid" } [500]`): + +```text +uri=/announce/ShortTestKey01?info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0 +uri=/announce/TestPeerKey000000000000000000001?info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0 +uri=/api/v1/key/BadTestKey +uri=/api/v1/stats?token=WrongTestToken0001 +``` + +The other REST requests sent the admin token in the `Authorization: Bearer` header. The log held +0 lines with that token. + +Conclusion: a key in the path and a token in the query string are logged; a token in the header is +not. The log line for the 500 reply holds the status and the request id and no reason: + +```text +2026-11-22T14:43:51.138915Z ERROR request{method=GET uri=/api/v1/stats?token=WrongTestToken0001 version=HTTP/1.1}: API: response latency_ms=0 status_code=500 Internal Server Error server_socket_addr=127.0.0.1:41212 service_binding=http://127.0.0.1:41212/ request_id=79d28710-5453-4595-b6a5-7aaf83e34e8c +``` + +### V4 - Generated key in the log (inventory A5) + +`POST /api/v1/key/3600` answered 200. The log then held one `Generated key` line, and one line with +the generated key: + +```text +2026-11-22T14:43:51.142622Z DEBUG request{method=POST uri=/api/v1/key/3600 version=HTTP/1.1}: torrust_tracker_core::authentication::key: Generated key: , valid for: 3600s seconds +``` + +Conclusion: at DEBUG level the new key is written to the log in clear. + +### V5 - REST API database and rejection text (inventory B) + +- The same key added twice (SQLite); the second reply: + + ```text + Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, packages/tracker-core/src/databases/driver/sqlite/auth_key_store.rs:74:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500] + ``` + +- A malformed JSON body (`{bad`): + + ```text + Failed to parse the request body as JSON: key must be a string at line 1 column 2 [400] + ``` + +- `GET /api/v1/key/abc/extra`: 404 with an empty body. + +Conclusion: the reply for a database failure is the driver text; the JSON rejection is serde's text. + +### V6 - UDP and HTTP replies on a public listed tracker (inventory B) + +```text +--- UDP announce, not whitelisted +tracker announce error: Tracker core whitelist error: The torrent: 0000000000000000000000000000000000000000, is not whitelisted, packages/tracker-core/src/whitelist/authorization.rs:61:23 +--- UDP announce, wrong connection id +tracker announce error: Connection cookie error: cookie value is expired: -0.0…010544892055975403, expected > 1795358512.2066972 +--- UDP 3-byte packet +error parsing request: SendableRequestParseError { message: "Couldn't parse action", opt_connection_id: None, opt_transaction_id: None } +--- HTTP announce, not whitelisted +d14:failure reason158:Tracker whitelist error: The torrent: 0000000000000000000000000000000000000000, is not whitelisted, packages/tracker-core/src/whitelist/authorization.rs:61:23e +``` + +Conclusion: the UDP replies nest internal error names; the connection-id reply holds a value +derived from the server clock (`expected > 1795358512.2066972`); the parse reply holds a Rust type +name. + +Separately, the private configuration with a `[[udp_trackers]]` entry added logged: + +```text +2026-11-22T14:44:17.829867Z WARN complete_startup: torrust_tracker_lib::app: Could not start UDP trackers while in private mode. UDP is not safe for private trackers! +``` + +This run was a single command outside the script: +`timeout 8 target/debug/torrust-tracker --config-toml-path private-udp.toml`, where +`private-udp.toml` is the script's `private.toml` plus +`[[udp_trackers]]` / `bind_address = "127.0.0.1:46969"`. + +### V7 - Configuration errors echo the value (inventory A10) + +`password = 987654321` under `[core.database]`, then `admin = 424242` under +`[http_api.access_tokens]`: + +```text +Failed processing the configuration: invalid type: found signed int `987654321`, expected a string for key "default.core.database.password" in TOML source string, packages/configuration/src/v3_0_0/mod.rs:409:28, packages/configuration/src/lib.rs:258:56 +Failed processing the configuration: invalid type: found signed int `424242`, expected a string for key "default.http_api.access_tokens.admin" in TOML source string, packages/configuration/src/v3_0_0/mod.rs:409:28, packages/configuration/src/lib.rs:258:56 +``` + +Conclusion: a secret that TOML reads as an integer is printed on stderr and in the log. + +### V8 - Database server messages (inventory A11, A12) + +Wrong credentials (user `db_user`, a wrong password); the end of the startup error: + +```text +The MySQL query was malformed: error returned from database: 1045 (28000): Access denied for user 'db_user'@'172.17.0.1' (using password: YES), packages/tracker-core/src/databases/driver/mysql/schema_migrator.rs:86:41 +Failed to apply PostgreSQL schema migrations: while executing migrations: error returned from database: password authentication failed for user "db_user", packages/tracker-core/src/databases/driver/postgres/schema_migrator.rs:12:9 +``` + +The same key added twice, on MySQL: + +```text +Unhandled rejection: Err { reason: "failed to add key: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key', packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs:72:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500] +``` + +The MySQL tracker's log then held 1 line with the key (cut at 330 characters by the script): + +```text +2026-11-22T14:44:04.850783Z DEBUG request{method=POST uri=/api/v1/keys version=HTTP/1.1}: torrust_located_error: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key', packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs:72:2 +``` + +On PostgreSQL: + +```text +Unhandled rejection: Err { reason: "failed to add key: The PostgreSQL query was malformed: error returned from database: duplicate key value violates unique constraint \"keys_key_key\", packages/tracker-core/src/databases/driver/postgres/auth_key_store.rs:72:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500] +``` + +and its log held 0 lines with the key. + +Conclusion: the server message names the database user and the client address (A11). On MySQL the +duplicate-key message holds the peer key, in the reply and in a DEBUG log line; on PostgreSQL and +SQLite (V5) it does not (A12). An authentication failure is labelled "query was malformed". + +## Not Reproduced + +- A6 (the REST client prints the URL with the token in a transport error), A7 and A8 (plain + `String` types) were confirmed by reading the code, not by running it. The EPIC inventory gives + the lines. +- The expired-key reply was not requested: it needs a key past its lifetime. + +## Failures and Follow-up + +No request failed to run. The findings are the inventory of the EPIC; the sub-issues own the fixes. From f9d4fbe73742b3b3c74d7297e592280aa3e53f34 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:47:59 +0000 Subject: [PATCH 07/11] docs(issues): [#2993] reach the tracker database error through a failing persisted-downloads read in SI-B Co-Authored-By: Claude Fable 5.2 --- .../drafts/2993-si-b-client-error-text-policy/ISSUE.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md index f30b37935..4519130b4 100644 --- a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md +++ b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md @@ -91,7 +91,8 @@ The driver text in client replies and the wrong `InvalidQuery` label are bugs ag ## Regression Test Strategy - **Unit**: for each error family, a test at the mapping seam (`error_mapping.rs`, the REST adapters, the UDP `From` conversions) that builds the error with a source carrying a unique marker string and asserts the client text does not contain it. -- **Real boundary**: one test per protocol with the existing test servers asserting the reply for a forced database failure (a duplicate insert) holds no driver text, and that the server log holds the detail. +- **Real boundary, REST API**: a test with the existing REST test server asserting that the reply for a forced database failure (a duplicate key insert) holds no driver text, and that the server log holds the detail. +- **Real boundary, HTTP and UDP trackers**: a duplicate insert cannot reach them. An announce updates the in-memory repository and touches the database only in `load_downloads_metric_if_needed` (`packages/tracker-core/src/announce_handler.rs:196-205`), which reads the persisted download count when the torrent is not in memory; scrape reads it in `persisted_downloads.load_many`. So the test needs `core.tracker_policy.persistent_torrent_completed_stat = true`, an info-hash that is not in memory, and a read that fails (a database that was dropped or closed after start, or a test double of the persisted-downloads store that returns a database error). It asserts that the announce and scrape replies of each tracker hold no driver text. - **UDP**: tests that the connection-id error holds no clock value and the parse error holds no type name. - A helper that forbids known driver markers (`sqlx`, `error returned from database`, `constraint failed`, `Access denied`) in client text, used by the protocol tests. @@ -175,7 +176,7 @@ Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. | M1 | REST database failure | Add the same key twice through the REST API; read the reply and the server log | The reply follows the ADR and holds no driver text; the log holds the detail | TODO | `manual-verification-evidence.md` section V1 | | M2 | HTTP and UDP whitelist rejection | Announce a non-whitelisted info-hash over HTTP and over UDP | One clear sentence each, no nesting beyond what the ADR allows | TODO | `manual-verification-evidence.md` section V2 | | M3 | UDP connection id and short packet | Announce with a wrong connection id; send a 3-byte packet | No clock value; no type name | TODO | `manual-verification-evidence.md` section V3 | -| M4 | Database down | Stop the database of a MySQL or PostgreSQL tracker and send an announce that needs it, and a REST key request | The client text follows the ADR and names neither the user nor the host; the log holds them | TODO | `manual-verification-evidence.md` section V4 | +| M4 | Database down | On a MySQL or PostgreSQL tracker with `persistent_torrent_completed_stat = true`, stop the database and send an HTTP and a UDP announce for an info-hash that is not in memory, a scrape, and a REST key request | The client text follows the ADR and names neither the user nor the host; the log holds them | TODO | `manual-verification-evidence.md` section V4 | | M5 | REST bad token and bad JSON | Call the API with a wrong token and with a malformed JSON body | Text as the ADR decides, within v1's rules | TODO | `manual-verification-evidence.md` section V5 | Notes: manual verification is mandatory even when automated tests pass. Record the toolchain for every command, and create `manual-verification-evidence.md` from `docs/templates/MANUAL-VERIFICATION-EVIDENCE.md`. From da2944a505407f922ff7d6314e82c963c72898fd Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:48:32 +0000 Subject: [PATCH 08/11] docs(issues): [#2993] assign database errors that hold a secret to SI-A as inventory item A12 Co-Authored-By: Claude Fable 5.2 --- .../ISSUE.md | 26 ++++++++++++------- .../ISSUE.md | 6 ++--- .../EPIC.md | 7 ++--- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md index ddc349218..893be0bec 100644 --- a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md +++ b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md @@ -37,7 +37,7 @@ No error value keeps a peer authentication key or a REST API admin token, no err ## Background -The inventory of the EPIC (section "Inventory", items A1 to A11) lists every case found in the tree and reproduced on a running tracker. This issue owns the cases that are secrets: A1 to A8 and A10. A9 is a documentation fix that belongs here too. A11 (database server messages that name the user and host) is owned by SI-B. +The inventory of the EPIC (section "Inventory", items A1 to A11) lists every case found in the tree and reproduced on a running tracker. This issue owns the cases that are secrets: A1 to A8, A10 and A12. A9 is a documentation fix that belongs here too, and so is A12 (a database server message that holds the key). A11 (database server messages that name the user and host) is owned by SI-B. The commands and output of the reproductions are in the EPIC's [`manual-verification-evidence.md`](../../open/2993-secrets-and-client-error-text/manual-verification-evidence.md). The rule already exists: rule 3 of the errors ADR (`docs/adrs/20261118045443_errors_do_not_record_source_locations.md`) says a secret is never the offending input in a message and the error does not keep it, and the `handle-secrets` skill forbids secrets in logs and error text. The code predates both for the peer key, which is not a `SecretString` and prints in clear wherever it is formatted. The skill and the secrecy ADR cover configuration secrets only; they do not name the peer key or secrets carried in URLs. @@ -57,7 +57,8 @@ The maintainer's principle (2026-11-22): help the legitimate user as much as pos 5. **The type (A7).** `Key` gets a redacting `Debug` (`Key([REDACTED])`). Its `Display` stays only where the key is deliberately handed to its owner or persisted (the generate and add responses, the database store), and each remaining use is listed in the issue's evidence. `PeerKey`'s manual `Display` is checked the same way. Tests assert the redacted text without printing a test secret (`handle-secrets` skill). 6. **The REST client (A6).** The client strips the URL from `reqwest` errors (`without_url`) before it wraps them, and sends the token in the `Authorization: Bearer` header instead of the query string, which the server already accepts. The plain `String` token fields (A8) become `SecretString` where that is practical; if a field cannot change without a breaking change, record why. 7. **Configuration errors (A10).** A configuration error does not print the value of a secret option. For the `figment` error of a secret field (the database password, an access token), the loader reports the option path and the expected type with a fixed message and no value. How it is detected (the key path of the `figment` error against a list of secret paths, or reading the secret fields as strings and rejecting other types with a fixed message) is decided at implementation and recorded. -8. **Documentation (A9 and the gap).** Update the `handle-secrets` skill and the secrecy ADR (or add an ADR if the review prefers) with the rule for the peer key and for secrets carried in URLs; fix `docs/containers.md` so the examples use the `Authorization` header and the v3 network database fields instead of `?token=` and a `mysql://` `path`. +8. **Database errors that hold a secret (A12).** A database server message can contain the value that was written: adding a peer key that already exists makes MySQL answer `Duplicate entry '' for key 'keys.key'` (reproduced; see the EPIC evidence file, section V8). `databases::error::Error` keeps the `sqlx` source and prints it, so the key is in the retained error, in the REST reply and in a DEBUG log line. For the key store operations the error must not keep or print the driver message: map a unique-constraint violation to a variant of its own with a fixed message (for example "the key already exists"), using the driver's error kind (`sqlx::error::ErrorKind::UniqueViolation`), not its text; for any other driver error raised by a statement that binds a secret, keep the error kind and code and drop the message. Record at implementation which statements bind a secret (the `keys` table writes). What non-secret driver detail a client may see is SI-B. +9. **Documentation (A9 and the gap).** Update the `handle-secrets` skill and the secrecy ADR (or add an ADR if the review prefers) with the rule for the peer key and for secrets carried in URLs; fix `docs/containers.md` so the examples use the `Authorization` header and the v3 network database fields instead of `?token=` and a `mysql://` `path`. ### Out of Scope @@ -91,6 +92,7 @@ This is substantively a bug (a secret printed to a client and to logs), so it fo - **Log redaction**: a unit test of the shared redaction function over the URI shapes (`/announce/?...`, `/scrape/`, `/api/v1/key/?token=`, a bare `?token=`, a URI with no secret, a percent-encoded key). A test through each server captures the tracing output with a unique test key and token and asserts neither appears in it. - **Generated key**: a test that captures the debug output of key generation. - **Configuration**: a test that loads a configuration with a numeric database password and a numeric access token and asserts the error contains the option path and not the value. +- **Database errors**: a test that adds the same key twice and asserts that the retained error (`Display`, `Debug` and its source chain), the REST reply and the captured log hold no key. It must run against MySQL, the driver that prints the value, so it belongs with the database-backed driver tests; the SQLite and PostgreSQL runs assert the same thing and guard against a future driver message change. - **REST client**: a test that forces a transport error and asserts the text holds neither the URL query nor the token. - **Real boundary**: the existing protocol tests (`packages/axum-http-server/tests`, the REST API server tests) get assertions that a failure reason and a REST error hold no key. @@ -109,18 +111,19 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T7 | TODO | Configuration errors | A10: no secret value in a configuration error. | | T8 | TODO | Documentation | `handle-secrets` skill, the ADR change, `docs/containers.md`. | | T9 | TODO | Final recheck | The baseline reproduction repeated after the last production change. | +| T7b | TODO | Database errors | A12: the key store errors keep and print no driver message that holds a key; MySQL duplicate-key regression test. | ## Commit Points | Task | Coherent change set | Commit policy | | --- | --- | --- | -| T2 | The red tests | Commit after focused validation and required review. | -| T3 | Key errors, messages and REST responses | Commit after focused validation and required review. | -| T4 | `Key` and `PeerKey` formatting | Commit after focused validation and required review. | -| T5 | Redaction function and the three servers | Commit after focused validation and required review. | -| T6 | REST client | Commit after focused validation and required review. | -| T7 | Configuration errors | Commit after focused validation and required review. | -| T8 | Skill, ADR and documentation | Commit after focused validation and required review. | +| T3 | Key errors, messages and REST responses, with their tests | Commit after the red and green runs and the recorded test-design review. | +| T4 | `Key` and `PeerKey` formatting | Commit after the red and green runs and the recorded test-design review. | +| T5 | Redaction function and the three servers | Commit after the red and green runs and the recorded test-design review. | +| T6 | REST client | Commit after the red and green runs and the recorded test-design review. | +| T7 | Configuration errors, with their tests | Commit after the red and green runs and the recorded test-design review. | +| T7b | Database errors that hold a key, with the MySQL regression test | Commit after the red and green runs and the recorded test-design review. | +| T8 | Skill, ADR and documentation | Commit after the red and green runs and the recorded test-design review. | ## Progress Tracking @@ -156,6 +159,8 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. - [ ] `linter all` exits with code `0` - [ ] Relevant tests pass - [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` +- [ ] AC9: Adding a peer key that already exists leaves no key in the retained error, the REST reply or the log, on MySQL, PostgreSQL and SQLite. +- [ ] AC10: Each test increment has a recorded test-design review, and the maintainer checkpoint after the last increment is recorded in the progress log. - [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior ## Verification Plan @@ -181,6 +186,7 @@ Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. Notes: manual verification is mandatory even when automated tests pass. Record the toolchain for every command, and create `manual-verification-evidence.md` from `docs/templates/MANUAL-VERIFICATION-EVIDENCE.md`. +| M7 | Duplicate key on MySQL | On a tracker with a MySQL database and `trace_filter = "debug"`, add the same key twice through the REST API; read the reply and the log | Neither holds the key | TODO | `manual-verification-evidence.md` section V7 | ### Disposable Verification Scripts None planned. The UDP and HTTP probes of the EPIC session were ad-hoc commands; promote any durable check to a Rust test. @@ -200,6 +206,8 @@ None planned. The UDP and HTTP probes of the EPIC session were ad-hoc commands; ## Risks and Trade-offs +| AC9 | TODO | {test/log/PR link} | +| AC10 | TODO | {test/log/PR link} | - **Redacting the URI loses debugging value.** An operator cannot see which key a client used. Mitigation: if correlation is needed, log a short stable fingerprint (a truncated hash) instead of the key; decide in review. - **Conflict with SI-4 (#2916).** Both rewrite the tracker-core key errors. Mitigation: start after SI-4 merges. - **A breaking change in a public error enum.** `UnableToReadKey` loses a field. Mitigation: tracker-core is not published yet, and the enum is `#[non_exhaustive]`. diff --git a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md index 4519130b4..acc589ce8 100644 --- a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md +++ b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md @@ -72,7 +72,7 @@ The maintainer's decisions (2026-11-22): the text for database failures is decid - Source locations (EPIC #2912). - REST status codes and the response shape of API v1: v1 is additive-only, and correct codes and a structured error body are API v2 (EPIC #144). This issue changes v1 text only. The ADR should say how the v2 error model relates to this policy so the two do not diverge. - The general error-event contract (draft `docs/issues/drafts/generalize-error-events/`). This issue changes only what the existing UDP error event carries, if the ADR decides it must change. -- Server-side log content: driver text in a server log is correct and stays. +- Server-side log content: non-secret driver text in a server log is correct and stays. A driver message that holds a secret (EPIC item A12, the MySQL duplicate-key message) is removed from the error, the reply and the log by SI-A. - Log levels for client errors (#1166). ## Architectural Decisions @@ -104,8 +104,8 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | --- | --- | --- | --- | | T1 | TODO | Draft the ADR | The decisions listed in the scope, with the options and the reasons; a table of every current client text and its proposed text. Its own pull request. | | T2 | TODO | Maintainer accepts the ADR | No code before this. Update this specification with the approved texts. | -| T3 | TODO | Baseline reproduction and red tests | Evidence recorded; red output recorded. | -| T4 | TODO | Database errors and the server-side event | Driver text stays in the source and the log; the `tracing` event exists; the `InvalidQuery` label is right. | +| T3 | TODO | Baseline reproduction and test plan | Evidence recorded; the list of tests per behavior area (T4 to T7) written. The tests are written red-then-green inside each area, with a recorded test-design review after each passing increment. | +| T4 | TODO | Database errors and the server-side event | Non-secret driver text stays in the source and the log (SI-A has already removed driver messages that hold a secret); the `tracing` event exists; the `InvalidQuery` label is right. | | T5 | TODO | HTTP tracker text | As the ADR decides. | | T6 | TODO | UDP tracker text and the error event | As the ADR decides. | | T7 | TODO | REST API text | As the ADR decides, within v1's additive-only rule. | diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md index a9840af22..288a15c60 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -63,6 +63,7 @@ Paths are relative to the repository root. Every item was read in the code, and | A9 | `docs/containers.md` (lines about 492-562) | the documentation teaches `?token=` URLs and a `mysql://user:password@host` URL in config and environment | readers; the request log then records the token. The MySQL example (`path = "mysql://db_user:...@mysql:3306/torrust_tracker"`) is also stale: the v3 schema refuses `path` for a network database (`packages/configuration/src/v3_0_0/database.rs:203-204`) | | A10 | `packages/configuration/src/v3_0_0/mod.rs:409` (`figment.extract()`), wrapped by `Error::ConfigError` (`packages/configuration/src/lib.rs:335`) | a configuration error prints the offending value, so a numeric database password or access token is printed (details below) | the operator: stderr and the server log | | A11 | `packages/tracker-core/src/databases/error.rs:111-135` (`From<(SqlxError, Driver)>` keeps the `sqlx` text) | a database server message names the database user and the client address (details below). Not a secret; owned by SI-B | the operator today; a client wherever driver text is forwarded | +| A12 | `packages/tracker-core/src/databases/error.rs:111-135` (the `sqlx` source is kept and printed), reached from `packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs` | a database server message can contain a secret: adding a peer key that already exists makes MySQL answer `Duplicate entry '' for key 'keys.key'`, and the error keeps and prints it. PostgreSQL (`duplicate key value violates unique constraint "keys_key_key"`) and SQLite (`UNIQUE constraint failed: keys.key`) do not print the value | the REST administrator (500 reply), and the server log at DEBUG through the `torrust_located_error` event | Checked and found safe, so that the spec does not redo it: @@ -147,7 +148,7 @@ There is no ADR on peer-key handling, request-log redaction or client-facing err SI-A, secrets (a bug class): -- Remove every cluster of A1 to A8 and A10 (a configuration error must not echo a secret value, for example by building the figment error message without the offending value or by rejecting a non-string secret with a fixed message): no error keeps or prints a key or token; request logging of both servers redacts the key path segment and the `token` query parameter (the maintainer's decision, 2026-11-22); the generated key is not logged in clear; the REST client strips the URL from transport errors; `Key` gets redacting `Debug` and no clear `Display` where a clear value is not needed. +- Remove every cluster of A1 to A8, A10 and A12 (A12: a database error must not keep or print a driver message that holds a secret) (a configuration error must not echo a secret value, for example by building the figment error message without the offending value or by rejecting a non-string secret with a fixed message): no error keeps or prints a key or token; request logging of both servers redacts the key path segment and the `token` query parameter (the maintainer's decision, 2026-11-22); the generated key is not logged in clear; the REST client strips the URL from transport errors; `Key` gets redacting `Debug` and no clear `Display` where a clear value is not needed. - A rule for the peer key in the `handle-secrets` skill (and an ADR or an update of the secrecy ADR, decided in SI-A), and a fix of the `docs/containers.md` examples (A9). - Tests that assert redaction without printing the secret, and a regression test per leak. @@ -238,7 +239,7 @@ Recorded 2026-11-22 in the session that drafted this specification: 1. The work is an EPIC with two sub-issues (SI-A secrets, SI-B client text), because the first is a bug class and the second a design question that needs an ADR. 2. Request-URI logging is in scope: redact the peer key and the `token` query parameter in both the HTTP tracker and the REST API. 3. The EPIC is standalone, linked from EPIC #2912 and SI-4, not a sub-issue of it. -4. What a client receives for database failures is decided in the SI-B ADR, not fixed in this specification. The user and host in database server messages (A11) are an operator-side exposure and a client-text question, so SI-B owns them. +4. What a client receives for database failures is decided in the SI-B ADR, not fixed in this specification. The user and host in database server messages (A11) are an operator-side exposure and a client-text question, so SI-B owns them. A database server message that holds a secret (A12) is a secret leak, so SI-A owns it: SI-A makes the retained error, the reply and the log free of the secret, and SI-B then decides what non-secret detail a client may see. 5. Principle for client text about a secret: help the legitimate user as much as possible without revealing the secret. The project is public, so an attacker can read the source, and security must not rely on hiding how the tracker works. A message may therefore state any fact about the client's own input (its length, that it holds a character outside the allowed set) and the state of the credential (not registered, expired), but never the secret itself. SI-B applies the same principle to the other error families. @@ -267,7 +268,7 @@ The REST API messages for an uploaded key (A2) follow the same pattern: the leng - [ ] Every completed subissue includes post-implementation acceptance criteria review. - [ ] Every completed subissue includes an implementation completion review. - [ ] Documentation and governance updates are included when required. -- [ ] No error value keeps a peer key or an admin token, and no message prints one (A1, A2, A6, A10). +- [ ] No error value keeps a peer key or an admin token, and no message prints one (A1, A2, A6, A10, A12). - [ ] No log line written for a real request on the HTTP tracker or the REST API holds a peer key or an admin token, shown on a running tracker (A3, A4, A5). - [ ] The `handle-secrets` skill, and an ADR, state how the peer key is handled (A7), and `docs/containers.md` no longer teaches a pattern that logs a secret (A9). - [ ] An accepted ADR defines the client text policy, and the replies of the HTTP tracker, the UDP tracker and the REST API follow it, shown on a running tracker. From 9a3491f844d1917d5b5a3bf3f79f62ed4fb6f581 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:49:05 +0000 Subject: [PATCH 09/11] docs(issues): [#2993] require the incremental test-design review and maintainer checkpoint in both sub-issue drafts Co-Authored-By: Claude Fable 5.2 --- .../ISSUE.md | 17 ++++++++++------- .../2993-si-b-client-error-text-policy/ISSUE.md | 14 +++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md index 893be0bec..1cb6cab78 100644 --- a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md +++ b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md @@ -98,20 +98,23 @@ This is substantively a bug (a secret printed to a client and to logs), so it fo ## Implementation Plan +Test-development loop (required by `docs/templates/ISSUE.md`, "Commit Points", and the `create-issue` skill): the red tests are not written as one batch. Use the `write-unit-test` skill and work one behavior area at a time, in the order of the commit points below. For each area: write the smallest behavior-focused test, record its red output, make the production change, record the green output, then perform and record an explicit test-design review before starting the next area. The review uses the prose-first Arrange-Act-Assert comparison (write temporary prose for each section, refactor until the code expresses it, remove redundant prose) and confirms that the test exposes the one causal initial-state difference, that its fixture owns only incidental mechanics, and that the production Act and the independently specified expected result stay visible. Record each review in the task's evidence. Commit each reviewed increment before the next one. After the last increment, stop for maintainer review before final verification, the final commit and the pull request. + Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | ID | Status | Task | Notes / Expected Output | | --- | --- | --- | --- | | T1 | TODO | Baseline reproduction | The EPIC cases A1 to A6 and A10 reproduced on the starting commit; evidence recorded. Starts after SI-4 (#2916) merges. | -| T2 | TODO | Red tests | Unit tests for the errors, the redaction function, the generated key, the configuration error and the REST client; protocol assertions; red output recorded. | +| T2 | TODO | Test plan | The list of tests per behavior area (T3 to T8), written before the first one. The tests themselves are written red-then-green inside each area, with a recorded test-design review after each passing increment. | | T3 | TODO | Key errors and messages | A1, A2 and the new peer-key messages; the REST responses stop echoing the key. | | T4 | TODO | `Key` type | Redacting `Debug`; remaining `Display` uses listed and justified. | | T5 | TODO | Request logging | The shared redaction function; custom `MakeSpan` and `on_request` in the three servers; the generated-key log lines removed. | | T6 | TODO | REST client | `without_url`, header token, `SecretString` where practical. | | T7 | TODO | Configuration errors | A10: no secret value in a configuration error. | +| T7b | TODO | Database errors | A12: the key store errors keep and print no driver message that holds a key; MySQL duplicate-key regression test. | | T8 | TODO | Documentation | `handle-secrets` skill, the ADR change, `docs/containers.md`. | +| T8b | TODO | Maintainer checkpoint | Stop for maintainer review after the last test increment, before final verification, the final commit and the pull request. | | T9 | TODO | Final recheck | The baseline reproduction repeated after the last production change. | -| T7b | TODO | Database errors | A12: the key store errors keep and print no driver message that holds a key; MySQL duplicate-key regression test. | ## Commit Points @@ -156,11 +159,11 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. - [ ] AC6: A transport error of the REST client holds neither the token nor the URL query. - [ ] AC7: A configuration error for a secret option names the option and the expected type and does not print the value. - [ ] AC8: The `handle-secrets` skill and an ADR state how the peer key and URL-borne secrets are handled, and `docs/containers.md` no longer teaches `?token=` or a `mysql://` `path`. +- [ ] AC9: Adding a peer key that already exists leaves no key in the retained error, the REST reply or the log, on MySQL, PostgreSQL and SQLite. +- [ ] AC10: Each test increment has a recorded test-design review, and the maintainer checkpoint after the last increment is recorded in the progress log. - [ ] `linter all` exits with code `0` - [ ] Relevant tests pass - [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` -- [ ] AC9: Adding a peer key that already exists leaves no key in the retained error, the REST reply or the log, on MySQL, PostgreSQL and SQLite. -- [ ] AC10: Each test increment has a recorded test-design review, and the maintainer checkpoint after the last increment is recorded in the progress log. - [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior ## Verification Plan @@ -183,10 +186,10 @@ Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. | M4 | Generated key | `POST /api/v1/key/3600` with `trace_filter = "debug"` | The log has no `Generated key` line with the key | TODO | `manual-verification-evidence.md` section V4 | | M5 | Configuration error | Start the tracker with `password = 987654321` and with a numeric access token | The error names the option and the expected type, not the number | TODO | `manual-verification-evidence.md` section V5 | | M6 | REST client | Point the client at a closed port with a token | The error text holds no token | TODO | `manual-verification-evidence.md` section V6 | +| M7 | Duplicate key on MySQL | On a tracker with a MySQL database and `trace_filter = "debug"`, add the same key twice through the REST API; read the reply and the log | Neither holds the key | TODO | `manual-verification-evidence.md` section V7 | Notes: manual verification is mandatory even when automated tests pass. Record the toolchain for every command, and create `manual-verification-evidence.md` from `docs/templates/MANUAL-VERIFICATION-EVIDENCE.md`. -| M7 | Duplicate key on MySQL | On a tracker with a MySQL database and `trace_filter = "debug"`, add the same key twice through the REST API; read the reply and the log | Neither holds the key | TODO | `manual-verification-evidence.md` section V7 | ### Disposable Verification Scripts None planned. The UDP and HTTP probes of the EPIC session were ad-hoc commands; promote any durable check to a Rust test. @@ -203,11 +206,11 @@ None planned. The UDP and HTTP probes of the EPIC session were ad-hoc commands; | AC6 | TODO | {test/log/PR link} | | AC7 | TODO | {test/log/PR link} | | AC8 | TODO | {test/log/PR link} | +| AC9 | TODO | {test/log/PR link} | +| AC10 | TODO | {test/log/PR link} | ## Risks and Trade-offs -| AC9 | TODO | {test/log/PR link} | -| AC10 | TODO | {test/log/PR link} | - **Redacting the URI loses debugging value.** An operator cannot see which key a client used. Mitigation: if correlation is needed, log a short stable fingerprint (a truncated hash) instead of the key; decide in review. - **Conflict with SI-4 (#2916).** Both rewrite the tracker-core key errors. Mitigation: start after SI-4 merges. - **A breaking change in a public error enum.** `UnableToReadKey` loses a field. Mitigation: tracker-core is not published yet, and the enum is `#[non_exhaustive]`. diff --git a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md index acc589ce8..463821233 100644 --- a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md +++ b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md @@ -98,6 +98,8 @@ The driver text in client replies and the wrong `InvalidQuery` label are bugs ag ## Implementation Plan +Test-development loop (required by `docs/templates/ISSUE.md`, "Commit Points", and the `create-issue` skill): the red tests are not written as one batch. Use the `write-unit-test` skill and work one behavior area at a time, in the order of the commit points below (T4 to T7). For each area: write the smallest behavior-focused test, record its red output, make the production change, record the green output, then perform and record an explicit test-design review before starting the next area. The review uses the prose-first Arrange-Act-Assert comparison (write temporary prose for each section, refactor until the code expresses it, remove redundant prose) and confirms that the test exposes the one causal initial-state difference, that its fixture owns only incidental mechanics, and that the production Act and the independently specified expected result stay visible. Record each review in the task's evidence. Commit each reviewed increment before the next one. After the last increment, stop for maintainer review before final verification, the final commit and the pull request. + Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | ID | Status | Task | Notes / Expected Output | @@ -110,6 +112,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T6 | TODO | UDP tracker text and the error event | As the ADR decides. | | T7 | TODO | REST API text | As the ADR decides, within v1's additive-only rule. | | T8 | TODO | Skill and documentation | `handle-errors-in-code`; any documented example reply. | +| T8b | TODO | Maintainer checkpoint | Stop for maintainer review after the last test increment, before final verification, the final commit and the pull request. | | T9 | TODO | Final recheck | The baseline reproduction repeated after the last production change. | ## Commit Points @@ -117,11 +120,10 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | Task | Coherent change set | Commit policy | | --- | --- | --- | | T1 | The ADR and the index entry | Commit after focused validation and required review. | -| T3 | The red tests | Commit after focused validation and required review. | -| T4 | Database error mapping and the tracing event | Commit after focused validation and required review. | -| T5 | HTTP tracker text | Commit after focused validation and required review. | -| T6 | UDP tracker text and event | Commit after focused validation and required review. | -| T7 | REST API text | Commit after focused validation and required review. | +| T4 | Database error mapping and the tracing event | Commit after the red and green runs and the recorded test-design review. | +| T5 | HTTP tracker text | Commit after the red and green runs and the recorded test-design review. | +| T6 | UDP tracker text and event | Commit after the red and green runs and the recorded test-design review. | +| T7 | REST API text | Commit after the red and green runs and the recorded test-design review. | | T8 | Skill and documentation | Commit after focused validation and required review. | ## Progress Tracking @@ -154,6 +156,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. - [ ] AC4: The UDP connection-id error holds no server clock value, and the UDP parse error holds no Rust type name. - [ ] AC5: Every changed client text is listed, old and new, in this specification and was approved before the change. - [ ] AC6: The `handle-errors-in-code` skill states the policy. +- [ ] AC7: Each test increment has a recorded test-design review, and the maintainer checkpoint after the last increment is recorded in the progress log. - [ ] `linter all` exits with code `0` - [ ] Relevant tests pass - [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` @@ -195,6 +198,7 @@ A short UDP probe (connect, announce, raw packet) is needed for M2 and M3, becau | AC4 | TODO | {test/log/PR link} | | AC5 | TODO | {test/log/PR link} | | AC6 | TODO | {test/log/PR link} | +| AC7 | TODO | {test/log/PR link} | ## Risks and Trade-offs From 27ea49a2f064872427ba9664c0436ffc2add4c00 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 14:59:48 +0000 Subject: [PATCH 10/11] docs(pr-reviews): [#2994] record review round 2 Co-Authored-By: Claude Fable 5.2 --- docs/pr-reviews/pr-2994-review/PR-REVIEW.md | 75 +++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/docs/pr-reviews/pr-2994-review/PR-REVIEW.md b/docs/pr-reviews/pr-2994-review/PR-REVIEW.md index 48314f84d..07516ae1f 100644 --- a/docs/pr-reviews/pr-2994-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2994-review/PR-REVIEW.md @@ -43,6 +43,8 @@ deliver findings through GitHub and have no repository-artifact obligation. Round 1 covers review 6012624473 (Copilot, COMMENTED, submitted 2026-11-22T14:05:07Z, a lite review) with seven inline comments on `docs/issues/open/2993-secrets-and-client-error-text/EPIC.md`. Its body is an overview with no finding beyond the inline comments; its warning that the full agentic review did not start is context and makes no row. The comments carry no `[Severity]` bracket. The audit severity scale has no medium or low level, so this audit maps the overview's `Medium severity` badge (F1 to F3) to `Minor (inferred)` and its `Low severity` badge (F4 to F7) to `Nit (inferred)`, as the PR #2990 audit does. The seven comments are three texts: F2 and F3 repeat F1 on other lines, and F6 and F7 repeat F5, so they are re-raises with their own rows. +Round 2 covers review 6012831750 (Copilot, COMMENTED, submitted 2026-11-22T14:40:22Z, a balanced review) with five inline comments, each with a `[Severity][FindingId]` first line. Its body is a verdict ("Changes recommended") and a list that repeats the five inline findings and the seven threads resolved since round 1; it makes no row. Copilot's IDs F8, F9 and F13 do not collide with F1 to F7 and are kept. Copilot used `F12` for two different findings: the first in source order (comment 4658541296, the SI-A draft) keeps F12, and the other (comment 4658541369, the EPIC evidence) is F14 here, the first number after the highest ID in use, with Copilot's ID in its detail entry. The rows are in source order. Severities are the comments' brackets. The overview's badges (Medium for F8, Low for the other four) differ from the brackets and are not used. + | Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | | ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | | F1 | review-finding:pr-2994-f1 | Copilot | Minor (inferred) | documentation | ORIGINAL | FIXED | RESOLVED | @@ -52,6 +54,11 @@ Round 1 covers review 6012624473 (Copilot, COMMENTED, submitted 2026-11-22T14:05 | F5 | review-finding:pr-2994-f5 | Copilot | Nit (inferred) | documentation | ORIGINAL | NO_ACTION | SUPERSEDED | | F6 | review-finding:pr-2994-f6 | Copilot | Nit (inferred) | documentation | RE_RAISE_OF:F5 | NO_ACTION | SUPERSEDED | | F7 | review-finding:pr-2994-f7 | Copilot | Nit (inferred) | documentation | RE_RAISE_OF:F5 | NO_ACTION | SUPERSEDED | +| F8 | review-finding:pr-2994-f8 | Copilot | Major | security | ORIGINAL | FIXED | RESOLVED | +| F12 | review-finding:pr-2994-f12 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | +| F9 | review-finding:pr-2994-f9 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | +| F13 | review-finding:pr-2994-f13 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | +| F14 | review-finding:pr-2994-f14 | Copilot | Minor | documentation | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -146,11 +153,79 @@ Round 1 covers review 6012624473 (Copilot, COMMENTED, submitted 2026-11-22T14:05 - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658464189 +### F8 - A database error can hold a secret and no sub-issue owns its removal + +- PR number: 2994 +- Source review ID: 6012831750 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658541274 +- Concern: Driver diagnostics can contain secrets: adding an existing peer key to MySQL's unique `keys.key` column produces `Duplicate entry '' ...`, and `databases/error.rs:130-133` keeps that source. Copilot asks to assign the sanitization of secret-bearing database errors to SI-A, to add a MySQL duplicate-key regression that covers retained errors, replies and logs, and to make SI-B's Out of Scope item and T4 keep only non-secret driver detail. +- Solution: The case is inventory item A12, owned by SI-A. It was reproduced on MySQL 8.0 (section V8 of `docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md`): the 500 reply and one DEBUG `torrust_located_error` log line hold the key; the PostgreSQL reply and log do not, and the SQLite reply of V5 does not. EPIC: row A12 in the A table, the In Scope item of SI-A, the acceptance criterion and a sentence in maintainer decision 4. SI-A draft: In Scope item 8, a MySQL regression test in the Regression Test Strategy, task T7b, AC9 and manual scenario M7. SI-B draft: the Out of Scope bullet and T4 say that non-secret driver text stays and that SI-A removes messages that hold a secret. The same commit also holds lines of F12 and F13 (see those entries). The background paragraph of the SI-A draft still opens with "items A1 to A11" while it names A12 two sentences later; this was seen during this audit and is not changed in this round. +- Current-tree verification: `git show HEAD:docs/issues/open/2993-secrets-and-client-error-text/EPIC.md | grep -n 'A12'` finds lines 66 (table row), 151 (In Scope), 242 (decision 4) and 271 (acceptance criterion); the same grep on the SI-A draft finds lines 40, 60 (In Scope item 8) and 114 (T7b), with the regression test on line 95, AC9 on line 162 and M7 on line 189; on the SI-B draft, lines 75 (Out of Scope) and 110 (T4) say "non-secret driver text". The evidence file's V8 quotes the MySQL reply and the DEBUG log line with `Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key'` and says the PostgreSQL log held 0 lines with the key. +- Resolution reference: `docs(issues): [#2993] assign database errors that hold a secret to SI-A as inventory item A12` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658603687 + +### F12 - The SI-A draft does not require the incremental test-design review + +- PR number: 2994 +- Source review ID: 6012831750 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658541296 +- Concern: T2 of the SI-A draft batches every regression test and records only red output; nothing requires the recorded prose-first Arrange-Act-Assert review after each passing increment, which `docs/templates/ISSUE.md:119-128` and `create-issue/SKILL.md:180-189` require. Copilot asks for incremental red/green work, the design-review evidence and an explicit maintainer checkpoint. +- Solution: The Implementation Plan of the SI-A draft has a "Test-development loop" paragraph (the `write-unit-test` skill, one behavior area at a time, a recorded test-design review before the next area, a commit per reviewed increment, a stop for maintainer review after the last increment). T2 is a test plan, T8b is the maintainer checkpoint, and AC10 requires the recorded reviews and the checkpoint. Not every line of this fix is in the commit named below. When the round's changes were split into commits by hunk, these lines of the SI-A draft landed in `docs(issues): [#2993] assign database errors that hold a secret to SI-A as inventory item A12` because they are next to A12 lines: the AC10 line, the AC10 row of the Acceptance Verification table, and the reworded cells of the Commit Points table (with the removal of its T2 row). +- Current-tree verification: `git show HEAD:docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md` has the paragraph on line 101, T2 "Test plan" on line 108, T8b on line 116, AC10 on line 163 and its Acceptance Verification row on line 210. `git show -U0` of the commit named below shows the paragraph, the T2 row and the T8b row for this file; `git show -U0` of the A12 commit shows the AC10 line, the AC10 row and the Commit Points cells. +- Resolution reference: `docs(issues): [#2993] require the incremental test-design review and maintainer checkpoint in both sub-issue drafts` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658603862 + +### F9 - A duplicate insert cannot reach the database-error reply of the HTTP and UDP trackers + +- PR number: 2994 +- Source review ID: 6012831750 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658541332 +- Concern: The announce handlers of the HTTP and UDP trackers update the in-memory repository and only read persisted download counts (`announce_handler.rs:184-204`); a duplicate-key insert is a REST operation. Copilot asks the SI-B draft to specify a failing persisted-downloads read for the two tracker protocols, with persistence enabled and a torrent absent from memory. +- Solution: The Regression Test Strategy of the SI-B draft has one item for the REST boundary (a duplicate key insert) and one for the HTTP and UDP trackers: `core.tracker_policy.persistent_torrent_completed_stat = true`, an info-hash that is not in memory, and a read that fails in `load_downloads_metric_if_needed` (announce) or `persisted_downloads.load_many` (scrape). Manual scenario M4 names the same setting and an info-hash that is not in memory. +- Current-tree verification: `git show HEAD:docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md` has the two items on lines 94 and 95 and M4 on line 182; `git show HEAD:packages/tracker-core/src/announce_handler.rs | grep -n load_downloads_metric_if_needed` finds the call on line 189 and the function on line 196. +- Resolution reference: `docs(issues): [#2993] reach the tracker database error through a failing persisted-downloads read in SI-B` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658603993 + +### F13 - The SI-B draft does not require the incremental test-design review + +- PR number: 2994 +- Source review ID: 6012831750 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658541352 +- Concern: The SI-B plan records baseline and red evidence and then goes through the production changes, without the prose-first Arrange-Act-Assert design review after each passing test increment that `docs/templates/ISSUE.md:119-128` and `create-issue/SKILL.md:180-189` require. Copilot asks for the incremental red/green loop, the recorded design review before the next behavior area and a final maintainer checkpoint. +- Solution: The Implementation Plan of the SI-B draft has the same "Test-development loop" paragraph as the SI-A draft, for areas T4 to T7. T3 is "Baseline reproduction and test plan", T8b is the maintainer checkpoint, the Commit Points cells name the red and green runs and the recorded review, and AC7 requires the recorded reviews and the checkpoint. Not every line of this fix is in the commit named below. When the round's changes were split into commits by hunk, the reworded T3 row of the SI-B task table ("Baseline reproduction and test plan") landed in `docs(issues): [#2993] assign database errors that hold a secret to SI-A as inventory item A12`, because it is next to the T4 row that the A12 change touches. +- Current-tree verification: `git show HEAD:docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md` has the paragraph on line 101, T3 on line 109, T8b on line 115, AC7 on line 159 and its Acceptance Verification row on line 201. `git show -U0` of the commit named below shows the paragraph, T8b, the Commit Points rows, AC7 and its row for this file; `git show -U0` of the A12 commit shows the T3 row. +- Resolution reference: `docs(issues): [#2993] require the incremental test-design review and maintainer checkpoint in both sub-issue drafts` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658604115 + +### F14 - The reproductions have no issue-local manual verification evidence file + +- PR number: 2994 +- Source review ID: 6012831750 +- Reviewer finding ID: F12 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658541369 +- Concern: The claimed reproductions have example output but no issue-local `manual-verification-evidence.md` with the commands, configuration and relevant logs, although SI-A relies on this session as its baseline. Copilot asks to keep the runtime and backend details, commands, redacted results and outcomes in the EPIC's evidence file and to link both drafts to it. +- Solution: `docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md` records a new run of the reproductions on a fresh debug build whose code equals `develop` at `98fa27df2`, with `evidence/reproduce.sh`, `evidence/udp_probe.py` and `evidence/output.txt`. The EPIC and both drafts link it. The commit also adds the EPIC's `evidence/*.txt` to `ignorePaths` in `cspell.json`. Limits, as the evidence file states them: A6, A7 and A8 were confirmed by reading the code, not run; the expired-key reply was not requested; the script was edited for ShellCheck after the run and the edited script was not run again. The link in the background paragraph of the SI-A draft is in `docs(issues): [#2993] assign database errors that hold a secret to SI-A as inventory item A12`; the commit named below links the file from the SI-A Regression Test Strategy, the SI-B background and the EPIC. +- Current-tree verification: `git ls-tree -r --name-only HEAD docs/issues/open/2993-secrets-and-client-error-text` lists `EPIC.md`, the three `evidence/` files and `manual-verification-evidence.md`. `git merge-base --is-ancestor 98fa27df2 torrust/develop` succeeds. The evidence file names the build on lines 44 and 45, the script edit on lines 21 to 23 and the two limits under "Not Reproduced" (lines 233 to 236). `git show HEAD:cspell.json | grep -n 2993` finds line 28. `grep -c 'manual-verification-evidence.md'` on `git show HEAD:` of the EPIC, the SI-A draft and the SI-B draft prints 1, 13 and 10. +- Resolution reference: `docs(issues): [#2993] record the reproductions of the EPIC inventory as manual verification evidence` +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2994#discussion_r4658604272 + ## Processing Log - 2026-11-22 14:16 UTC - Started audit. Round 1: review 6012624473 (Copilot, COMMENTED, submitted 14:05:07Z) with seven inline comments, F1 to F7. Fetched the seven review threads with GraphQL as `josecelano-bot`: all unresolved, `viewerCanResolve` true for each. The fixes of F1 and F4 were already committed (committer times 14:09:00Z and 14:10:03Z) and on the pull request head. Checked each disposition against the current tree with the commands in the detail entries. - 2026-11-22 14:17 UTC - Replied on the seven threads as `josecelano-bot` (reply `created_at` 14:17:20Z to 14:17:34Z) and recorded the reply URLs. - 2026-11-22 14:18 UTC - A copy of the audit validator that calls `gh-bot` exits 0 (7 rows, 0 failures). After it, `github-review-threads reply-status` reported `all_replied` (7 of 7) and the seven threads were resolved as `josecelano-bot`. A new GraphQL fetch shows 7 threads, 0 unresolved. This record is not committed yet. +- 2026-11-22 14:55 UTC - Round 2: review 6012831750 (Copilot, COMMENTED, submitted 14:40:22Z) with five inline comments, recorded as F8, F12, F9, F13 and F14. Fetched the twelve review threads with GraphQL as `josecelano-bot`: the seven of round 1 resolved, the five new ones unresolved with `viewerCanResolve` true. The four fix commits were already on the pull request head (committer times 14:47:25Z to 14:49:05Z). Checked each disposition against the head commit with `git show HEAD:`, because the working tree held an unfinished merge of `develop` that this audit did not start. +- 2026-11-22 14:56 UTC - Replied on the five threads of round 2 as `josecelano-bot` (reply `created_at` 14:56:46Z to 14:56:55Z) and recorded the reply URLs. +- 2026-11-22 14:57 UTC - The copy of the audit validator that calls `gh-bot` exits 0 (12 rows, 0 failures). After it, `github-review-threads reply-status` reported `all_replied` (5 of 5) and the five threads were resolved as `josecelano-bot`. A new GraphQL fetch shows 12 threads, 0 unresolved. The round 2 additions to this record are not committed yet: the working tree holds an unfinished merge of `develop` with a conflict in `cspell.json`. ## Completion Rules From 7718d711061bbdd4afb3b7dda6b7d4a9e3fac4ae Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 22 Nov 2026 15:02:01 +0000 Subject: [PATCH 11/11] docs(issues): [#2993] refresh the inventory after SI-4 of EPIC #2912 merged SI-4 (#2916) removed the source locations from the tracker-core errors. Updates the tracker-core line references, records a re-run on a build that includes it (evidence V9), and drops the wait-for-SI-4 notes. Co-Authored-By: Claude Fable 5.2 --- .../ISSUE.md | 18 +++++----- .../ISSUE.md | 2 +- .../EPIC.md | 28 ++++++++-------- .../manual-verification-evidence.md | 33 ++++++++++++++++++- 4 files changed, 57 insertions(+), 24 deletions(-) diff --git a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md index 1cb6cab78..9983f9dcb 100644 --- a/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md +++ b/docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md @@ -37,7 +37,7 @@ No error value keeps a peer authentication key or a REST API admin token, no err ## Background -The inventory of the EPIC (section "Inventory", items A1 to A11) lists every case found in the tree and reproduced on a running tracker. This issue owns the cases that are secrets: A1 to A8, A10 and A12. A9 is a documentation fix that belongs here too, and so is A12 (a database server message that holds the key). A11 (database server messages that name the user and host) is owned by SI-B. The commands and output of the reproductions are in the EPIC's [`manual-verification-evidence.md`](../../open/2993-secrets-and-client-error-text/manual-verification-evidence.md). +The inventory of the EPIC (section "Inventory", items A1 to A12) lists every case found in the tree and reproduced on a running tracker. This issue owns the cases that are secrets: A1 to A8, A10 and A12. A9 is a documentation fix that belongs here too, and so is A12 (a database server message that holds the key). A11 (database server messages that name the user and host) is owned by SI-B. The commands and output of the reproductions are in the EPIC's [`manual-verification-evidence.md`](../../open/2993-secrets-and-client-error-text/manual-verification-evidence.md). The rule already exists: rule 3 of the errors ADR (`docs/adrs/20261118045443_errors_do_not_record_source_locations.md`) says a secret is never the offending input in a message and the error does not keep it, and the `handle-secrets` skill forbids secrets in logs and error text. The code predates both for the peer key, which is not a `SecretString` and prints in clear wherever it is formatted. The skill and the secrecy ADR cover configuration secrets only; they do not name the peer key or secrets carried in URLs. @@ -48,16 +48,16 @@ The maintainer's principle (2026-11-22): help the legitimate user as much as pos ### In Scope 1. **Errors that keep or print a key (A1, A2).** - - `authentication::key::Error::UnableToReadKey` (`packages/tracker-core/src/authentication/key/mod.rs:180`) loses its `key` field. Its message becomes `Authentication key not registered` (wording confirmed in review). - - `PeerKeyError::InvalidKey` (`packages/tracker-core/src/error.rs:128`) and the REST `AuthKeyError::InvalidKey { key, reason }` (`packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs:31`) stop keeping the uploaded key. They keep the parse error, which already says what is wrong (length or characters), and the REST reply states the length that was received. + - `authentication::key::Error::UnableToReadKey` (`packages/tracker-core/src/authentication/key/mod.rs:176`) loses its `key` field. Its message becomes `Authentication key not registered` (wording confirmed in review). + - `PeerKeyError::InvalidKey` (`packages/tracker-core/src/error.rs:124`) and the REST `AuthKeyError::InvalidKey { key, reason }` (`packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs:31`) stop keeping the uploaded key. They keep the parse error, which already says what is wrong (length or characters), and the REST reply states the length that was received. - The REST responses `invalid_auth_key_response` and `invalid_auth_key_param_response` stop echoing the key. 2. **Messages for the peer key** (the proposal in the EPIC, to confirm in review): `Missing authentication key: this tracker is private, use /announce/`; `Invalid authentication key: expected 32 characters, got `; `Invalid authentication key: only the characters 0-9, a-z and A-Z are allowed`; `Authentication key not registered`; `Authentication key expired`. The malformed-key texts are produced in `packages/http-protocol/src/v1/auth.rs` and `packages/tracker-core/src/authentication/key/peer_key.rs`; the length case needs the length passed to the error, not the key. 3. **Request logging (A3, A4).** The HTTP tracker, the REST API and the health-check API log `%uri` in the request event and the `DefaultMakeSpan` span records it again. Replace both with a redacted URI: the path segment after `/announce/`, `/scrape/` and `/api/v1/key/`, and the value of the `token` query parameter, are replaced by a fixed marker (`***`, the marker the configuration redaction uses). One tested function owns the rule, shared by the three servers; its home is decided at implementation (a small module in an existing shared package, not a new package unless the review asks for it). The span must not record the raw URI either: use a custom `MakeSpan`. -4. **The generated key (A5).** Remove the `tracing::debug!` lines that print the generated key (`packages/tracker-core/src/authentication/key/mod.rs:113`, `:120`). +4. **The generated key (A5).** Remove the `tracing::debug!` lines that print the generated key (`packages/tracker-core/src/authentication/key/mod.rs:111`, `:118`). 5. **The type (A7).** `Key` gets a redacting `Debug` (`Key([REDACTED])`). Its `Display` stays only where the key is deliberately handed to its owner or persisted (the generate and add responses, the database store), and each remaining use is listed in the issue's evidence. `PeerKey`'s manual `Display` is checked the same way. Tests assert the redacted text without printing a test secret (`handle-secrets` skill). 6. **The REST client (A6).** The client strips the URL from `reqwest` errors (`without_url`) before it wraps them, and sends the token in the `Authorization: Bearer` header instead of the query string, which the server already accepts. The plain `String` token fields (A8) become `SecretString` where that is practical; if a field cannot change without a breaking change, record why. 7. **Configuration errors (A10).** A configuration error does not print the value of a secret option. For the `figment` error of a secret field (the database password, an access token), the loader reports the option path and the expected type with a fixed message and no value. How it is detected (the key path of the `figment` error against a list of secret paths, or reading the secret fields as strings and rejecting other types with a fixed message) is decided at implementation and recorded. -8. **Database errors that hold a secret (A12).** A database server message can contain the value that was written: adding a peer key that already exists makes MySQL answer `Duplicate entry '' for key 'keys.key'` (reproduced; see the EPIC evidence file, section V8). `databases::error::Error` keeps the `sqlx` source and prints it, so the key is in the retained error, in the REST reply and in a DEBUG log line. For the key store operations the error must not keep or print the driver message: map a unique-constraint violation to a variant of its own with a fixed message (for example "the key already exists"), using the driver's error kind (`sqlx::error::ErrorKind::UniqueViolation`), not its text; for any other driver error raised by a statement that binds a secret, keep the error kind and code and drop the message. Record at implementation which statements bind a secret (the `keys` table writes). What non-secret driver detail a client may see is SI-B. +8. **Database errors that hold a secret (A12).** A database server message can contain the value that was written: adding a peer key that already exists makes MySQL answer `Duplicate entry '' for key 'keys.key'` (reproduced; see the EPIC evidence file, section V8). `databases::error::Error` keeps the `sqlx` source and prints it, so the key is in the retained error and in the REST reply (and, before SI-4 of EPIC #2912, in a DEBUG log line). For the key store operations the error must not keep or print the driver message: map a unique-constraint violation to a variant of its own with a fixed message (for example "the key already exists"), using the driver's error kind (`sqlx::error::ErrorKind::UniqueViolation`), not its text; for any other driver error raised by a statement that binds a secret, keep the error kind and code and drop the message. Record at implementation which statements bind a secret (the `keys` table writes). What non-secret driver detail a client may see is SI-B. 9. **Documentation (A9 and the gap).** Update the `handle-secrets` skill and the secrecy ADR (or add an ADR if the review prefers) with the rule for the peer key and for secrets carried in URLs; fix `docs/containers.md` so the examples use the `Authorization` header and the v3 network database fields instead of `?token=` and a `mysql://` `path`. ### Out of Scope @@ -81,8 +81,8 @@ Not applicable: the work changes error types, a log formatting function, a type' This is substantively a bug (a secret printed to a client and to logs), so it follows `.claude/skills/fix-bug/SKILL.md`: -- analysis: the call paths and audiences are in the EPIC inventory; re-check them against the tree before the first change, because SI-4 (#2916) rewrites the tracker-core errors first; -- real-artifact reproduction: run a tracker and send the requests of the manual scenarios below; record each reply and the log lines. The EPIC's session reproduced them, and the commands, configuration and output are in the EPIC's `manual-verification-evidence.md`; repeat that baseline on the commit this issue starts from, because SI-4 changes the texts first; +- analysis: the call paths and audiences are in the EPIC inventory; re-check them against the tree before the first change (SI-4, #2916, merged on 2026-11-22 and removed the source locations from these errors); +- real-artifact reproduction: run a tracker and send the requests of the manual scenarios below; record each reply and the log lines. The EPIC's session reproduced them, and the commands, configuration and output are in the EPIC's `manual-verification-evidence.md`; repeat that baseline on the commit this issue starts from; - regression-test boundary: see Regression Test Strategy; - red regression-test evidence, production fix, green test evidence, and the same reproduction run again after the last production change, all recorded in `manual-verification-evidence.md`. @@ -104,7 +104,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | ID | Status | Task | Notes / Expected Output | | --- | --- | --- | --- | -| T1 | TODO | Baseline reproduction | The EPIC cases A1 to A6 and A10 reproduced on the starting commit; evidence recorded. Starts after SI-4 (#2916) merges. | +| T1 | TODO | Baseline reproduction | The EPIC cases A1 to A6 and A10 reproduced on the starting commit; evidence recorded. | | T2 | TODO | Test plan | The list of tests per behavior area (T3 to T8), written before the first one. The tests themselves are written red-then-green inside each area, with a recorded test-design review after each passing increment. | | T3 | TODO | Key errors and messages | A1, A2 and the new peer-key messages; the REST responses stop echoing the key. | | T4 | TODO | `Key` type | Redacting `Debug`; remaining `Display` uses listed and justified. | @@ -212,7 +212,7 @@ None planned. The UDP and HTTP probes of the EPIC session were ad-hoc commands; ## Risks and Trade-offs - **Redacting the URI loses debugging value.** An operator cannot see which key a client used. Mitigation: if correlation is needed, log a short stable fingerprint (a truncated hash) instead of the key; decide in review. -- **Conflict with SI-4 (#2916).** Both rewrite the tracker-core key errors. Mitigation: start after SI-4 merges. +- **Overlap with EPIC #2912.** SI-4 (#2916) has merged. SI-5 (#2917) rewrites the configuration errors that item 7 also touches. Mitigation: agree the order of SI-5 and item 7 with the maintainer before T7. - **A breaking change in a public error enum.** `UnableToReadKey` loses a field. Mitigation: tracker-core is not published yet, and the enum is `#[non_exhaustive]`. - **Moving the REST client token to the header** breaks nothing on the server, which accepts both, but changes what a proxy log sees. Mitigation: record it in the release notes. - **Detecting secret options in a `figment` error** can miss a new secret option. Mitigation: derive the list from the `SecretString` fields, or test that each secret field is covered. diff --git a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md index 463821233..3ca0ab509 100644 --- a/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md +++ b/docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md @@ -206,7 +206,7 @@ A short UDP probe (connect, announce, raw packet) is needed for M2 and M3, becau - **Clients that match on text.** Mitigation: list old and new texts; the ADR says whether any text is a contract. - **Divergence from API v2.** Mitigation: the ADR names how the v2 error model (EPIC #144) relates to the policy. - **Over-generic messages that help nobody.** Mitigation: the maintainer's principle; a known client mistake keeps a specific message. -- **Conflict with SI-A and SI-4.** All three touch the tracker-core errors. Mitigation: run them one after the other: SI-4, then SI-A, then this issue's code. +- **Conflict with SI-A and SI-4.** All three touch the tracker-core errors. Mitigation: SI-4 has merged; run SI-A before this issue's code. ## Implementation Completion Review diff --git a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md index 288a15c60..ced08c84d 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/EPIC.md @@ -46,24 +46,26 @@ The two problems differ in kind. SI-A is a bug class with concrete, listed cases ## Inventory (verified against the tree at `develop` commit `bcca9764c`, 2026-11-22) +SI-4 of EPIC #2912 (#2916, pull request #2991) merged into `develop` on 2026-11-22 as `4fa49ec9c`, after this inventory was made. It removed the source locations from the tracker-core errors and nothing else that matters here: a re-run on a build that includes it (evidence file, section V9) shows the same replies without the location suffix, the key still echoed, and the MySQL duplicate-key reply still holding the key. The `tracker-core` line numbers below were refreshed against the tree that includes SI-4; the quoted reply texts in "Verified by running experiments" are from the run before it and still show locations. + Paths are relative to the repository root. Every item was read in the code, and the leaks were reproduced on a running tracker (see "Verified by running experiments"). The one thing not checked is how a source location prints in a release build; the debug build prints the workspace-relative path (`packages/tracker-core/src/authentication/service.rs:98:27`), and that is EPIC #2912's concern. ### A. Secrets held by errors or written to output | ID | Location | What leaks | Seen by | | --- | --- | --- | --- | -| A1 | `packages/tracker-core/src/authentication/key/mod.rs:180` (`UnableToReadKey { key: Box }`, built in `authentication/service.rs:97`) | the full 32-character peer key, kept and printed (`Failed to read key: {key}`) | the HTTP client that sent the key | -| A2 | `packages/tracker-core/src/error.rs:128` (`PeerKeyError::InvalidKey { key: String }`, built in `authentication/handler.rs:106`, `:123`) and `packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs:31` (`InvalidKey { key, reason }`, Display `invalid key: "{key}"`) | the key an administrator uploaded, echoed back | the REST API administrator; REST handlers `auth_key/handlers.rs:38-46` and `invalid_auth_key_response` (`responses.rs:53-55`) | +| A1 | `packages/tracker-core/src/authentication/key/mod.rs:176` (`UnableToReadKey { key: Box }`, built in `authentication/service.rs:96`) | the full 32-character peer key, kept and printed (`Failed to read key: {key}`) | the HTTP client that sent the key | +| A2 | `packages/tracker-core/src/error.rs:124` (`PeerKeyError::InvalidKey { key: String }`, built in `authentication/handler.rs:103`, `:118`) and `packages/rest-api-protocol/src/v1/context/auth_key/resources/auth_key.rs:31` (`InvalidKey { key, reason }`, Display `invalid key: "{key}"`) | the key an administrator uploaded, echoed back | the REST API administrator; REST handlers `auth_key/handlers.rs:38-46` and `invalid_auth_key_response` (`responses.rs:53-55`) | | A3 | `packages/axum-http-server/src/v1/routes.rs:82-104` (`TraceLayer`, `DefaultMakeSpan` at INFO plus `on_request` with `%uri`) | the peer key in `/announce/` and `/scrape/`, plus the whole query string, in the request event and in the span of every event inside it | server log reader | | A4 | `packages/axum-rest-api-server/src/routes.rs:76-98` (same pattern; the auth middleware is inside the trace layer, so wrong tokens are logged too) | the admin token in `?token=` and the key in `/api/v1/key/` | server log reader | -| A5 | `packages/tracker-core/src/authentication/key/mod.rs:113`, `:120` (`tracing::debug!("Generated key: {}...")`) | a newly generated peer key, in clear, at DEBUG | server log reader | +| A5 | `packages/tracker-core/src/authentication/key/mod.rs:111`, `:118` (`tracing::debug!("Generated key: {}...")`) | a newly generated peer key, in clear, at DEBUG | server log reader | | A6 | `packages/rest-api-client/src/v1/client.rs:30` (`TransportError(reqwest::Error)`) and `:369-370` (token added to the query string); `without_url` is never called | reqwest prints the URL, so a transport error on a GET contains `?token=` | users of the client library and console tools | | A7 | `packages/tracker-core/src/authentication/key/peer_key.rs:127-128`, `:46-47`, `:71-75` (`Key` and `PeerKey` derive `Debug`, `Display`, `Serialize`) | the peer key prints in clear wherever the value is formatted | any log or error that formats a `Key` | | A8 | `packages/axum-rest-api-server/src/v1/middlewares/auth.rs:62-65` (`QueryParams { token: Option }` derives `Debug`); `packages/rest-api-client/src/connection_info.rs:7-9` (`api_token: Option`) | plain `String` tokens; no log of them was found | none today; a latent risk | | A9 | `docs/containers.md` (lines about 492-562) | the documentation teaches `?token=` URLs and a `mysql://user:password@host` URL in config and environment | readers; the request log then records the token. The MySQL example (`path = "mysql://db_user:...@mysql:3306/torrust_tracker"`) is also stale: the v3 schema refuses `path` for a network database (`packages/configuration/src/v3_0_0/database.rs:203-204`) | | A10 | `packages/configuration/src/v3_0_0/mod.rs:409` (`figment.extract()`), wrapped by `Error::ConfigError` (`packages/configuration/src/lib.rs:335`) | a configuration error prints the offending value, so a numeric database password or access token is printed (details below) | the operator: stderr and the server log | -| A11 | `packages/tracker-core/src/databases/error.rs:111-135` (`From<(SqlxError, Driver)>` keeps the `sqlx` text) | a database server message names the database user and the client address (details below). Not a secret; owned by SI-B | the operator today; a client wherever driver text is forwarded | -| A12 | `packages/tracker-core/src/databases/error.rs:111-135` (the `sqlx` source is kept and printed), reached from `packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs` | a database server message can contain a secret: adding a peer key that already exists makes MySQL answer `Duplicate entry '' for key 'keys.key'`, and the error keeps and prints it. PostgreSQL (`duplicate key value violates unique constraint "keys_key_key"`) and SQLite (`UNIQUE constraint failed: keys.key`) do not print the value | the REST administrator (500 reply), and the server log at DEBUG through the `torrust_located_error` event | +| A11 | `packages/tracker-core/src/databases/error.rs:92-116` (`From<(SqlxError, Driver)>` keeps the `sqlx` text) | a database server message names the database user and the client address (details below). Not a secret; owned by SI-B | the operator today; a client wherever driver text is forwarded | +| A12 | `packages/tracker-core/src/databases/error.rs:92-116` (the `sqlx` source is kept and printed), reached from `packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs` | a database server message can contain a secret: adding a peer key that already exists makes MySQL answer `Duplicate entry '' for key 'keys.key'`, and the error keeps and prints it. PostgreSQL (`duplicate key value violates unique constraint "keys_key_key"`) and SQLite (`UNIQUE constraint failed: keys.key`) do not print the value | the REST administrator (500 reply). Before SI-4 of EPIC #2912 also the server log at DEBUG, through the `torrust_located_error` event; that line is gone since SI-4 | Checked and found safe, so that the spec does not redo it: @@ -93,9 +95,9 @@ HTTP tracker (a bencoded `failure reason`, always HTTP 200; wrapper `packages/ht | Error family | Client text (shape) | Source | | --- | --- | --- | -| authentication | `Tracker authentication error: Failed to read key: [, ]`, `Missing authentication key`, `Key has expired` | `packages/http-core/src/services/error_mapping.rs:4-21`, `packages/tracker-core/src/authentication/key/mod.rs:180-191` | -| whitelist | `Tracker whitelist error: The torrent: , is not whitelisted` | `packages/tracker-core/src/error.rs:104` | -| database (announce and scrape) | `Tracker announce error: Database error: ` | `packages/tracker-core/src/error.rs:79`, `:92`; `databases/error.rs` | +| authentication | `Tracker authentication error: Failed to read key: [, ]`, `Missing authentication key`, `Key has expired` | `packages/http-core/src/services/error_mapping.rs:4-21`, `packages/tracker-core/src/authentication/key/mod.rs:176-185` | +| whitelist | `Tracker whitelist error: The torrent: , is not whitelisted` | `packages/tracker-core/src/error.rs:102` | +| database (announce and scrape) | `Tracker announce error: Database error: ` | `packages/tracker-core/src/error.rs:77`, `:90`; `databases/error.rs` | | query parse | `Bad request. Cannot parse query params: invalid param ` and per-parameter texts that echo the client's own values | `packages/http-protocol/src/v1/requests/announce.rs:216-245`, `:346-354`, `query.rs:102` | | client IP | `Error resolving peer IP: missing or invalid right-most IP in the X-Forwarded-For header, which is mandatory when the tracker runs behind a reverse proxy` | `peer_ip_resolver.rs:112-121` | @@ -106,7 +108,7 @@ UDP tracker (the error packet message is `error.to_string()` of `udp_server::err | request parse | `error parsing request: {request_parse_error:?}` (Debug of a struct) | `packages/udp-server/src/error.rs:24` | | connection cookie | `... Connection cookie error: cookie value is expired: , expected > ` (server timing values) | `packages/udp-core/src/connection_cookie.rs:112-118` | | whitelist | `tracker announce error: Tracker core whitelist error: The torrent: , is not whitelisted` | `packages/udp-core/src/services/announce.rs:190-204` | -| database | `tracker announce error: Tracker core announce error: Database error: Failed to connect to database: error communicating with database: ` | `databases/error.rs:111-135` | +| database | `tracker announce error: Tracker core announce error: Database error: Failed to connect to database: error communicating with database: ` | `packages/tracker-core/src/databases/error.rs:92-116` | | internal | `internal server error: {message}` | `packages/udp-server/src/error.rs:36` | REST API (`packages/axum-rest-api-server/src/v1/responses.rs`): @@ -170,11 +172,11 @@ SI-B, client error text (a design question): Decided by the maintainer on 2026-11-22: this EPIC is standalone and linked. It is not a sub-issue of #2912, so #2912 keeps its single scope (source locations). Effects on #2912: -- SI-4 (#2916, PR #2991) does not fix A1 or A2; it links this EPIC for the standing review finding. +- SI-4 (#2916, PR #2991) merged on 2026-11-22. It did not fix A1 or A2; it links this EPIC for the standing review finding. - SI-5 (#2917): one interaction. Its AC2 says the startup error for a bad configuration file "names the file and the invalid key or value". For a secret option (the database password, an access token) the value must not be printed (A10). SI-5 should name the option and the expected type only for those options, or leave the value to SI-A; the maintainer decides which issue owns it. - SI-6 (#2918) is unchanged. - SI-7 (#384) is unchanged: it checks that no client reply holds a source path. Its out-of-scope note about other information in a reply (for example database error codes) points to SI-B. -- Order: nothing here blocks #2912. Any change to the text of the tracker-core errors lands after SI-4 merges, to avoid conflicting edits. +- Order: nothing here blocks #2912. SI-4 has merged, so SI-A can start on the tracker-core errors. ## Subissues @@ -182,7 +184,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | Order | Issue | Local Spec | Status | Notes | | --- | --- | --- | --- | --- | -| 1 | #[To be assigned] - SI-A Keep secrets out of errors, logs and output | `docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md` | TODO | After SI-4 (#2916) merges. A bug class with the listed cases A1 to A9 | +| 1 | #[To be assigned] - SI-A Keep secrets out of errors, logs and output | `docs/issues/drafts/2993-si-a-keep-secrets-out-of-errors-and-logs/ISSUE.md` | TODO | SI-4 (#2916) has merged, so it can start. A bug class with the listed cases A1 to A9 | | 2 | #[To be assigned] - SI-B Define and apply the client error text policy | `docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md` | TODO | Starts with an ADR; implementation after the maintainer accepts the ADR. May start in parallel with SI-A, but it touches the same error types, so run them one after the other | Both sub-issue specifications are drafts until the maintainer approves them; their GitHub issues are created then. @@ -296,7 +298,7 @@ The REST API messages for an uploaded key (A2) follow the same pattern: the leng - **Redacting the URI loses debugging value.** An operator can no longer see which key a client used. Mitigation: log a stable short fingerprint if the maintainer wants correlation; SI-A decides. - **Hiding database detail from clients hides it from administrators.** The REST admin loses the driver text. Mitigation: the detail goes to a `tracing` event on the server, and the reply may carry a request id. - **Changing client text breaks clients that match on it.** Today's text is unstable and unspecified, but a client may still match it. Mitigation: each sub-issue lists old and new texts for approval, and the ADR says whether any text is a contract. -- **Conflict with EPIC #2912.** Both touch tracker-core error types. Mitigation: SI-A and SI-B start after SI-4 merges. +- **Conflict with EPIC #2912.** Both touch tracker-core error types. SI-4 has merged; SI-5 and SI-6 touch other packages and the `LocatedError` dependency. Mitigation: re-check the inventory lines against the tree before the first change. - **Scope growth.** Mitigation: the Out of Scope list; API v2 status codes stay in EPIC #144. ## References diff --git a/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md b/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md index 44f3a661e..89ed48e26 100644 --- a/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md +++ b/docs/issues/open/2993-secrets-and-client-error-text/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2993-secrets-and-client-error-text/EPIC.md -last-updated-utc: "2026-11-22 14:50" +last-updated-utc: "2026-11-22 15:05" --- # Manual Verification Evidence @@ -228,6 +228,37 @@ Conclusion: the server message names the database user and the client address (A duplicate-key message holds the peer key, in the reply and in a DEBUG log line; on PostgreSQL and SQLite (V5) it does not (A12). An authentication failure is labelled "query was malformed". +### V9 - After SI-4 of EPIC #2912 merged + +SI-4 (#2916) merged into `develop` as `4fa49ec9c` while this pull request was in review. The key +cases were sent again at 2026-11-22 15:00 UTC to a debug build of the tree that includes it +(`develop` at `6f62cc107` plus this branch's documentation), with the same configuration files and +by hand, not with the script: + +- `GET /announce/TestPeerKey000000000000000000001?...`: + + ```text + d14:failure reason82:Tracker authentication error: Failed to read key: TestPeerKey000000000000000000001e + ``` + +- `POST /api/v1/keys` with `{"key":"ShortTestKey01","seconds_valid":100}`: + + ```text + Invalid URL: invalid auth key: string "ShortTestKey01", Invalid key length. Key must be have 32 chars + ``` + +- The same key added twice on MySQL; the second reply: + + ```text + Unhandled rejection: Err { reason: "failed to add key: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key'" } [500] + ``` + + The MySQL tracker's log held 0 lines with the key. + +Conclusion: SI-4 removed the source locations and, with `LocatedError`, the DEBUG line that held +the key. The key is still echoed in the HTTP failure reason, in the REST reply for an uploaded key +and in the MySQL duplicate-key reply. The other processes were not repeated on this build. + ## Not Reproduced - A6 (the REST client prints the URL with the token in a transport error), A7 and A8 (plain