wallet: redact RPC creds everywhere and warn once on a login from env
All checks were successful
ci / test (pull_request) Successful in 19m31s
ci / sdk (pull_request) Successful in 2m3s

The app-spawned child already takes its login from the sealed store record
and only falls back to ONIONWIRE_WALLET_RPC_LOGIN; make that order explicit
in the code and name the exposure once per process when the fallback is used.

The dial URL still carries user:pass (Wallet::from_url needs it), but no
rendering path repeats it: Endpoint::redacted and WalletClient::redacted_url
print http://<redacted>:<redacted>@host:port/json_rpc, WalletClient has a
hand-written Debug, and error/status copy redacts the whole login, not just
the password half.

Residual, documented at the top of wallet_child.rs: --rpc-login is visible in
/proc/<pid>/cmdline to same-uid processes because monero-wallet-rpc has no
other credential channel.
This commit is contained in:
agent 2026-10-22 22:20:12 -04:00
commit 625879e000
No known key found for this signature in database
3 changed files with 224 additions and 17 deletions

View file

@ -101,6 +101,33 @@ fn password_absent_from_url_errors() {
);
}
/// A 401 on the authenticated retry means the login is wrong. That copy is
/// rendered in the TUI/Android status line, so it must not echo either half of
/// the credential — not the password, not `user:pass`, not a URL with userinfo.
#[tokio::test]
async fn ping_401_error_carries_no_credential() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
// Answer the authenticated retry with another 401: the digest was built
// from this connection's own challenge, so this is a wrong login.
let reply: Arc<dyn Fn(&str) -> String + Send + Sync> =
Arc::new(|_| digest_401("refused-again"));
tokio::spawn(serve_rpc_conns_with(listener, reply, None, None, true));
let pass = "s3cretPASS";
let login = format!("ow:{pass}");
let res = Wallet::ping(&format!("http://127.0.0.1:{}", addr.port()), login.as_str()).await;
assert!(!res.ok, "a refused digest must not report connected");
let err = res.error.expect("failure carries a reason");
println!("401 ping error: {err}");
assert!(!err.contains(pass), "password leaked in error: {err}");
assert!(!err.contains(&login), "login leaked in error: {err}");
assert!(
!err.contains(&format!("://{login}@")),
"URL userinfo leaked in error: {err}"
);
}
#[tokio::test]
async fn mock_get_address_parses_string() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();