Repository navigation
Do not reveal the API token in logs - #1442
josecelano merged 1 commit into
Conversation
|
ACK 4205c71 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1442 +/- ##
========================================
Coverage 84.54% 84.54%
========================================
Files 254 254
Lines 19189 19189
Branches 19189 19189
========================================
Hits 16224 16224
Misses 2694 2694
Partials 271 271 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change from #1442 as it stands at a94c3ced8 on the default branch.
What still runs: the one-line change, #[instrument(skip(configuration))] on AppContainer::initialize, is unchanged from 4205c71 at src/container.rs:64, now on an async fn that returns a Result. The span records no fields, so the Configuration and the API access tokens it holds never enter it. Two later changes added protection of their own: b7af6fa made the tokens SecretString, whose Debug renders SecretBox<str>([REDACTED]), and 8cfc07b redacts ?token= in the REST API request event and span. That second change also closed the other path by which, at merge time, the token still reached the logs the description refers to (the raw request URI logged at INFO); that is history, not a finding.
[Nit] src/bootstrap/app.rs:76 still carries #[instrument(skip())] on initialize_global_services(configuration: &Configuration). An empty skip() skips nothing, so the span records the whole Configuration through Debug: the pattern this pull request removed from src/container.rs:64. On the production startup path (src/app.rs:114 to src/bootstrap/app.rs:64) the span is created before any subscriber exists and records nothing, and today Debug redacts the tokens and the database password, so nothing secret leaks at this commit. Sequence where it does record: a thread-scoped subscriber is current when initialize_global_services is entered (for example a test under capture_logs_in_scope from packages/test-helpers/src/logging.rs) and logging.trace_filter is not off; the Logging initialized event at packages/configuration/src/v3_0_0/logging.rs:101 is then emitted inside the span and carries configuration=Configuration { ... } (every setting, database host, user and paths included) as its span context, and the token values are kept out only by their type, not by the span. Smallest fix: #[instrument(skip(configuration))] (or skip_all) at src/bootstrap/app.rs:76, matching src/container.rs:64.
Checked and found sound at a94c3ced8: every other #[instrument] that receives the API tokens or a container holding them skips them (packages/axum-rest-api-server/src/routes.rs:42, src/bootstrap/jobs/tracker_apis.rs:72 and :116, src/app.rs:264); AccessTokens is HashMap<String, SecretString> (packages/configuration/src/lib.rs:38) with a Debug redaction test at packages/configuration/src/v3_0_0/tracker_api.rs:128; the startup configuration log goes through to_redacted_json (src/bootstrap/app.rs:66); the auth middleware (packages/axum-rest-api-server/src/v1/middlewares/auth.rs) logs neither the presented nor the configured token and compares in constant time; redact_uri (packages/axum-server/src/request_log.rs) matches token after percent-decoding, as the query extractor decodes it, and in any case; the empty skip() on setup and initialize_static (src/bootstrap/app.rs:53, :90) and on check_fn (packages/axum-rest-api-server/src/server.rs:252) records only an optional file path, nothing, and a service binding.
Do not reveal the API token in logs.