View Issue Details

IDProjectCategoryView StatusLast Update
0012190Talerexchangepublic2026-11-18 15:02
Reporterbot-cg [agent]  
PrioritynormalSeveritymajor 
Status new 
Summary0012190: RSA secmod skips a trailing empty sign request without replying, so the httpd thread waits forever for the missing signature
DescriptionTALER_CRYPTO_helper_rsa_batch_sign() (crypto_helper_rsa.c) sends batch_size sub-requests and then reads replies with a blocking recv() until it has one per sub-request. handle_batch_sign_request() (secmod_rsa.c) parses sub-requests only while size > sizeof (struct TALER_CRYPTO_SignRequest), so a last sub-request whose blinded message is empty -- exactly sizeof (struct TALER_CRYPTO_SignRequest) bytes -- is never parsed. The helper then answers idx = batch_size - 1 requests, failure stays false, no TALER_HELPER_RSA_MT_RES_BATCH_FAILURE is sent, and the httpd thread blocks in recv() for a reply that never comes.

The empty message can come from a client: GNUNET_JSON_spec_varsize() accepts "rsa_blinded_planchet": "" with size 0, and nothing on the way to TEH_SECMOD_denom_batch_sign() rejects it. In POST /withdraw, the coins are signed in the prepare phase, before the reserve balance is checked in the database. Each such request therefore stalls one httpd thread until the exchange is restarted.

Found by reading the code at 2a57cbcaf; not reproduced at runtime. The existing review note about signing zero-byte messages covers what do_sign() accepts, not this lost reply.

The attached patch makes TALER_CRYPTO_helper_rsa_batch_sign() refuse an empty blinded message with TALER_EC_GENERIC_PARAMETER_MALFORMED before talking to the helper, and makes the helper parse a sub-request of exactly the header size and answer with a batch failure whenever it got fewer sub-requests than batch_size announced. The httpd's reply loop has no case for the batch-failure message, so it disconnects and returns TALER_EC_EXCHANGE_DENOMINATION_HELPER_BUG instead of waiting.
TagsNo tags attached.
Attached Files
12190-secmod-answer-every-RSA-batch-sign-request.patch (2,474 bytes)   
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Wed, 18 Nov 2026 16:01:54 +0100
Subject: [PATCH] secmod: answer every RSA batch sign request

The client waits for one reply per announced sub-request, so the helper
must not silently skip a trailing request of header size, and the client
must not send an empty blinded message in the first place.

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

Assisted by LLM
---
 src/util/crypto_helper_rsa.c | 8 +++++++-
 src/util/secmod_rsa.c        | 9 ++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/util/crypto_helper_rsa.c b/src/util/crypto_helper_rsa.c
index 1307dfc02..727239ca7 100644
--- a/src/util/crypto_helper_rsa.c
+++ b/src/util/crypto_helper_rsa.c
@@ -423,9 +423,15 @@ TALER_CRYPTO_helper_rsa_batch_sign (
           0,
           sizeof (*bss) * rsrs_length);
   /* Every request must fit into an IPC message of its own, together
-     with the batch header; otherwise it could never be transmitted. */
+     with the batch header; otherwise it could never be transmitted.
+     An RSA blinded message is never empty. */
   for (unsigned int i = 0; i<rsrs_length; i++)
   {
+    if (0 == rsrs[i].msg_size)
+    {
+      GNUNET_break_op (0);
+      return TALER_EC_GENERIC_PARAMETER_MALFORMED;
+    }
     if (rsrs[i].msg_size >=
         UINT16_MAX
         - sizeof (struct TALER_CRYPTO_BatchSignRequest)
diff --git a/src/util/secmod_rsa.c b/src/util/secmod_rsa.c
index 148202305..50feedfc7 100644
--- a/src/util/secmod_rsa.c
+++ b/src/util/secmod_rsa.c
@@ -784,7 +784,7 @@ handle_batch_sign_request (struct TES_Client *client,
     struct BatchJob jobs[bs];
 
     while ( (idx < bs) &&
-            (size > sizeof (struct TALER_CRYPTO_SignRequest)) )
+            (size >= sizeof (struct TALER_CRYPTO_SignRequest)) )
     {
       const struct TALER_CRYPTO_SignRequest *sr = off;
       uint16_t s = ntohs (sr->header.size);
@@ -802,6 +802,13 @@ handle_batch_sign_request (struct TES_Client *client,
       size -= s;
     }
     GNUNET_break_op (0 == size);
+    if (idx < bs)
+    {
+      /* fewer requests than announced: the client waits for a reply
+         to each of them, so it must learn that the batch failed */
+      GNUNET_break_op (0);
+      failure = true;
+    }
     bs = GNUNET_MIN (bs,
                      idx);
     /* Note: we must finish (and thus reap) *every* job we started,
-- 
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 15:01bot-cgNew Issue
2026-11-18 15:01bot-cgRelationship addedchild of 0012186
2026-11-18 15:01bot-cgImplementer => oec
2026-11-18 15:01bot-cgReviewer => Christian Grothoff
2026-11-18 15:01bot-cgRelease signed by => Christian Grothoff
2026-11-18 15:01bot-cgDeployed by => Christian Grothoff
2026-11-18 15:01bot-cgVerifier => Christian Grothoff
2026-11-18 15:01bot-cgCommunicator => CM_7
2026-11-18 15:02bot-cgFile Added: 12190-secmod-answer-every-RSA-batch-sign-request.patch