Properly gate reveal routes behind device re-auth
What changed, and why it matters
This commit fixes a security bug where a malicious app or a crafted launch command could open the wallet's secret-reveal screens without requiring the user to unlock the app first. The patch removes a risky Android entry point and wraps the sensitive screens with a re-authentication check, so the device lock/biometric prompt now blocks direct access.
Users should upgrade to a build containing this commit. Developers should verify that ReauthGate cannot be skipped by hot-restart, background-resume, or intent replay, and consider setting android:exported="false" on MainActivity if no external launch is required. A security advisory should be published describing the bypass and fixed versions.
Security signals we found
Exported MainActivity allowed arbitrary intents to set a route
Sensitive routes '/lws_keys' and '/secret_keys' reachable without device unlock
Previous getInitialRoute()/shouldHandleDeeplinking() mitigation was bypassable
Fix centralizes authentication enforcement via ReauthGate
Removal of duplicate biometric prompt in settings dialog
Evidence from the diff
The commit addresses an authentication-bypass path in a Flutter Android wallet. MainActivity was exported, allowing any third-party app or adb to launch it with an intent carrying a ‘route’ extra or data URI that would navigate directly to ‘/lws_keys’ or ‘/secret_keys’. The previous code tried to null out getInitialRoute() and disable deep-link handling, but Flutter’s Navigator could still honor the launch intent’s route. The fix removes those ineffective overrides and instead uses onGenerateInitialRoutes to force the app to start at the resolved initial route, dropping any cold-start deep link. It also wraps the LwsKeysScreen and SecretKeysScreen route builders with ReauthGate, and removes a duplicate biometric prompt from the settings dialog so the gate is the single enforcement point.
Changed components
android/app/src/main/kotlin/com/example/monero_light_wallet/MainActivity.ktlib/main.dartlib/screens/settings.dartApp Lock / biometric authentication flowRoute navigation / deep-link handlingInspect captured patch +9 / −23
### android/app/src/main/kotlin/com/example/monero_light_wallet/MainActivity.kt
@@ -18,14 +18,6 @@ class MainActivity : FlutterFragmentActivity() {
// time; see build.gradle.kts.
private val storeReviewChannel = "org.magicgrants.wallet/store_review"
- // MainActivity is exported, so any app (or adb) can start it with an intent
- // that names a route, via the "route" extra or a data URI, and reach screens
- // past App Lock. The app takes no links, so ignore both: it always starts at
- // its own initial route, and a new intent never pushes one.
- override fun getInitialRoute(): String? = null
-
- override fun shouldHandleDeeplinking(): Boolean = false
-
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, secureClipboardChannel)
### lib/main.dart
@@ -176,8 +176,10 @@ class _AppRootState extends State<_AppRoot> with WidgetsBindingObserver {
'/unlock': (context) => UnlockScreen(),
'/wallet_home': (context) => WalletHomeScreen(),
'/settings': (context) => SettingsScreen(),
- '/lws_keys': (context) => LwsKeysScreen(),
- '/secret_keys': (context) => SecretKeysScreen(),
+ '/lws_keys': (context) =>
+ ReauthGate(reason: AppLocalizations.of(context)!.settingsAppLockUnlockReason, child: LwsKeysScreen()),
+ '/secret_keys': (context) =>
+ ReauthGate(reason: AppLocalizations.of(context)!.revealSeedAuthReason, child: SecretKeysScreen()),
'/send': (context) => SendScreen(),
'/scan_qr': (context) => ScanQrScreen(),
'/receive': (context) => ReceiveScreen(),
@@ -346,6 +348,11 @@ class _AppRootState extends State<_AppRoot> with WidgetsBindingObserver {
);
},
initialRoute: initialRoute,
+ // Always boot through the resolved initial route; a cold-start deep
+ // link (the launch intent's `route` extra) arrives here and is
+ // dropped — the app exposes no deep-link destination, and letting one
+ // become the initial route would race boot/unlock and skip the lock.
+ onGenerateInitialRoutes: (_) => [_onGenerateRoute(RouteSettings(name: initialRoute))!],
locale: Locale.fromSubtags(languageCode: languageProvider.language),
onGenerateRoute: _onGenerateRoute,
);
### lib/screens/settings.dart
@@ -235,19 +235,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
Future<void> _showViewSecretKeysDialog() async {
final i18n = AppLocalizations.of(context)!;
- if (Platform.isAndroid || Platform.isIOS) {
- final result = await BiometricAuth.authenticateIfAppLockEnabled(
- reason: i18n.revealSeedAuthReason,
- );
- if (result != BiometricAuthResult.authenticated) {
- if (mounted) {
- showBrandToast(context, i18n.settingsAppLockUnableToAuthError);
- }
- return;
- }
- if (!mounted) return;
- }
-
final ok = await showConfirmSheet(
context: context,
icon: Icons.warning_amber_rounded,Why this scored 74/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.