fix: gate shop origin and pin pay - #668
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Greptile SummaryThe PR restricts Bitrefill checkout messages and top-level navigation to trusted HTTPS origins and disables QuickPay when payment PIN protection is enabled.
Confidence Score: 4/5The PR should not merge until the Bitrefill-only navigation policy is scoped so that Shop Discover can still load BTC Map. The shared WebView cancels Shop Discover's initial btcmap.org main-frame request because the new delegate allows only Bitrefill HTTPS origins. Files Needing Attention: Bitkit/Components/ShopWebView.swift
|
| Filename | Overview |
|---|---|
| Bitkit/Components/ShopWebView.swift | Adds origin checks for messages and navigation, but the unconditional Bitrefill policy breaks the shared WebView's BTC Map caller. |
| Bitkit/Utilities/ShopOrigin.swift | Adds HTTPS Bitrefill host validation and sender-origin filtering with appropriate apex and subdomain matching. |
| Bitkit/Utilities/PaymentNavigationHelper.swift | Prevents QuickPay selection when both PIN and payment-PIN protection are enabled. |
| Bitkit/Views/Shop/ShopMain.swift | Rejects empty payment URIs before handing trusted checkout messages to payment parsing. |
| BitkitTests/ShopOriginTests.swift | Covers host and bridge-script validation but does not exercise the shared WebView navigation policy. |
| BitkitTests/PaymentNavigationHelperTests.swift | Covers every boolean combination of the new payment-PIN gate. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ShopWebView initial navigation] --> B{Main frame?}
B -- No --> C[Allow subresource]
B -- Yes --> D{Bitrefill HTTPS origin?}
D -- Yes --> E[Allow checkout]
D -- No --> F[Cancel navigation]
G[Shop Discover: btcmap.org] --> A
F --> H[BTC Map does not load]
Reviews (1): Last reviewed commit: "fix: gate shop origin and pin pay" | Re-trigger Greptile
Co-authored-by: Cursor <cursoragent@cursor.com>
ovitrif
left a comment
There was a problem hiding this comment.
Looks good. Shop checkout rejects payment_intent messages from non-Bitrefill origins, and QuickPay no longer bypasses PIN-for-payments.
|
Simulator QA on
|
Description
Shop checkout only accepts Bitrefill payment requests, and QuickPay now honors PIN protection.
payment_intentmessages only from Bitrefill HTTPS origins (bitrefill.comand subdomains).window.opennavigation off Bitrefill; CDN subresources stay allowed.VulnHunter 01b findings 02 (shop WebView any-origin
payment_intent) and 03 (QuickPay skips PIN). iOS lock already unmounts the main tree, so there is no queued-scan work here.Companion Android PR: synonymdev/bitkit-android#1158
Linked Issues/Tasks
VulnHunter 01b findings 02 and 03.
Screenshot / Video
N/A, security behavior only.
QA Notes
payment_intent: Send Confirm or QuickPay opens with the invoice.regression:PIN off or PIN for payments off + QuickPay on → scan a small LN invoice: QuickPay still opens.Unit tests:
ShopOriginTests.swift,PaymentNavigationHelperTests.swift.Made with Cursor