fix: open external links outside the app so the PIN lock can show (#3737)
What changed, and why it matters
This update changes how the app opens web links so they launch in the device's regular browser instead of an embedded browser sheet. The problem was that on iOS the embedded sheet (SFSafariViewController) hid the app from normal background/foreground events, so when a user returned from viewing a link the wallet reappeared without asking for the PIN. That could let someone with brief physical access to an unlocked phone browse back to the wallet without re-entering the PIN. The patch forces links to open externally, restoring the normal app lifecycle and letting the PIN lock screen appear.
Verify that all remaining launchUrl/launchUrlString calls in the codebase use externalApplication or another mode that preserves lifecycle events, and confirm the PIN lock triggers reliably after returning from any browser on both iOS and Android. Consider adding a regression test for lifecycle transitions during external browsing.
Security signals we found
PIN/biometric lock bypass on iOS when returning from in-app browser
Use of SFSafariViewController default launch mode suppressing Flutter lifecycle events
Physical-access attack vector on an already-unlocked device
Patch applies a uniform remediation pattern across multiple link-opening call sites
Evidence from the diff
The commit replaces default launchUrl/launchUrlString calls with LaunchMode.externalApplication across nine UI files. Default mode on iOS uses SFSafariViewController, which runs as a separate process and does not propagate AppLifecycleState changes to the Flutter engine while visible. Consequently, returning to the app from the in-app browser did not trigger the wallet’s background-lock logic. Using externalApplication opens the URL in Safari or another browser, keeping the app in the background lifecycle state and allowing the existing PIN lock to engage when the user returns. The commit message references GHSA-329m-5v92-587r and internal ticket CW-1707.
Changed components
lib/cake_pay/src/widgets/link_extractor.dartlib/new-ui/pages/about_page.dartlib/new-ui/widgets/changelog_modal.dartlib/new-ui/widgets/coins_page/zcash_migration_modal.dartlib/new-ui/widgets/scan_page/network_list.dartlib/src/screens/integrations/deuro/savings_page.dartlib/src/screens/welcome/welcome_page.dartlib/view_model/anonpay_details_view_model.dartlib/view_model/transaction_details_view_model.dartInspect captured patch +17 / −17
### lib/cake_pay/src/widgets/link_extractor.dart
@@ -48,7 +48,7 @@ class ClickableLinksText extends StatelessWidget {
style: linkStyle,
recognizer: TapGestureRecognizer()
..onTap = () {
- launchUrl(Uri.parse(url));
+ launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
},
),
);
### lib/new-ui/pages/about_page.dart
@@ -111,14 +111,14 @@ class _AboutPageState extends State<AboutPage> {
ListItemRegularRow(
keyValue: "official website",
label: "Official Website",
- onTap: () => launchUrl(Uri.https("cakewallet.com")),
+ onTap: () => launchUrl(Uri.https("cakewallet.com"), mode: LaunchMode.externalApplication),
trailingIconPath: "assets/new-ui/link_arrow.svg",
foregroundColor: Theme.of(context).colorScheme.primary,
trailingIconSize: 10),
ListItemRegularRow(
keyValue: "docs",
label: "Cake Docs",
- onTap: () => launchUrl(Uri.https("docs.cakewallet.com")),
+ onTap: () => launchUrl(Uri.https("docs.cakewallet.com"), mode: LaunchMode.externalApplication),
trailingIconPath: "assets/new-ui/link_arrow.svg",
foregroundColor: Theme.of(context).colorScheme.primary,
trailingIconSize: 10)
@@ -127,21 +127,21 @@ class _AboutPageState extends State<AboutPage> {
ListItemRegularRow(
keyValue: "gh",
label: "GitHub",
- onTap: () => launchUrl(Uri.https("github.com", "cake-tech")),
+ onTap: () => launchUrl(Uri.https("github.com", "cake-tech"), mode: LaunchMode.externalApplication),
trailingIconPath: "assets/new-ui/link_arrow.svg",
foregroundColor: Theme.of(context).colorScheme.primary,
trailingIconSize: 10),
ListItemRegularRow(
keyValue: "twitter",
label: "X (Twitter)",
- onTap: () => launchUrl(Uri.https("twitter.com", "cakewallet")),
+ onTap: () => launchUrl(Uri.https("twitter.com", "cakewallet"), mode: LaunchMode.externalApplication),
trailingIconPath: "assets/new-ui/link_arrow.svg",
foregroundColor: Theme.of(context).colorScheme.primary,
trailingIconSize: 10),
ListItemRegularRow(
keyValue: "tg",
label: "Telegram",
- onTap: () => launchUrl(Uri.https("t.me", "cakewallet")),
+ onTap: () => launchUrl(Uri.https("t.me", "cakewallet"), mode: LaunchMode.externalApplication),
trailingIconPath: "assets/new-ui/link_arrow.svg",
foregroundColor: Theme.of(context).colorScheme.primary,
trailingIconSize: 10)
### lib/new-ui/widgets/changelog_modal.dart
@@ -109,7 +109,7 @@ class _ChangelogModalState extends State<ChangelogModal> {
NewPrimaryButton(
onPressed: () {
try {
- launchUrl(Uri.https("docs.cakewallet.com", "/release-notes"));
+ launchUrl(Uri.https("docs.cakewallet.com", "/release-notes"), mode: LaunchMode.externalApplication);
} catch (_) {}
},
text: S.of(context).view_more_info,
### lib/new-ui/widgets/coins_page/zcash_migration_modal.dart
@@ -146,7 +146,7 @@ class ZcashMigrationModal extends StatelessWidget {
void _launchDocs() {
try {
- launchUrl(Uri.parse("https://docs.cakewallet.com/cryptos/zcash/ironwood-migration"));
+ launchUrl(Uri.parse("https://docs.cakewallet.com/cryptos/zcash/ironwood-migration"), mode: LaunchMode.externalApplication);
} catch (_) {}
}
}
### lib/new-ui/widgets/scan_page/network_list.dart
@@ -97,7 +97,7 @@ class ScanPageNetworkList extends StatelessWidget {
subtitle: S.of(context).wc_desc,
trailingWidget: _externalLinkIcon(context),
onTap: () {
- launchUrl(Uri.https("walletconnect.com"));
+ launchUrl(Uri.https("walletconnect.com"), mode: LaunchMode.externalApplication);
}),
ListItemRegularRow(
iconPath: "assets/new-ui/ocp_min.svg",
@@ -106,7 +106,7 @@ class ScanPageNetworkList extends StatelessWidget {
subtitle: S.of(context).ocp_desc,
trailingWidget: _externalLinkIcon(context),
onTap: () {
- launchUrl(Uri.https("opencryptopay.io"));
+ launchUrl(Uri.https("opencryptopay.io"), mode: LaunchMode.externalApplication);
})
]
})
### lib/src/screens/integrations/deuro/savings_page.dart
@@ -103,7 +103,7 @@ class DEuroSavingsPage extends BasePage {
InfoChip(
label: S.of(context).website,
icon: CupertinoIcons.globe,
- onPressed: () => launchUrlString("https://deuro.com/"),
+ onPressed: () => launchUrlString("https://deuro.com/", mode: LaunchMode.externalApplication),
)
],
),
@@ -331,15 +331,15 @@ class DEuroSavingsPage extends BasePage {
title: S.of(context).deuro_savings_balance,
content: S.of(context).deuro_savings_balance_tooltip,
key: 'savings_tooltip',
- onLearnMorePressed: () => launchUrlString("https://deuro.com/#faq"),
+ onLearnMorePressed: () => launchUrlString("https://deuro.com/#faq", mode: LaunchMode.externalApplication),
);
void _onInterestTooltipPressed(BuildContext context) => _showTooltip(
context,
title: S.of(context).deuro_savings_collect_interest,
content: S.of(context).deuro_savings_collect_interest_tooltip,
key: 'interest_tooltip',
- onLearnMorePressed: () => launchUrlString("https://deuro.com/#faq"),
+ onLearnMorePressed: () => launchUrlString("https://deuro.com/#faq", mode: LaunchMode.externalApplication),
);
void _showTooltip(
@@ -387,7 +387,7 @@ class DEuroSavingsPage extends BasePage {
onRightActionButtonPressed: () => Navigator.of(bottomSheetContext).pop(),
doubleActionLeftButtonText: S.of(context).learn_more,
leftActionButtonKey: ValueKey('deuro_page_tooltip_dialog_welcome_learn_more_button_key'),
- onLeftActionButtonPressed: () => launchUrlString("https://deuro.com/what-is-deuro.html"),
+ onLeftActionButtonPressed: () => launchUrlString("https://deuro.com/what-is-deuro.html", mode: LaunchMode.externalApplication),
showDisclaimerText: _dEuroViewModel.isFistTime,
),
);
### lib/src/screens/welcome/welcome_page.dart
@@ -36,7 +36,7 @@ class WelcomePage extends BasePage {
size: 26,
),
onPressed: () async {
- await launchUrl(_url);
+ await launchUrl(_url, mode: LaunchMode.externalApplication);
},
);
}
### lib/view_model/anonpay_details_view_model.dart
@@ -74,6 +74,6 @@ abstract class AnonpayDetailsViewModelBase with Store {
items.add(TrackTradeListItem(
title: S.current.track,
value: invoiceDetail.clearnetStatusUrl,
- onTap: () => launchUrlString(invoiceDetail.clearnetStatusUrl)));
+ onTap: () => launchUrlString(invoiceDetail.clearnetStatusUrl, mode: LaunchMode.externalApplication)));
}
}
### lib/view_model/transaction_details_view_model.dart
@@ -506,7 +506,7 @@ abstract class TransactionDetailsViewModelBase with Store {
String get explorerDescription => S.current.view_transaction_on + Uri.parse(_explorerUrl).host;
void launchExplorer() {
- launchUrl(Uri.parse(_explorerUrl));
+ launchUrl(Uri.parse(_explorerUrl), mode: LaunchMode.externalApplication);
}
void addBumpFeesListItems(TransactionInfo tx, String rawTransaction) {Why this scored 64/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.