View Issue Details

IDProjectCategoryView StatusLast Update
0012213Talerexchangepublic2026-11-18 16:41
Reporterbot-cg [agent]  
PrioritynormalSeverityminor 
Status new 
Product Versiongit (master) 
Summary0012213: Denomination helper clients do not bound failure replies by the batch, and accept a failure with TALER_EC_NONE as success
DescriptionIn TALER_CRYPTO_helper_rsa_batch_sign(), TALER_CRYPTO_helper_cs_batch_sign() and TALER_CRYPTO_helper_cs_r_batch_derive() (src/util/crypto_helper_rsa.c, crypto_helper_cs.c), the signature replies are refused once the batch is finished, but the *_FAILURE replies are not: each one increments wpos unconditionally. A failure reply after the last expected one leaves wpos past rend, so in the next sub-batch the replies are stored at the wrong positions, and with enough of them wpos never equals rend again and bss[] / crps[] are written past their end.

Separately, the error code of a failure reply is used as is. A failure with ec == TALER_EC_NONE that completes the batch makes the function return TALER_EC_NONE although some blinded_sig entries are still NULL, which the callers then dereference.

Both need a misbehaving helper process, so this is only reachable over the local IPC. Confirmed by reading the code at 2a57cbcaf.

The attached patch makes each failure branch refuse a reply after the batch is finished, as the signature branches already do, and maps TALER_EC_NONE in a failure reply to TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG.
Additional InformationThe finished check is also part of patch 302 (SECMOD-11) of the exchange review notes, which in addition changes the handling of a closed helper connection; the two touch the same lines in the failure branches.
TagsNo tags attached.
Attached Files
12213-util-bound-and-check-failure-replies-from-the-denomi.patch (3,826 bytes)   
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Wed, 18 Nov 2026 17:41:26 +0100
Subject: [PATCH] util: bound and check failure replies from the denomination
 helpers

A failure reply after the last expected one moved the write position
past the batch, and a failure carrying TALER_EC_NONE passed for success
with signatures missing.

Issue: https://bugs.taler.net/n/12213

Assisted by LLM
---
 src/util/crypto_helper_cs.c  | 26 ++++++++++++++++++++++++++
 src/util/crypto_helper_rsa.c | 13 +++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/src/util/crypto_helper_cs.c b/src/util/crypto_helper_cs.c
index c7fb2a8f9..44efe90f5 100644
--- a/src/util/crypto_helper_cs.c
+++ b/src/util/crypto_helper_cs.c
@@ -615,11 +615,24 @@ more:
             do_disconnect (dh);
             return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
           }
+          if (finished)
+          {
+            /* more replies than requests in this batch */
+            GNUNET_break_op (0);
+            do_disconnect (dh);
+            return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
+          }
           {
             const struct TALER_CRYPTO_SignFailure *sf =
               (const struct TALER_CRYPTO_SignFailure *) buf;
 
             ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
+            if (TALER_EC_NONE == ec)
+            {
+              /* a failure must not pass for success */
+              GNUNET_break_op (0);
+              ec = TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
+            }
             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                         "Signing %u failed with status %d!\n",
                         wpos,
@@ -864,11 +877,24 @@ more:
             do_disconnect (dh);
             return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
           }
+          if (finished)
+          {
+            /* more replies than requests in this batch */
+            GNUNET_break_op (0);
+            do_disconnect (dh);
+            return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
+          }
           {
             const struct TALER_CRYPTO_RDeriveFailure *rdf =
               (const struct TALER_CRYPTO_RDeriveFailure *) buf;
 
             ec = (enum TALER_ErrorCode) (int) ntohl (rdf->ec);
+            if (TALER_EC_NONE == ec)
+            {
+              /* a failure must not pass for success */
+              GNUNET_break_op (0);
+              ec = TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
+            }
             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                         "R derivation %u failed with status %d!\n",
                         wpos,
diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c
index 1307dfc02..a6c0f845d 100644
--- a/src/util/crypto_helper_rsa.c
+++ b/src/util/crypto_helper_rsa.c
@@ -622,11 +622,24 @@ more:
             do_disconnect (dh);
             return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
           }
+          if (finished)
+          {
+            /* more replies than requests in this batch */
+            GNUNET_break_op (0);
+            do_disconnect (dh);
+            return TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
+          }
           {
             const struct TALER_CRYPTO_SignFailure *sf =
               (const struct TALER_CRYPTO_SignFailure *) buf;
 
             ec = (enum TALER_ErrorCode) (int) ntohl (sf->ec);
+            if (TALER_EC_NONE == ec)
+            {
+              /* a failure must not pass for success */
+              GNUNET_break_op (0);
+              ec = TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG;
+            }
             GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                         "Signing %u failed with status %d!\n",
                         wpos,
-- 
2.47.3

Required notifications

Address or linkRemarkAdded byNotifiedActions

Relationships

child of 0012186 new Unchecked array lengths and counts in exchange, merchant and anastasis: review after 2a57cbcaf [meta] 

Activities

Issue History

Date ModifiedUsernameFieldChange
2026-11-18 16:41bot-cgNew Issue
2026-11-18 16:41bot-cgRelationship addedchild of 0012186
2026-11-18 16:41bot-cgImplementer => oec
2026-11-18 16:41bot-cgReviewer => Christian Grothoff
2026-11-18 16:41bot-cgRelease signed by => Christian Grothoff
2026-11-18 16:41bot-cgDeployed by => Christian Grothoff
2026-11-18 16:41bot-cgVerifier => oec
2026-11-18 16:41bot-cgCommunicator => CM_7
2026-11-18 16:41bot-cgFile Added: 12213-util-bound-and-check-failure-replies-from-the-denomi.patch