Repository navigation
fix: show relay on pubky auth approval - #2075
Conversation
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; no new blocking issues were found. SummaryShows the relay URL below requested permissions on the Pubky approval sheet.
No new actionable issues were found. Reviews (2) · Last reviewed commit: "fix: accept relay characters the sdk kee..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Shows the relay URL (scheme, lower-cased host, port, path, query; no user info or fragment) on the Pubky auth approval sheet, refuses a request whose relay cannot be read the way the SDK's URL parser reads it, and re-checks the shown relay at authorize(). Reviewed 02355e40d, full tier (auth path).
What I checked, and 4 candidates I ruled out
Read in full: PubkyAuthRequest.kt (displayRelay, isUnchangedRelayHostPort, isCanonicalIpv6, parse), PubkyAuthApprovalViewModel.kt, the relay block of PubkyAuthApprovalSheet.kt, PubkyRepo.parseAuthUrl.
Call sites traced: PubkyAuthRequest.parse from parseGrantSignup, parseSignup (raw Ring relay) and PubkyRepo.parseAuthUrl (SDK-normalized details.relayUrl); all three now pass through the relay check.
CI at this head: build-local, lint, detekt, Greptile green; build-and-test, compose-ui and e2e pending. Static review: on bitkit-android the PR's branch is not built or run by this reviewer, so this rests on the code and on CI.
Ruled out
- Host disguised through user info: the authority is cut at the first
/,?or#and everything through the last@is dropped, the WHATWG way, sohttps://trusted.example@relay/showsrelay; a backslash makes the request invalid rather than shown. - Section silently missing:
parserejects any non-empty relaydisplayRelaycannot render, sorelayUrlis null only when the request has no relay. - Shown relay differing from the one approved:
authorize()re-parses the request and fails withRequesterChangedwhenrelayDisplayUrlchanged. - Rejecting relays the SDK already normalized: SDK output has dot segments resolved, default ports dropped and the listed characters encoded, so only hand-written Ring signup relays can hit the new rejection, as the body states.
Merge confidence: 4/5, no findings and the parser is covered by PubkyAuthRequestTest.kt, but build-and-test and e2e are pending, the sheet has no Compose test, and the branch was not run here.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the session metadata names the model, not a reasoning setting)
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 02355e4.
1 actionable finding — resolve or provide an evidence-backed rebuttal.
The relay section, the fail-closed relay check and the relay re-check in authorize() hold up for the security goal. I tried every way I could find to make the sheet show one host while the SDK delivers to another: user info, backslash, percent-encoded or numeric hosts, non-canonical IPv6, dot segments in any %2e spelling, default, padded or out-of-range ports, and tab or newline. The new check refuses all of them, and I found no case where the displayed relay differs from the real destination. One LOW issue: the check also refuses some relays the SDK already accepts unchanged, so those grant links now fail as an invalid link.
Dependency source inspected: paykit-rs v0.1.1-rc9 (0b9c63d25dbd, matching paykit-android 0.1.1-rc9). In that version parse_pubky_auth_url returns relay_url as the url crate's Url::to_string(). Also pubky-core v0.16.2 (f60e502fb4fc), where parse_relay is Url::parse and the inbox channel adds the channel ID with path_segments_mut, so the displayed path is kept. And rust-url v2.5.8 (d6ea13c5f8e7) for its percent-encode sets. crates.io was not reachable, so these came from GitHub tags.
Validation: a local Kotlin probe of the PR's displayRelay (kotlinc, functions copied verbatim) confirmed F1. I did not run the Gradle suite. CI on this head reports build-and-test, compose-ui and the local e2e jobs green. No test asserts the Compose relay section itself.
Parity: compared the relay flow with the iOS twin #1502 at 7115c8d. It uses the same displayRelay rules, the same rejected characters and the same section order and dividers, so F1 applies there too. This is not a review of the iOS PR.
Gaps: the companion bitkit-e2e-tests repo was not inspected. bitkit-core's own relay parsing on the Ring signup path was not inspected. I relied on its expected url-crate behaviour.
Device testing: not performed in this review.
Suggested additional test cases
- Android, dev regtest build with a Pubky profile, using the PR's setup link: replace
relaywithhttps%3A%2F%2Fhttprelay.pubky.app%2Finbox%2F%3Fx%3D%7By%7D(decodes tohttps://httprelay.pubky.app/inbox/?x={y}). Expected: the sheet opens and RELAY showshttps://httprelay.pubky.app/inbox/?x={y}. At this head an invalid-link toast is expected instead (F1). - Android, same setup with a relay containing an apostrophe in the path, for example
https%3A%2F%2Fhttprelay.pubky.app%2Fo'k%2F. Expected: the sheet showshttps://httprelay.pubky.app/o'k/, not the invalid-link toast.
Findings
- [LOW] Stop rejecting relays the SDK already sends to unchanged — inline at
app/src/main/java/to/bitkit/models/PubkyAuthRequest.kt:161.
Reviewer model: claude-opus-5-5
Reasoning effort: high
There was a problem hiding this comment.
Verdict: ⛔️ Request changes — valid grant links can be rejected before consent.
Findings:
- MEDIUM — Valid normalized relay URLs fail as invalid links,
app/src/main/java/to/bitkit/models/PubkyAuthRequest.kt:186. The filter rejects punctuation across the entire URL, although the pinned SDK preserves apostrophes and carets in paths, and braces, backticks, carets and backslashes in queries. A relay such ashttps://httprelay.staging.pubky.app/inbox/?token={abc}passes SDK parsing, then fails the new display check. Validate by URL component and cover these normalized grant forms. This confirms @piotr-iohk's existing finding with device evidence; no duplicate inline finding.
QA for 02355e4: Android 15 emulator, dev regtest debug build compiled from this head, staging Pubky identity and relay.
Sign in from a cold start and approve to the displayed relay ✅ J1: loading toast, full relay, and successful authorization; the requester SDK confirmed the matching wallet pubky and permissions.
The app showed Loading Your Pubky Profile, then the full relay below requested permissions with PubkyAuthRelayOrigin. Approval completed with PubkyAuthOK.
cold-signin2x.2x.mp4
Requester confirmation, checked in its SDK result:
approved: true
pubky: pubky79effrkbyzggz5xxzbtct1fezh33m7ozdp9s4jt9u35t9yfbsnqo
capabilities: /pub/locks.app/:rw
Show the relay for Ring signup before creating a profile ✅ Case 10: the fresh wallet showed the full relay below permissions; Cancel returned without creating a profile.
The sheet showed the staging homeserver and https://httprelay.staging.pubky.app/inbox/. After cancellation, Profile still offered initial profile setup.
ring-signup2x.2x.mp4
Accept SDK-normalized relay paths and queries ❌ Case 14: the control opened consent, while valid punctuation forms produced the invalid-link toast; all five rejections were confirmed in the app log.
The same grant request was opened with these relay suffixes:
/inbox/— consent opened./inbox/?token={abc}— rejected./inbox/o'connor— rejected./inbox/a^b— rejected./inbox/?token=a`b— rejected./inbox/?token=a\b— rejected.
relay-punctuation2x.2x.mp4
Each rejection reached the new check after SDK parsing:
PubkyAuthApprovalViewModel: Failed to parse auth request [InvalidUrl]
Caused by: java.lang.IllegalArgumentException: Unreadable Pubky auth relay
Not re-driven: manual cases 1–7, relying on the author's device evidence at this exact head. No planned case remains unrun. The changes to translations and approval-time relay comparison were checked in code and focused tests; other locales were not driven on a device.
Coverage: full 576ac143..02355e4, including all changed files, signup/sign-in callers and the pinned SDK URL handling. Read all PR comments and reviews; also checked @talosmachina's review and @piotr-iohk's review.
Twin: synonymdev/bitkit-ios#1502 at 7115c8d matches the relay layout and parser rules, including this rejection. iOS was compared in code; no iOS device run here.
Reviewed by gpt-6.1-sol-high
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Re the MEDIUM finding in the ovi-reviewer review on 02355e4 ("Valid normalized relay URLs fail as invalid links", The relay check now filters per URL component, using rust-url 2.5.8's own sets: the path rejects Proof: Not re-driven on a device; Case 14 needs a re-run on this head. |
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None. The previous valid-relay rejection is fixed. The path/query filters match the pinned rust-url component encoding sets, while authority/path backslashes remain rejected.
QA for 08420a1: Android 15 emulator, dev regtest debug build compiled from this head. Requests were cancelled before authorization.
Accept SDK-normalized relay paths and queries ✅ Case 14: all five previously rejected forms now open consent and show the complete relay unchanged.
Checked the normal relay, an apostrophe and caret in paths, and braces, backtick and backslash in queries. Exact text matched PubkyAuthRelayOrigin in each UI dump; each request cancelled cleanly.
grant-punctuation2x.2x.mp4
Validate raw Ring relay components ✅ Case 15: ambiguous authority/path forms stay invalid; preserved query punctuation opens consent and cancels without creating a profile.
Authority/path backslashes and a query apostrophe produced the invalid-link toast, with Unreadable Pubky auth relay confirmed in the app log. A query backslash remained visible. A relay without a path gained / and preserved braces, a second ?, and a query backslash, checked against its UI dump. Profile still offered initial setup after cancellation.
ring-components2x.2x.mp4
Build, focused PubkyAuthRequestTest and PubkyAuthApproval* tests, detekt and Android Lint passed.
Not repeated: manual display cases 1–7 rely on the author's evidence at 02355e4; J1 cold-start approval and Ring signup case 10 rely on the previous recorded review. Their successful inputs and delivery/layout paths are unchanged. No planned case remains unrun. This delta changes only component validation and its test rows; it adds no layout or translation changes.
Coverage: contiguous delta 02355e4..08420a1, both changed files, the open finding, SDK grant and raw Ring callers, and approval-time reparse comparison.
Twin: synonymdev/bitkit-ios#1502 at 01415be now matches the component-specific fix; compared in code, with no iOS device run here.
Reviewed by gpt-6.1-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 02355e4, including affected code paths, at 08420a1. Baseline: prior review (unchanged approval view model, approval sheet UI, localized strings, changelog, and journey coverage inherited).
No new actionable code findings.
- Relay character validation:
PubkyAuthRequest.displayRelaynow applies per-component rejection matchingrust-url2.5.8(url/src/parser.rs, used bypaykit-rsv0.1.1-rc9andpubkyv0.16.2): backslashes are rejected inauthorityandpath,PATHpercent-encoded characters ("<>{}) are rejected only inpath, andSPECIAL_QUERYpercent-encoded characters ("<>') are rejected only in the query. Verified with an exhaustive Rusturl = "=2.5.8"probe across printable ASCII (0x21..0x7E) in path, query (with and without root path), userinfo, and fragment plus dot-segment, host, port, and IPv6 edge cases (0 mismatches againstUrl::parsewith userinfo/fragment stripped). Also verified thatPubkyAuthApprovalSheet'sasLiteralRequestText()` leaves all newly accepted characters untouched. - Twin parity: Compared against synonymdev/bitkit-ios#1502 at 01415be;
PubkyAuthRequest.displayRelayandPubkyAuthRequestTestsapply the same per-component sets and test cases. - Validation & limitations: Local Gradle unit tests could not run because no Android SDK is installed in this review environment. On 08420a1, CI checks build-and-test, compose-ui / ui-tests, detekt, lint, and build succeeded (a re-triggered
build-and-testjob ande2e-tests-localshards were still in progress at review time).
Ready for device testing once any in-progress CI checks complete and any carried-forward review items are confirmed closed.
Device testing: not performed in this review (code-only). The author reports a Pixel_9 check at 08420a1 passing Case 1 and the five punctuation variants (braces, apostrophe, caret, backtick, and backslash in query); author manual cases 2–7 and journey J1 (signin-cold-start.xml) remain unverified on device.
Earlier findings reconciled at this revision: 1 verified fixed.
Reviewer model: gemini-4-neon
Reasoning effort: high
|
Merged: approved on 08420a1, cases 1, 14 and 15 passed on emulator runs of that head, checks green, no open threads. |
Fixes #1505
Twin: synonymdev/bitkit-ios#1502
Shows which relay receives a Pubky authorization on the approval sheet, as the Figma "Authorize paykit" frame draws it:
RELAYlabel, globe icon, full relay URL with its path.Description
PubkyAuthRequest.relayDisplayUrl: scheme, lower-cased host, port, path and query of the request'srelayURL. User info and fragment are left out, sohttps://trusted.example@relay.example/cannot pass fortrusted.example. It is read the way the Pubky SDK's URL parser reads it; a relay that cannot be read that way with certainty (backslash, non-ASCII, percent-encoded or numeric host, no host) makes the request invalid, so the section is never missing for a request that has a relay.PubkyAuthApprovalSheet: a "Relay" section below the requested permissions on the Authorize and Authorizing steps, with a divider between sections: caption, 16dp globe icon and the URL in the same row layout as the permission rows. The URL wraps instead of truncating and is selectable. Test tagPubkyAuthRelayOrigin(shared with iOS).profile__auth_approval_relayadded in English and all 15 locales.signin-cold-start.xmlgains the relay check.pubky_auth__watch_only_intro_relay). iOS removed that line in47aa7a8cd(twin of feat: refine usdt payment and earn screens #1494), and Figma's Earn frames have none, so it is not ported. The relay is shown on the Authorize step that follows the intro.PubkyAuthApprovalViewModel.authorizealso compares the relay shown with the relay of the re-parsed request before approving.Out of Scope
PubkyAuthApprovalSheet.kt: the rest of the "Authorize paykit" frame (folder/permission icon header, swipe to authorize, avatar in the header). Only the relay block, the section order and the dividers are taken from it.Design
Authorize paykit in the Auth (paykit) flow: the
Relayblock (Section Header, 16px globe icon, 4px gap, URL in Body S semibold). Figma shows a one-line URL and no long-URL state; long URLs wrap.Preview
Pending device run.
QA Notes
Setup
Dev (regtest) debug build, package
to.bitkit.dev, wallet onboarded, a Pubky profile created in Bitkit. The links below are dummy requests: do not tap Authorize.adb shell "am start -a android.intent.action.VIEW -d 'pubkyauth://signin_grant?caps=/pub/locks.app/:rw&relay=https%3A%2F%2Fhttprelay.pubky.app%2Finbox%2F&secret=e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3s&cid=locks.test&cpk=5jsjx1o6fzu6aeeo697r3i5rx15zq41kikcye8wtwdqm4nb4tryo' to.bitkit.dev"Journeys
signin-cold-start.xml— the authorization sheet shows the relay URL with its path (PubkyAuthRelayOrigin) next to a globe icon under the RELAY labelManual Tests
https://httprelay.pubky.app/inbox/(idPubkyAuthRelayOrigin) below the requested permissions; Cancel closes it — J1 needs a live requesting app, this dummy link does notrelay=https%3A%2F%2FRelay.Example.com%3A8443%2Flink%2F→https://relay.example.com:8443/link/caps=/pub/paykit/:rw&x-bitkit-claim=watch-only-account-v1→ Earn intro without a relay line; after Approve, the Authorize step shows the relay; Cancelrelay=https%3A%2F%2Ftrusted.example%40httprelay.pubky.app%2Finbox%2F→https://httprelay.pubky.app/inbox/, notrusted.example@relay=https%3A%2F%2Fevil.example%5C%40httprelay.pubky.app%2Flink→ the sheet showshttps://evil.example/@httprelay.pubky.app/link, or the invalid-link toast; never a URL starting withhttps://httprelay.pubky.apprelay=https%3A%2F%2Fhttprelay.pubky.app%2Fa%7Cb%2F%5Bc%5D%2F→ the RELAY section is present (or the invalid-link toast); never a sheet without itCases 1–3 keep their IDs from the first revision; their expected text changed from the origin to the full URL, so earlier results (none were recorded) would not carry over.
Automated Checks
PubkyAuthRequestTest.kt— the relay display URL keeps scheme, lower-cased host, port, path and query and drops user info and fragment; relays with a backslash, raw IDN, percent-encoded or numeric host, or no host make the request invalid, also on the Ring signup path; a request has a relay display URL whenever it has a relayPubkyAuthApprovalViewModelTest.kt— the loaded state carries the relay URLEvidence
Device screenshots: pending device run
Local checks at
cf1f899af, all passed:./gradlew compileDevDebugKotlin testDevDebugUnitTest detekt lintDevDebug— BUILD SUCCESSFUL; 339 test classes, 6923 tests, 0 failures (PubkyAuthRequestTest37).After review round 2, at
d47852f6c:./gradlew compileDevDebugKotlin testDevDebugUnitTest --tests '*PubkyAuthRequestTest' --tests '*PubkyAuthApproval*' detekt— BUILD SUCCESSFUL;PubkyAuthRequestTest37,PubkyAuthApprovalViewModelTest37, 0 failures. The full suite and Android Lint were last run atcf1f899af.Gaps
Review
An independent review (fresh agent, no implementation context) found two HIGH, three MEDIUM and several LOW items. All were checked against the code before changing anything.
java.net.URI), which disagrees with the Rusturlcrate that delivers the grant: a backslash before@, raw IDN and numeric hosts displayed another host, and characters such as|or[made the section disappear while the request stayed approvable. Fixed:displayRelayextracts the authority the WHATWG way (text between://and the first/,?or#, everything through the last@dropped) and accepts only what Rust leaves unchanged: printable ASCII without backslash or space, a plain host or bracketed IPv6, and no numeric host other than a dotted IPv4. A request whose relay is set but cannot be read this way is now an invalid request, so the sheet never opens for it. The section shows whenever a request has a relay.spkPR. ThespkPR (fix: refuse pubky auth requests for another pubky #2104) adds to the samecompanion objectand test file, so the second of the two to merge needs a textual conflict resolved by keeping both sides. Not reducible without restructuring the file.|and brackets in the path, IPv6, trailing dot, percent-encoded host, numeric hosts, the Ring signup raw path, and "relay set but unreadable" (invalid, not hidden).RelayandDetailsframes use.authorize()now compares the relay as well.signin-cold-start.xmlstates an example of the expected relay string and its position.Round 2 found no HIGH.
urlcrate delivers to the resolved path. A relay with a.or..path segment, in any%2espelling, is now unreadable, so the request is invalid.https://host/).@in the query and after#, upper-case scheme, port 0, port above 65535, default port, dot segments, non-canonical IPv6 andlocalhost:port. Android also has a newline case and a view-model test thatauthorize()fails closed when the re-parsed relay differs from the one shown.Round 3 found no HIGH or MEDIUM and no behaviour bugs, only test gaps. Added rows for
<,>and a backtick,%2eand.%2Esegments, a default port on an IPv6 host, port 65535, upper-case and IPv4-mapped IPv6, and..;x/..%2fsegments that are not dot segments; Android also checks..and%252e%252erelays at parse level. The targeted test class passed.Merge order. This PR and #2104 edit neighbouring lines of the same files. Merge this PR first; #2104 then needs a rebase, keeping both sides of each conflict.
Review round, 2026-11-27.
02355e40d), relay check too strict: real, fixed in08420a11c. The filter rejected',^,{,}and a backtick anywhere, although rust-url 2.5.8 keeps',^,|,[,]unchanged in a path and{,},^, backtick,|and\unchanged in an http(s) query. The check is now per component: the path rejects",<,>, backtick,{,}and\(itsPATHset, plus the backslash it turns into/); the query rejects",<,>and'(SPECIAL_QUERY); a backslash before the query is rejected. My earlier statement that the filter only affected raw Ring signup relays was wrong and is removed.PubkyAuthRequestTestfailed on the old code forhttps://relay.example/o'neil/inbox/and passes now (37 tests); detekt and Android Lint pass./inbox/?token={abc},/inbox/o'connor,/inbox/a^b, backtick and backslash in the query) needs a run on this head.Models used
claude-fable-5-2(reasoning:Not exposed)claude-fable-5-2(reasoning:Not exposed)claude-fable-5-2(reasoning:Not exposed)Metadata note: the sessions report the model id but no reasoning setting; the reviewer model is as reported by the coordinating session.
Device check at 08420a1
Pixel_9, wallet A with a profile, dev debug build,
install -r. Authorize never tapped; each sheet cancelled.PubkyAuthRelayOrigin=https://httprelay.pubky.app/inbox/....?token={abc},.../o'connor,.../a^b,...?token=a`b,...?token=a\b; no invalid-link toast.🤖 Generated with Claude Code