mailbox-private-keys-written-to-log.md (3471B)
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 # The mailbox's private keys are written to the log every 30 seconds 18 19 Noticed in a simulator log while investigating something else: with developer 20 mode on, the wallet logs its whole mailbox configuration — including both 21 private keys — at **error** level, every 30 seconds. 22 23 **Severity: moderate.** It is developer-mode only, but developer mode is also 24 where "Debug log → Save internal log" lives, and that export is exactly what a 25 user is asked for when reporting a problem. Sending that file hands over the 26 keys to the wallet's mailbox. 27 28 ## What happens 29 30 ``` 31 E taler-wallet: Rereshing mailbox MailboxConfiguration( 32 mailboxBaseUrl=https://mailbox.gnunet.org, 33 privateKey=K5ZN6AW2WQVE4T7G22EXPNR1HCBZZAVKMP3JXEXTGF5X1TV2B0CG, 34 privateEncryptionKey=9Q59Z0H38JB4N4F40VXAB33Q799KN6XTAW1ARN2H7DTMM9Q2H5H0, 35 hAddress=E4RBDRX49F7M2V3H1JJVQ0MN0QVVJHTRMEG4300ZCWMXEPQMQWXMHZ7C80VBHVM69HX7Y59X05F70KNGR1K94DK87TT8BGA11TX5X2G, 36 expiration=Timestamp(s=1823806854), payUri=null) 37 ``` 38 39 `MailboxConfiguration` is a data class, so string interpolation prints every 40 field. 41 42 ## Reproduce by hand 43 44 1. Install the wallet and enable **Developer mode** in Settings. 45 2. Run `adb logcat | grep -i "Rereshing mailbox"` (the typo is in the source). 46 3. Wait up to 30 seconds. The line appears, with `privateKey=` and 47 `privateEncryptionKey=` in full, and repeats every 30 seconds. 48 49 The same content reaches a file through Settings → **Debug log**, which runs 50 `logcat -d *:V`. 51 52 ## Reproduce with the simulator 53 54 ```bash 55 ssh root@tripwire.taler.net 56 cd /opt/taler-sim/driver 57 python3 ../findings/repro_mailbox_private_keys_in_log.py 58 ``` 59 60 ## Why 61 62 `wallet/src/main/java/net/taler/wallet/mailbox/MailboxManager.kt:146`: 63 64 ```kotlin 65 fun refreshMailbox(config: MailboxConfiguration) { 66 67 Log.e(TAG, "Rereshing mailbox ${config}") 68 ``` 69 70 Left-over debug output: error level, no `BuildConfig.DEBUG` guard, and a typo 71 in the message. `MailboxManager.start()` schedules `refreshMailbox` every 30 72 seconds while `isDevMode()` is true (`MailboxManager.kt:82-98`). 73 74 ## Suggested fix 75 76 Delete the line. If a trace is wanted, log the base URL alone and at debug 77 level: 78 79 ```kotlin 80 Log.d(TAG, "refreshing mailbox at ${config.mailboxBaseUrl}") 81 ``` 82 83 Worth considering alongside it: give `MailboxConfiguration` a `toString()` that 84 redacts the two key fields, so no future interpolation can leak them. 85 86 ## Also worth deciding 87 88 `MainViewModel.onInitReceived` calls `mailboxManager.start()` unconditionally, 89 and `start()` calls `loadMailbox()` with a hardcoded 90 `https://mailbox.gnunet.org`. Every wallet start therefore contacts that host, 91 in release builds too, before the user has asked for anything to do with 92 messaging. Whether that is intended is a product decision, but it is worth 93 being deliberate about.