Commit 8e514f3
fix(net): redact proxy credentials from the diagnostic bundle (#190)
## The defect
The SPEC s18 diagnostic bundle writes `settings_redacted.json` via
`redact_settings()`, which built its output with `global:
s.global.clone()` -
the whole `GlobalSettings` struct verbatim.
`GlobalSettings` carries the issue #34 `proxy_url`. In `manual` mode
that URL
may embed basic-auth userinfo:
```
http://corpuser:hunter2@proxy.corp.example:8080
```
So the proxy password shipped **in plaintext** inside a bundle whose
entire
purpose is to be handed to support. Every other secret-bearing surface
in the
bundle is scrubbed (logs, crashes, and the activity CSV all go through
`Redactor`; the telemetry `install_id` is hashed) -
`settings_redacted.json`
was the hole, and its own doc comment claimed "the only redaction here
is the
install id".
Found while verifying the already-shipped #145 proxy work (issue #34).
## The fix
Strip the userinfo before serializing, keeping scheme + `host:port`
because
that is the diagnostically useful part of a proxy setting:
```
http://<redacted>@proxy.corp.example:8080
```
`redact_proxy_userinfo` is hand-rolled rather than routed through
`url::Url`
deliberately: a URL the parser rejects must still get scrubbed, never
fall
through to emitting the raw string. The authority is everything between
`://`
and the first `/`, `?` or `#`; the **last** `@` in it splits userinfo
from host
(a password may itself contain `@`).
## Tests
Two new unit tests in `src-tauri/src/commands/settings.rs`:
- `redact_settings_strips_proxy_basic_auth_credentials` - asserts the
username
and password are gone, `host:port` survives, and (the load-bearing one)
that
the **serialized JSON** carries no secret, since that is the artifact
that
actually leaves the machine.
- `redact_proxy_userinfo_handles_every_url_shape` - no-credential
passthrough,
socks5, username-only, a password containing `@`, path/query not
mistaken for
the authority, an `@` inside a path left alone, and
unparseable-garbage-with-
an-`@` redacted wholesale rather than passed through.
Ran locally: `cargo test -p driven-app redact_` (12 passed),
`cargo clippy -p driven-app --all-targets -- -D warnings` (clean),
`cargo fmt --all -- --check` (clean).
## Scope note
Two adjacent fields in the same struct are also cloned verbatim into the
bundle
and may carry user PII, but are **out of scope here** and reported
separately
rather than silently swept in: `custom_root_ca_path` (an absolute path
that can
contain the OS username, and which the rest of the bundle would have
hashed to
`<path:...>`) and `pre_backup_hook` / `post_backup_hook` (free-text
commands).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Qu8GxMwkuxF7JBzwRjtcw7
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 6b02650 commit 8e514f3
1 file changed
Lines changed: 115 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2136 | 2136 | | |
2137 | 2137 | | |
2138 | 2138 | | |
2139 | | - | |
| 2139 | + | |
| 2140 | + | |
2140 | 2141 | | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
2141 | 2148 | | |
2142 | | - | |
| 2149 | + | |
2143 | 2150 | | |
2144 | 2151 | | |
2145 | 2152 | | |
| |||
2151 | 2158 | | |
2152 | 2159 | | |
2153 | 2160 | | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
2154 | 2188 | | |
2155 | 2189 | | |
2156 | 2190 | | |
| |||
3105 | 3139 | | |
3106 | 3140 | | |
3107 | 3141 | | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
3108 | 3221 | | |
3109 | 3222 | | |
3110 | 3223 | | |
| |||
0 commit comments