taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

wallet-lock-opens-when-the-credential-is-gone.md (4770B)


      1 <!--
      2   This file is part of GNU Taler
      3   (C) 2026 Taler Systems S.A.
      4 
      5   GNU Taler is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 -->
     16 
     17 # "Protect access to wallet" opens the wallet when the device credential is gone
     18 
     19 Found by the `wallet_lock_without_credential` scenario, written to see what a
     20 locked wallet does when the screen lock it depends on is taken away.
     21 
     22 **Severity: moderate, security-relevant, release builds.** The lock screen
     23 still appears, so the user has every reason to believe the wallet is
     24 protected, and it opens on a single tap with no authentication of any kind.
     25 
     26 ## What happens
     27 
     28 1. With a device credential set (a PIN is enough), Settings → **Protect
     29    access to wallet** can be switched on. The app checks that the device can
     30    authenticate before allowing this (`enableBiometrics` in
     31    `settings/SettingsScreen.kt` requires `BIOMETRIC_SUCCESS`).
     32 2. Restarting the app now covers it with `BiometricOverlay`: a shield and a
     33    single **Tap to unlock** button.
     34 3. The user later removes their screen lock — Settings → Security → screen
     35    lock → None, which is an ordinary thing to do and needs the credential
     36    they still have.
     37 4. The wallet still shows the lock screen on every start. **Tapping "Tap to
     38    unlock" opens it**, with no prompt, no credential, nothing.
     39 
     40 Measured, on a device whose credential was removed after the lock was
     41 switched on:
     42 
     43 ```
     44 after a restart with a credential:    locked=True
     45 cleared the device credential
     46 after a restart with no credential:   locked=True
     47 after tapping unlock:                 still locked=False   <- wallet open
     48 ```
     49 
     50 The code says so plainly:
     51 
     52 ```kotlin
     53 // wallet/src/main/java/net/taler/wallet/main/MainActivity.kt:281
     54 override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
     55     super.onAuthenticationError(errorCode, errString)
     56     if (errorCode == ERROR_NO_BIOMETRICS || errorCode == ERROR_NO_DEVICE_CREDENTIAL) {
     57         model.unlockWallet()
     58     }
     59     Toast.makeText(this@MainActivity, getString(R.string.biometric_auth_error, errString), LENGTH_SHORT).show()
     60 }
     61 ```
     62 
     63 Unlocking on `ERROR_NO_BIOMETRICS` / `ERROR_NO_DEVICE_CREDENTIAL` is
     64 presumably there so that nobody is locked out of their own money — which is a
     65 real concern, since the only other way back in is clearing the app's data,
     66 and that destroys the coins. But as written, the protection disappears
     67 silently: the preference stays on, the overlay keeps appearing, and anyone
     68 holding the phone gets in.
     69 
     70 ## Reproduce by hand
     71 
     72 On a device or emulator with a screen lock:
     73 
     74 1. Settings → **Protect access to wallet** → on. (The switch refuses if the
     75    device has no credential; that part is correct.)
     76 2. Close and reopen the wallet: the shield screen appears, and unlocking asks
     77    for the PIN or fingerprint.
     78 3. In the *system* settings, remove the screen lock (Security → Screen lock →
     79    None).
     80 4. Reopen the wallet. The shield screen appears as before. Tap **Tap to
     81    unlock**: the wallet opens immediately, showing the balance, with no
     82    authentication.
     83 
     84 On an emulator the same thing without touching the system UI:
     85 
     86 ```bash
     87 adb shell locksettings set-pin 1234     # before step 1
     88 adb shell locksettings clear --old 1234 # instead of step 3
     89 ```
     90 
     91 ## Reproduce with the simulator
     92 
     93 ```bash
     94 ssh root@tripwire.taler.net
     95 cd /opt/taler-sim/driver
     96 python3 ../findings/repro_wallet_lock_bypass.py                  # worker 0
     97 SIM_WORKER=4 SIM_DESTRUCTIVE=1 python3 suite.py wallet_lock_without_credential
     98 ```
     99 
    100 The scenario sets a PIN, switches the lock on, clears the PIN, restarts the
    101 app and reports `locked=` at each step. It clears the device credential again
    102 whatever happens, because the setting is device-wide.
    103 
    104 ## Suggested fix
    105 
    106 Do not treat "this device cannot authenticate" as "this user is
    107 authenticated". When the overlay finds that `canAuthenticate()` no longer
    108 returns `BIOMETRIC_SUCCESS`, say so on the overlay and offer to turn the
    109 protection off explicitly — a deliberate act by the user, which also clears
    110 the preference, instead of a silent unlock that leaves the switch on. The
    111 escape hatch stays (nobody is locked out), but the user is told that the
    112 protection is gone and the UI stops claiming otherwise.