View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012273 | Taler | exchange | public | 2026-11-21 10:28 | 2026-11-21 22:49 |
| Reporter | bot-oec [agent] | ||||
| Implementer | Christian Grothoff | ||||
| Estimated effort (hours) | 2 | ||||
| Priority | normal | Severity | major | ||
| Status | implementing | ||||
| Target Version | 1.10 | ||||
| Summary | 0012273: Coins offered to a reserve open request are charged although the exchange refuses it for too low a payment (402) | ||||
| Description | `post-reserves-RESERVE_PUB-open.rst` documents 402 "when the payment offered is insufficient for the requested operation"; such a refusal should charge nothing. `post-reserves-RESERVE_PUB-open.c` debits each coin's contribution (`insert_reserve_open_deposit`) before `exchange_do_reserve_open` computes the cost. When the payment is too low, the procedure returns without an error ("amount paid too low"); the handler commits the transaction and answers 402, so the coins' contributions are kept and nothing is bought. A retry with more is a new request (new `reserve_sig`), which does not count the earlier contributions. The same holds, by reading the code, when nothing needs to change (the reserve is already open long enough, "no change required") and when the request is out of range: the coins are charged, the reserve payment is not. **Steps to reproduce:** 1. A coin of EUR:5 offers EUR:0.015 to keep the reserve open for a year with five purses: 402. 2. Deposit EUR:5 from the coin: expected 200, gets 409 (insufficient residual value). The test `src/testing/test_exchange_api_open_underpay.c` does this; it fails on master at step 2 (expects 200, gets 409). The test will be on branch `dev/oec/formalization-findings` on git.taler.net; a note here will name the commit. **Proposed fix:** compute the cost before charging the coins, or roll the transaction back whenever `exchange_do_reserve_open` does not extend the reserve. A fix of the second kind in `post-reserves-RESERVE_PUB-open.c` (roll back when coins were offered and the reserve was not extended or nothing had to change) makes the test pass; the P2P tests still pass. **Found by:** the formalization of the Taler protocols; the rule violated is (E0) in `spec/p2p.md` with the atomicity of handlers (`spec/notation.md`): a request whose payment is below the cost is refused with `PAYMENT_REQUIRED`, and nothing is charged. | ||||
| Tags | No tags attached. | ||||
| Test: branch `dev/oec/formalization-findings` of exchange.git (git.taler.net), commit f5170f90bce7 "testing: coins of a refused reserve open request (0012273)", on master 7b658d8da. test_exchange_api_open_underpay_{cs,rsa}: a coin of EUR:5 offers EUR:0.015 to keep a reserve open for a year with five purses, which the exchange refuses (402); then EUR:5 are deposited from the coin: expected 200, gets 409 (insufficient residual value). Fails on master at deposit-all. | |
| Proposed patch (exchange master ba48fdeac; with it test_exchange_api_open_underpay_{rsa,cs} from dev/oec/formalization-findings passes, and test_exchange_api_p2p_{rsa,cs} still pass). When coins were offered and the reserve was not extended (payment too low, request out of range, or the reserve already open long enough), the transaction is rolled back, so the coins' contributions are not kept; the reply is the same as before: diff --git a/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c b/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c index 0a76a5e45..07d5a6a21 100644 --- a/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c +++ b/src/exchange/taler-exchange-httpd_post-reserves-RESERVE_PUB-open.c @@ -309,6 +309,20 @@ reserve_open_transaction (void *cls, rsc->reserve_pub); return GNUNET_DB_STATUS_HARD_ERROR; } + if ( (rsc->payments_len > 0) && + ( (GNUNET_TIME_timestamp_cmp (rsc->reserve_expiration, + <, + rsc->desired_expiration)) || + (TALER_amount_is_zero (&rsc->open_cost)) ) ) + { + /* Nothing was bought: the payment was too low, the request out of + range, or the reserve already open long enough. The coins' + contributions inserted above must not be kept. */ + TALER_EXCHANGEDB_rollback (TEH_pg); + *mhd_ret = reply_reserve_open_success (connection, + rsc); + return GNUNET_DB_STATUS_HARD_ERROR; + } return qs; } | |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-11-21 10:28 | bot-oec | New Issue | |
| 2026-11-21 10:28 | bot-oec | Implementer | => oec |
| 2026-11-21 10:28 | bot-oec | Reviewer | => Christian Grothoff |
| 2026-11-21 10:28 | bot-oec | Release signed by | => Christian Grothoff |
| 2026-11-21 10:28 | bot-oec | Deployed by | => Christian Grothoff |
| 2026-11-21 10:28 | bot-oec | Verifier | => oec |
| 2026-11-21 10:28 | bot-oec | Communicator | => CM_7 |
| 2026-11-21 10:47 | bot-oec | Note Added: 0030673 | |
| 2026-11-21 16:15 | oec | Implementer | oec => |
| 2026-11-21 22:26 | Christian Grothoff | Locked by | => Christian Grothoff |
| 2026-11-21 22:26 | Christian Grothoff | Status | new => planning |
| 2026-11-21 22:27 | Christian Grothoff | Implementer | => Christian Grothoff |
| 2026-11-21 22:27 | Christian Grothoff | Reviewer | Christian Grothoff => oec |
| 2026-11-21 22:27 | Christian Grothoff | Target Version | => 1.10 |
| 2026-11-21 22:27 | Christian Grothoff | Status | planning => implementing |
| 2026-11-21 22:27 | Christian Grothoff | Locked by | Christian Grothoff => |
| 2026-11-21 22:27 | Christian Grothoff | Estimated effort (hours) | => 2 |
| 2026-11-21 22:42 | Christian Grothoff | View Status | private => public |
| 2026-11-21 22:49 | bot-oec | Note Added: 0030713 |