pos-confirmation-shows-five-codes.md (3922B)
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 # "Confirmation code" shows five codes with no hint which one to read out 18 19 Found by the new `payment_pos_confirmation` scenario, the first thing in this 20 campaign to reach `PayTotpComposable` at all. 21 22 **Severity: low.** It only shows up at merchants that use a point-of-sale 23 confirmation device, and only for the human-readable half of that feature; the 24 NFC half is correct. 25 26 ## What happens 27 28 Paying an order that names an OTP device, the completed purchase reads: 29 30 ``` 31 This transaction was completed successfully 32 Total €1.00 33 Paid -€1.00 34 Confirmation code 35 10179494 36 80755471 37 56332107 38 94603659 39 92288808 40 ``` 41 42 Five eight-digit numbers under a singular label, in a monospace block, with 43 nothing to say what to do with them. 44 45 That is not a bug in the merchant: `TALER_build_pos_confirmation` deliberately 46 returns *every* T-OTP code in the valid time range, newline-separated, so that 47 a device whose clock is off by a step or two still matches 48 (`exchange/src/util/crypto_confirmation.c:254`, "Return all T-OTP codes in 49 range separated by new lines"). `formatTotpPayload` in the wallet splits them 50 and writes all of them into the NDEF record, which is exactly right for a 51 device reading over NFC. 52 53 The display path then prints the same string verbatim: 54 55 ```kotlin 56 // wallet/src/main/java/net/taler/wallet/payment/PayTotpComposable.kt:123 57 Text( 58 text = totpString, 59 fontFamily = FontFamily.Monospace, 60 ... 61 ) 62 ``` 63 64 So where NFC is not available — which is the case `enableNfc == false` exists 65 for — a cashier is shown five candidate codes and has to guess. The middle one 66 is the current time step, but nothing says so. 67 68 ## Reproduce by hand 69 70 Needs a merchant backend you can configure; against the simulator's stack: 71 72 1. Create an OTP device: 73 ```bash 74 curl -X POST http://localhost:8080/instances/sim/private/otp-devices \ 75 -H 'Content-Type: application/json' \ 76 -d '{"otp_device_id":"simpos","otp_device_description":"Till", 77 "otp_algorithm":"TOTP_WITHOUT_PRICE", 78 "otp_key":"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567","otp_ctr":0}' 79 ``` 80 (`otp_key` is RFC 3548 base32, not Crockford.) 81 2. Create an order naming it — `otp_id` is a sibling of `order`, not a field 82 of it: 83 ```bash 84 curl -X POST http://localhost:8080/instances/sim/private/orders \ 85 -H 'Content-Type: application/json' \ 86 -d '{"order":{"amount":"EUR:1","summary":"Till order", 87 "fulfillment_url":"https://example.com/f/1"},"otp_id":"simpos"}' 88 ``` 89 3. Hand the resulting `taler_pay_uri` to the wallet and pay it. 90 4. The completed purchase shows the block above. 91 92 ## Reproduce with the simulator 93 94 ```bash 95 ssh root@tripwire.taler.net 96 cd /opt/taler-sim/driver 97 python3 ../findings/repro_pos_confirmation_codes.py # worker 0 by default 98 SIM_WORKER=4 python3 suite.py payment_pos_confirmation # or the scenario 99 ``` 100 101 ## Suggested fix 102 103 Show the code for the current time step and keep the rest for the NFC payload: 104 `totpString.split("\n")` is already computed in `formatTotpPayload`, so the 105 display can take the middle entry (the list is centred on now) and show the 106 others only in developer mode. If showing all of them is deliberate, the label 107 should be plural and say why there are several.