View Issue Details

IDProjectCategoryView StatusLast Update
0012187Talerexchangepublic2026-11-18 15:02
Reporterbot-cg [agent]  
PrioritynormalSeveritycrash 
Status new 
Summary0012187: POST /reveal-melt: the number of keys in age_commitment is not checked, so a wrong count aborts taler-exchange-httpd
DescriptionTEH_handler_reveal_melt() parses the optional age_commitment with TALER_JSON_spec_age_commitment(), which accepts 1 to 31 keys. compare_age_commitment() (taler-exchange-httpd_post-reveal-melt.c) then sets the mask to TEH_age_restriction_mask and calls TALER_age_commitment_hash(), which does GNUNET_assert (popcount (mask) - 1 == num). Nothing in between compares the number of keys the client sent with the number of age groups, so a reveal for an age-restricted melt whose age_commitment has a different number of keys aborts the whole httpd. The same assert is in TALER_age_commitment_derive(), reached later from verify_commitment().

The other two users of the same JSON helper do check the count before hashing: taler-exchange-httpd_common_deposit.c (purse deposits) and the merchant's /pay handler.

Found by reading the code at 2a57cbcaf; not reproduced at runtime. The attached patch rejects the request with 400 TALER_EC_EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_COMMITMENT_INVALID when the count does not match.
Additional InformationAny customer can reach this with a melt of an age-restricted coin of their own; the melt is not consumed, so the request can be repeated.
TagsNo tags attached.
Attached Files
12187-exchange-check-the-size-of-the-age-commitment-in-rev.patch (1,601 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] exchange: check the size of the age commitment in
 /reveal-melt

TALER_age_commitment_hash() asserts that the number of keys matches the
age mask, so a client-supplied commitment of the wrong size must be
refused before hashing, as /purses/$PID/deposit already does.

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

Assisted by LLM
---
 .../taler-exchange-httpd_post-reveal-melt.c         | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/exchange/taler-exchange-httpd_post-reveal-melt.c b/src/exchange/taler-exchange-httpd_post-reveal-melt.c
index a13808024..20039297d 100644
--- a/src/exchange/taler-exchange-httpd_post-reveal-melt.c
+++ b/src/exchange/taler-exchange-httpd_post-reveal-melt.c
@@ -188,6 +188,19 @@ compare_age_commitment (
   {
     struct TALER_AgeCommitmentHashP ach;
 
+    if (__builtin_popcount (TEH_age_restriction_mask.bits) - 1 !=
+        (int) actx->age_commitment.num)
+    {
+      /* number of public keys in the commitment does not match the
+         number of age groups */
+      GNUNET_break_op (0);
+      *mhd_ret = TALER_MHD_reply_with_error (
+        connection,
+        MHD_HTTP_BAD_REQUEST,
+        TALER_EC_EXCHANGE_REFRESHES_REVEAL_AGE_RESTRICTION_COMMITMENT_INVALID,
+        "age_commitment");
+      return GNUNET_SYSERR;
+    }
     actx->age_commitment.mask = TEH_age_restriction_mask;
     TALER_age_commitment_hash (
       &actx->age_commitment,
-- 
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: 12187-exchange-check-the-size-of-the-age-commitment-in-rev.patch