Repository navigation
fix: bound LNURL authentication before VSS requests - #36
ben-kaufman wants to merge 1 commit into
Conversation
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Wraps the LNURL-auth JWT provider in a 10 s tokio::time::timeout for both the app client and the dedicated LDK client, so a stalled challenge, callback or body fails before any VSS request is sent. Reviewed 1a5b788, full tier (auth path).
Build skipped: talos-pr-run could not read the author's repo permission with this token and fails closed, so this review is static. CI Tests and Clippy are green on this head; iOS and Android bindgen were still pending when I read it.
What I checked, and 5 candidates I ruled out
Read in full: src/auth.rs, src/auth/tests.rs, src/conditional.rs, src/implementation.rs (client construction), src/ldk_client.rs, src/lib.rs, plus vss-client-ng 0.4.0 headers/lnurl_auth_jwt.rs, client.rs and util/retry.rs (the version Cargo.lock pins).
Ruled out
- Cancellation leaves a bad JWT cache:
get_jwt_tokenwrites the cache only afterfetch_jwt_tokenreturns, and no lock is held across an await, so dropping the future mid-leg leaves the previous cache state and the next call re-authenticates. - Timeout misclassified on the conditional path:
post_requestmaps any header error toAuthErrorbefore dispatch, andclassifyturnsAuthErrorintoRejected, which is correct since nothing reached VSS.OutcomeUnknownis untouched for dispatched requests. - Timer not available at runtime: the FFI runtime is built with
enable_all(), andtokionow carries thetimefeature in normal dependencies, not only dev. - Regular client can still wait long: on
innerthe timeout surfaces asAuthError, which the retry policy does not skip, andmax_total_delaycounts backoff only, so ten attempts can each spend up to 10 s. The PR body states this is per acquisition, not per operation, so it is deliberate. - Behaviour change in
ldk_client.rsbeyond the wrapper: the other hunks are rustfmt reflow only; retry policy and key derivation are byte-for-byte the same.
Merge confidence: 4/5, the LDK client's wrapped provider has no test exercising it (the regression covers the app conditional path) and bindgen CI was still pending.
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: Full review of the complete PR diff against its merge base, at 1a5b788. No saved baseline was available, so no coverage is inherited.
No new actionable code findings.
The 10-second bound applies to each header acquisition and is wired into both LnurlAuthToJwtProvider construction sites, the app client and the dedicated LDK client. A timeout drops the attempt before post_request sends anything to VSS. The JWT cache is written only after a completed fetch and no lock is held across an await, so an expired attempt leaves no partial state. Conditional writes return Rejected for this pre-dispatch failure, and OutcomeUnknown handling for dispatched requests is unchanged. The other ldk_client.rs hunks are formatting only.
Worst-case wait on retrying clients: this is not a 10-second operation limit, as the PR states. The timeout surfaces as AuthError, which the retry policy does not skip, and max_total_delay counts backoff only. From source, a fully stalled auth server would hold a retrying call for about 110 seconds: 10 attempts of 10 seconds plus about 10.1 seconds of backoff. That is the path in the originating bitkit-ios finding, so the reset wait there would become bounded at about that length, not 10 seconds.
Validation: the hosted Tests job ran on the merge of this head into the reviewed base and reported 28 passed, including auth_timeout_rejects_before_dispatch_and_same_provider_can_retry. Clippy also passed on this head. That regression exercises only the app conditional path, so the LDK factory wiring and the retrying clients are source-checked only.
Limitations: no Rust toolchain was available and static.crates.io was unreachable, so nothing was built or run locally. The dependency was read from the vss-client v0.4.0 tag, not the crate archive, so the Cargo.lock checksum was not verified against it. The PR body mixes requirements with fix notes, so discovery was not fully blind to them. bitkit-ios was checked only for how it calls this SDK; it was not reviewed.
Dependency: the fix reaches the app only after an SDK release and pin update. bitkit-ios#1121 still pins eba41ef.
Suggested additional test cases
- Rust, dedicated LDK client on the retry path. Setup: reuse the loopback server from
src/auth/tests.rs, hold every/challengeresponse, and use paused Tokio time. Action: buildLdkVssClient::new_with_lnurl_authand callget. Expected:VssError::AuthErrorafter 10 challenge attempts, at about 110 seconds of virtual time, with zero VSS requests. Removing the wrapper at the LDK factory should fail this test; the current suite would not catch that. - iOS, after the SDK is adopted. Setup: a state that needs a fresh JWT, with an LNURL-auth server that accepts the connection but holds its response. Action: read a key on the VSS Debug LDK tab, leave the screen, then choose Security → Reset. Expected: the read fails and the reset reaches credential deletion within about 110 seconds, with no VSS request sent.
Reviewer model: claude-opus-5-5
Reasoning effort: high
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None.
QA for 1a5b788:
Native authentication and backup regressions ✅ The exact-head Rust library suite passed, including all four authentication stall boundaries.
cargo test --locked --lib: 28 passed. The authentication regression holds challenge or callback responses before headers or during a partial body, verifies Rejected with no VSS writes after expiry and late response, then checks same-client recovery and JWT reuse.
Rendered command output:
Dedicated LDK authentication retries settle without VSS dispatch ✅ A loopback regression observed ten timed-out attempts, zero VSS requests, and same-client recovery.
A supplemental test exercised LdkVssClient::new_with_lnurl_auth and get with unchanged production source. Each real challenge request reached the socket before advancing Tokio time. The call returned AuthError after 110.228 seconds of virtual time; no VSS request was sent. The same client then authenticated once and completed two writes using its cached JWT.
Removing only the LDK factory wrapper made this probe fail waiting for the second challenge. Temporary test and control edits were restored. This directly exercises the native retry case suggested in the prior QA review; it does not establish wall-clock wipe timing.
Rendered command output:
Check: release library builds with production timer features ✅ The locked release build succeeded on the restored reviewed tree.
cargo build --locked --release --lib passed without test features.
Rendered command output:
Platform binding generation was not repeated; the current-head hosted iOS bindgen and Android bindgen workflows passed. These are build checks, not installed-app tests.
No device run: this repository provides a native library, and the PR explicitly leaves installed-app acceptance for SDK release and app adoption. The suggested iOS Debug → Reset journey was not driven; wallet wipe and running-LDK shutdown remain outside this native validation. Ten seconds bounds each header acquisition, not the complete retrying operation.
Full review of eba41ef..1a5b788: all changed files, both client factories, and reachable authentication, cache, dispatch, error-classification, runtime and retry paths, including resolved vss-client-ng 0.4.0 source. No actionable defects found in either independent source pass.
Reviewed by gpt-6.1-sol-high
LNURL authentication could wait indefinitely before the VSS request timeout started. A stalled challenge, signed callback or response body could therefore keep an admitted backup operation alive while the wallet caller waited for it to drain.
This change bounds each header acquisition to ten seconds by directly awaiting the existing provider inside a Tokio timeout. Both the app and dedicated LDK client factories retain their original signer, JWT cache and store binding. Expiry drops that attempt before VSS dispatch; conditional writes remain
Rejectedfor this pre-dispatch failure and retainOutcomeUnknownfor a dispatched request whose result is uncertain. Ordinary retries remain unchanged, so this is not a ten-second deadline for an entire operation or wallet wipe.Validation on the final source:
verified=true,reason=valid).This is a source fix for the native dependency finding on synonymdev/bitkit-ios#1121. The committed runtime regression exercises the app conditional-write path. A separate macOS loopback test exercised the dedicated LDK lookup used in the #1121 reset reproduction. With the challenge held on every attempt, the default-namespace read returned
AuthErrorafter 110.2 seconds (ten attempts). None reached the VSS endpoint. Once the challenge was released, an explicit read with the same client authenticated and returned an empty list. This measures one native read; Bitkit still pins the previous version. There is no installed-app timeout acceptance, hard real-time guarantee under runtime starvation or running-LDK shutdown claim. Version, released artifacts, app pins, public FFI and server behavior are unchanged. A separately authorized SDK release and app adoption are needed to deliver the fix. Hosted validation is complete on this head: all four workflows and six jobs passed on attempt 1 (Rust, manifest validation, iOS, Android). The synthetic checkout has the exact published tree and all 45 frozen inputs. All 28 Rust tests passed; both uploaded native artifacts were downloaded once and fully checked for hashes, CRCs, base API exports, platform/ABI metadata, Android debug pairing and 16 KiB segment alignment. Complete logs and annotations retain two base Clippy warnings, three base Python updater warnings and tooling advisories. Five OS-specific action skips and two Gradle NO-SOURCE tasks are not runtime passes. Hosted checks did not run Android lint, consumer fixtures or installed apps; those local results and the outstanding app acceptance remain separate.