View Issue Details

IDProjectCategoryView StatusLast Update
0009457Talermerchant backendpublic2025-01-13 22:01
Reporterfefe Assigned ToResolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
PrioritynormalSeveritytweakReproducibilityhave not tried
Status implementingResolutionopen 
Product Versiongit (master) 
Target Versionpost-1.0 
Summary0009457: scary comment about double payment
DescriptionThis is in batch_deposit_transaction (taler-merchant-httpd_post-orders-ID-pay.c):

```
 930 /* NOTE: We might want to check if the order was fully paid concurrently
 931 by some other wallet here, and if so, issue an auto-refund. Right now,
 932 it is possible to over-pay if two wallets literally make a concurrent
 933 payment, as the earlier check for 'paid' is not in the same transaction
 934 scope as this 'insert' operation. */
```

Has this been fixed elsewhere? That sounds like a pretty bad race condition that could be triggered, for example, if there is a network outage, a customer tries to pay again, and then when the network comes back up both transactions are retried automatically.
TagsNo tags attached.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

Christian Grothoff

2025-01-13 22:00

manager   ~0023976

Well, I think the comment is more scary than reality. Not because it is false, but because of the context:
- Before a wallet can pay, it needs to "claim" the contract (using the /claim endpoint).
- Only one wallet can claim an order, only that wallet gets the contract terms.
- Regular wallets would never attempt to pay an order for which they didn't get the contract terms (would be like sending money without knowing how much or for what). I didn't check if we validate that *this* wallet did the claim before in this endpoint, but at least in regular use we can be pretty sure wallets wouldn't pay contracts they didn't claim (and thus don't know the terms).

So the only "practical" situation where this may still matter is if a wallet is backed up, restored to another device, filled with different coins (some _other_ transactions are made so that different coins are chosen), and then the user does a concurrent payment on both devices and manages to get the race. VERY, very unlikely.

That said, the FIXME is correct and we probably should eventually do something about it.

Issue History

Date ModifiedUsernameFieldChange
2025-01-13 16:37fefeNew Issue
2025-01-13 16:37fefeStatusnew => assigned
2025-01-13 16:37fefeAssigned To => Christian Grothoff
2025-01-13 22:00Christian GrothoffNote Added: 0023976
2025-01-13 22:01Christian GrothoffAssigned ToChristian Grothoff =>
2025-01-13 22:01Christian GrothoffSeverityminor => tweak
2025-01-13 22:01Christian GrothoffStatusassigned => implementing
2025-01-13 22:01Christian GrothoffProduct Version => git (master)
2025-01-13 22:01Christian GrothoffTarget Version => post-1.0
2025-03-22 13:09Christian GrothoffCategorymechant backend => merchant backend