fix: harden shop payment bridge - #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
Hardens the Bitrefill shop payment bridge while preserving the intentional QuickPay behavior shared with Android.
https://embed.bitrefill.comorigin and default HTTPS port.Companion Android PR: synonymdev/bitkit-android#1158
Linked Issues/Tasks
VulnHunter 01b finding 02 (shop WebView any-origin
payment_intent). Finding 03 is accepted product behavior and is not changed here.Screenshot / Video
N/A, security behavior only.
QA Notes
payment_intent: the appropriate Send flow opens with the invoice.embed.bitrefill.comsender cannot invoke the native payment bridge.Focused unit coverage:
ShopOriginTests,ShopPaymentRequestTests, andPaymentNavigationHelperTests. Translation validation passes.