Repository navigation
fix: hide credentials in regtest errors - #203
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Retargeted to master: #201 merged. |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Builds the regtest URL with Url::join on a slash-normalised base and strips userinfo from the URL shown in regtest errors; README signatures gain auth. Reviewed f930735, full tier (api.rs is the HTTP path that carries basic auth).
Build skipped: talos-pr-run could not confirm the author's permission on this repo with the token it uses, and it fails closed, so this review is static.
What I checked, and 5 candidates I ruled out
Read in full: src/modules/blocktank/api.rs, src/modules/blocktank/db.rs (new, update_blocktank_url), rust-blocktank-client 0.0.16 client.rs (normalize_url, build_url)
Call sites traced: regtest_request from all five regtest_* methods; blocktank_url set in BlocktankDB::new and update_blocktank_url
CI: SwiftPM, manifests, paykit-route, wake green; Android/iOS bindgen and usdt pending at review time. No workflow runs modules::blocktank, so the new regtest_url_tests are not exercised by CI.
Ruled out
- Join diverges from the client:
regtest_urlis the same append-slash,Url::parse,joinsequence asBlocktankClient::normalize_url+build_url, so regtest and non-regtest routes resolve against the same base. - Base with a query and no trailing slash (
https://host/api?x=1): the appended slash lands in the query and the join resolves to/regtest/..., dropping/api. The client resolves its own routes the same way and the oldformat!produced/api?x=1/regtest/..., also wrong, so this diff does not introduce it. payment_idsteering the join: the relative reference always starts withregtest/, so no id can make it scheme-relative or absolute;?,#and..in an id behave as they did when reqwest parsed the formatted string.- Other places the URL leaks: both reqwest errors go through
without_url(),url::ParseErrordoes not carry the input, and the 401 path returns a fixed string. - Auth from base-URL userinfo: reqwest still takes it from the URL as before; only the displayed copy is redacted.
Merge confidence: 4/5, no findings, but the new tests are not run by CI and I could not run them here.
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews, nothing blocking a merge.
worth doing, does not block
- Base URL credentials override the auth argument on regtest calls (src/modules/blocktank/api.rs:238-241). If the Blocktank base URL contains credentials and the caller also passes
auth, the regtest request goes out with twoAuthorizationheaders. A Node server keeps the first one, which comes from the URL, soauthis silently ignored. The cause: reqwest'sRequestBuilder::newmoves URL userinfo into a basic auth header (reqwest 0.12.28,async_impl/request.rs:176-179). Thenbasic_authat api.rs:241 appends a second header instead of replacing the first. How I confirmed it: I built a scratch binary against this branch that callsupdate_blocktank_url("http://urluser:urlpass@127.0.0.1:PORT/api")and thenregtest_mine(None, Some("paramuser:parampass")). A raw socket listener received:POST /api/regtest/chain/mine HTTP/1.1 authorization: Basic dXJsdXNlcjp1cmxwYXNz (urluser:urlpass) authorization: Basic cGFyYW11c2VyOnBhcmFtcGFzcw== (paramuser:parampass)Against a Node 24httpserver,req.headers.authorizationwas the URL pair. This branch treats credentials in the base URL as a real configuration, since it redacts them. On master, URL credentials were the only way to authenticate these routes, so a setup that already uses them and then adoptsauthwill get 401s it can't explain. Two possible fixes: clear the userinfo onurlbeforeclient.requestwhenauthis set, or reject the combination. - URL credentials and explicit auth create duplicate Authorization headers (src/modules/blocktank/api.rs:238-241). Supplying
authalongside credentials in the base URL creates twoAuthorizationheaders.client.request()extracts URL credentials, thenbasic_auth()appends another header. I confirmed this by constructing a request withhttp://base:old-password@127.0.0.1/apiandauth = "regtest:new-password". The old credentials remain first, so servers may ignore valid explicit credentials or reject the duplicate headers.
nits
- New constants sit between use statements (src/modules/blocktank/api.rs:5-7).
REGTEST_TIMEOUT_SECSandERR_REGTEST_UNAUTHORIZEDare declared between theuse serde_json/std::timeimports and theuse rust_blocktank_clientimport. Moving them below the imports keeps the module header in the usual order.
|
@coreyphillips fixed in 25ff03f: with |
coreyphillips
left a comment
There was a problem hiding this comment.
Rechecked after 3 new commits (3443a0c, 69d16db, 25ff03f). Nothing blocking remains.
addressed
- Base URL credentials override the auth argument on regtest calls (src/modules/blocktank/api.rs:238-241). Fixed:
regtest_request_builder(src/modules/blocktank/api.rs:472) passeswithout_credentials(&url)(api.rs:458) toclient.requestwheneverauthis non-empty. It clears userinfo the same way reqwest 0.12.28'sextract_authoritydoes, so reqwest adds no URL-derived header andbasic_authadds the only one. I ranregtest_url_tests(4 pass, includingauth_replaces_base_url_credentials). I also built a scratch binary that callsupdate_blocktank_url("http://urluser:urlpass@127.0.0.1:PORT/api")and thenregtest_mine(None, Some("paramuser:parampass"))against a raw socket. The socket received exactly oneauthorization: Basic cGFyYW11c2VyOnBhcmFtcGFzcw==. Withauthset to None or an empty string, it received one header carrying the URL pair, as on master. - New constants sit between use statements (src/modules/blocktank/api.rs:5-7). Fixed:
REGTEST_TIMEOUT_SECSandERR_REGTEST_UNAUTHORIZEDnow sit at src/modules/blocktank/api.rs:9-11, after the lastuseline.cargo fmt --checkpasses on the file. - URL credentials and explicit auth create duplicate Authorization headers (src/modules/blocktank/api.rs:238-241). Fixed: This is the same defect as point 1, and the same change answers it.
regtest_request_builder(api.rs:472) strips URL userinfo before building the request whenauthis set. The wire check coveredurluser:urlpass@and the password-only:urlpass@base URLs, and both sent a single Authorization header taken fromauth.
|
Merged: approved by @coreyphillips on 25ff03f, no open threads, required checks green (Bindgen jobs still running, not required). |
Follow-up to #201 from @coreyphillips's review.
This PR:
regtest/<path>onto the Blocktank base URL withUrl::join, as the Blocktank client does, so a base URL with a query string (https://host/api/?x=1) still targets/api/regtest/...authis given, drops credentials embedded in the base URL from the request, so it carries a singleAuthorizationheader withauthauthparameter to the regtest signatures in both READMEs and notes that staging requires itTests
regtest_url_tests: the query-string base URL joins to/api/regtest/chain/mine; auser:secret@base URL never showssecretinregtest_mine's error; withauthand URL credentials, the built request has exactly oneAuthorizationheader, fromauthtest_regtest_mineandtest_regtest_depositstill pass against staging withBLOCKTANK_REGTEST_AUTHset