From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Christian Grothoff 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