Expand description
Operator-facing tracing-subscriber primitives.
§HIGH-B5 — redact bearer/Authorization in tracing output
reqwest (and the surrounding hyper / h2 / rustls stack) emit
verbose, byte-level diagnostics at TRACE. Those diagnostics include the
raw outbound request — and that means Authorization: Bearer <secret>,
Cookie:, Proxy-Authorization: and friends land in any log stream
whose RUST_LOG pulls those targets in at trace.
reqwest does not provide a redaction hook because the offending log
calls happen inside the crate. The right fix is to attach a filter to
the fmt layer at the workspace’s tracing-init sites so the dangerous
events never reach a writer.
This module ships that filter. Binaries that initialize the global
subscriber compose it onto their existing fmt layer:
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
let fmt_layer = tracing_subscriber::fmt::layer()
.with_filter(cellos_core::observability::redacted_filter());
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
.with(fmt_layer)
.init();§What the filter drops
-
HTTP-stack TRACE events. Any event whose
targetstarts with one ofHTTP_STACK_TARGETSatLevel::TRACEis suppressed unconditionally. reqwest’s TRACE log lines are not structured — the bearer token is embedded in aDebug-formattedHeaderMap, so field-name redaction cannot reach it. Suppression is the only reliable mitigation. -
Sensitive field names anywhere. Any event whose recorded fields include a name in
SENSITIVE_HEADER_NAMES(case-insensitive) is suppressed regardless of target or level. Catches our own code paths that might accidentallyinfo!(authorization = %h, ...).
Operators still see reqwest=debug (status codes, request URLs without
headers) and every workspace-emitted event at INFO/DEBUG. The escape
hatch — RUST_LOG=reqwest=trace in production — is closed.
Approach C from the wave-1 audit. ADR-0018 (FIX-B4 — credential redaction posture) cross-references this module.
Structs§
- Sensitive
Field Visitor - Tracing
Visitimpl that setsfound_sensitiveif any recorded field name appears inSENSITIVE_HEADER_NAMES(case-insensitive).
Constants§
- HTTP_
STACK_ TARGETS - Targets whose TRACE-level events are suppressed wholesale.
- SENSITIVE_
HEADER_ NAMES - Header / field names whose presence in any event causes the event to be
dropped. Case-insensitive match on the field name reported by
tracing::field::Field::name.
Functions§
- is_
sensitive_ field_ name - Case-insensitive membership check against
SENSITIVE_HEADER_NAMES.