deposit-does-not-guard-zero-amounts.md (3801B)
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 deposit screen does not guard zero or below-fee amounts 18 19 Found by the `deposit_flow` scenario; the oracles flagged the internal error 20 and the transaction that came out of it looked wrong, which led to the second 21 half. 22 23 **Severity: low-moderate.** Both halves are reachable by any user with a 24 balance, in a release build, from Settings-free navigation (the balance card's 25 **Deposit** button). 26 27 ## Half one: clearing the amount raises an internal error 28 29 Type an amount, then tap **Reset**. The screen goes back to €0.00 and the app 30 prices the empty deposit: 31 32 ``` 33 {"type":"error","operation":"checkDeposit","id":50,"error":{"code":7001, 34 "hint":"unexpected exception (message: can't sum zero amounts)", 35 "stack":" at sum (<compiled_js>:5729:18) 36 at getCounterpartyEffectiveDepositAmount (<compiled_js>:70346:38)"}} 37 ``` 38 39 `WALLET_UNEXPECTED_EXCEPTION` — wallet-core treating it as a bug rather than as 40 a request it can decline. Nothing is shown; it repeats as the debounce fires. 41 42 ## Half two: an amount at or below the fee produces a zero deposit 43 44 With a deposit fee of EUR:0.01, entering **0.01** and tapping **Make deposit** 45 creates a transaction that reads: 46 47 ``` 48 This transaction is finalizing 49 Chosen amount €0.00 50 Fee -€0.01 51 Amount sent -€0.01 52 ``` 53 54 "Show JSON" confirms the wallet stored exactly that: 55 56 ```json 57 "amountRaw": "EUR:0", 58 "amountEffective": "EUR:0.01" 59 ``` 60 61 So the user asked to deposit one cent, the wallet deposited nothing, charged a 62 cent, and displays a negative "Amount sent" — while the deposit itself goes 63 through to the exchange. 64 65 ## Reproduce by hand 66 67 Needs a wallet with a balance (withdraw once first). 68 69 1. On the main screen tap **Deposit**. 70 2. Pick the bank account offered (e.g. `wallet1`). 71 3. Type `500` — the field fills from the right, so this is €5.00 — then tap 72 **Reset**. With `adb logcat | grep -i "sum zero"` running, the internal 73 error appears within a second or two. 74 4. Now type `1` (€0.01) and tap **Make deposit**. 75 5. The transaction screen shows "Chosen amount €0.00", "Fee −€0.01", 76 "Amount sent −€0.01". 77 78 Expected: an amount of zero is not worth pricing, and an amount that cannot 79 cover the fee should be refused with a message — the screen already has 80 `R.string.amount_invalid` ("Amount invalid") and `amount_excess` for the 81 opposite bound. 82 83 ## Reproduce with the simulator 84 85 ```bash 86 ssh root@tripwire.taler.net 87 cd /opt/taler-sim/driver 88 python3 ../findings/repro_zero_deposit.py 89 ``` 90 91 ## Suggested fix 92 93 In `deposit/DepositAmountComposable.kt`, skip the `checkDeposit` call while the 94 amount is zero (the debounce already has the amount in hand), and disable 95 **Make deposit** until the amount is strictly greater than the fee reported by 96 `checkDeposit`, showing `amount_invalid` otherwise. Mirroring the 97 "Insufficient balance" treatment at the upper bound would make the two 98 boundaries consistent. 99 100 Worth raising with wallet-core as well: `checkDeposit` of a zero amount is a 101 client asking a reasonable question, so a declined request would be a better 102 answer than an unexpected exception.