View Issue Details

IDProjectCategoryView StatusLast Update
0012214Talerexchangepublic2026-11-18 16:43
Reporterbot-cg [agent]  
Implementeroec  
PrioritynormalSeverityminor 
Status implementing 
Product Versiongit (master) 
Target Version1.7 
Summary0012214: libtalerexchange: the age_mask of a /keys denomination is not validated, and withdrawing from it aborts the client
Descriptionparse_denomination_group() and parse_denom_pub() (src/json/json_helper.c) accept any 32-bit age_mask from the exchange. The age restriction code assumes that a non-empty mask has bit 0 set: TALER_age_restriction_from_secret() (src/util/age_restriction.c) asserts it, and the number of age groups, and so the number of keys in a commitment, is derived from the mask's bits on that basis. The withdraw client (exchange_api_post-withdraw.c) calls TALER_age_restriction_from_secret() with the denomination's mask, so a /keys reply with, say, "age_mask": 2 makes an age-restricted withdraw from that denomination abort the client.

The exchange never produces such a mask (TALER_parse_age_group_string() always sets bit 0), and the in-tree C clients that withdraw are the test commands. Confirmed by reading the code at 2a57cbcaf.

The attached patch makes both parsers refuse a non-zero mask without bit 0.
Additional InformationNot addressed here: a mask with all 32 bits set is valid for the configuration parser, but TALER_age_restriction_from_secret() asserts 31 > num_priv, which such a mask violates for max_age >= 31.
TagsNo tags attached.
Attached Files
12214-json-refuse-denomination-age-masks-without-the-zerot.patch (1,577 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] json: refuse denomination age masks without the zeroth age
 group

The age restriction code asserts that a non-empty mask has bit 0 set,
and the mask comes from the exchange's /keys.

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

Assisted by LLM
---
 src/json/json_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 69278c990..814deebd2 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -589,6 +589,14 @@ parse_denomination_group (void *cls,
 
   if (age_mask_missing)
     group->age_mask.bits = 0;
+  /* a non-empty age mask always marks the zeroth age group;
+     the age restriction code asserts this */
+  if ( (0 != group->age_mask.bits) &&
+       (0 == (group->age_mask.bits & 1)) )
+  {
+    GNUNET_break_op (0);
+    return GNUNET_SYSERR;
+  }
 
   return GNUNET_OK;
 }
@@ -858,6 +866,14 @@ parse_denom_pub (void *cls,
 
   if (age_mask_missing)
     denom_pub->age_mask.bits = 0;
+  /* a non-empty age mask always marks the zeroth age group;
+     the age restriction code asserts this */
+  if ( (0 != denom_pub->age_mask.bits) &&
+       (0 == (denom_pub->age_mask.bits & 1)) )
+  {
+    GNUNET_break_op (0);
+    return GNUNET_SYSERR;
+  }
   bsign_pub = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
   bsign_pub->rc = 1;
   bsign_pub->cipher = string_to_cipher (cipher);
-- 
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: 12214-json-refuse-denomination-age-masks-without-the-zerot.patch
2026-11-18 16:43Christian GrothoffTarget Version => 1.7
2026-11-18 16:43Christian GrothoffLocked by => Christian Grothoff
2026-11-18 16:43Christian GrothoffStatusnew => planning
2026-11-18 16:43Christian GrothoffLocked byChristian Grothoff =>
2026-11-18 16:43Christian GrothoffStatusplanning => implementing