commit 2a57cbcaf22e52bbd7b8b0594d6c112fd8810ddf
parent 0b87586b9f4e1fef16c7f2723ae6f53505af67e0
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 18 Nov 2026 15:21:19 +0100
ensure transfer_pubs array has the required length, do not expose clients to out-of-bounds risks from untrusted input
Diffstat:
1 file changed, 55 insertions(+), 48 deletions(-)
diff --git a/src/lib/exchange_api_get-coins-COIN_PUB-history.c b/src/lib/exchange_api_get-coins-COIN_PUB-history.c
@@ -282,56 +282,63 @@ parse_melt (struct CoinHistoryParseContext *pc,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
-
- struct TALER_DenominationHashP *denoms_h = NULL;
- struct TALER_TransferPublicKeyP *transfer_pubs = NULL;
- size_t num_transfer_pubs = 0;
- struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_amount_any ("melt_fee",
- &rh->details.melt.melt_fee),
- GNUNET_JSON_spec_fixed_auto ("rc",
- &rh->details.melt.rc),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
- &rh->details.melt.h_age_commitment),
- &rh->details.melt.no_hac),
- GNUNET_JSON_spec_fixed_auto ("coin_sig",
- &rh->details.melt.sig),
- GNUNET_JSON_spec_fixed_auto ("refresh_seed",
- &rh->details.melt.refresh_seed),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_fixed_auto ("blinding_seed",
- &rh->details.melt.blinding_seed),
- &rh->details.melt.no_blinding_seed),
- TALER_JSON_spec_array_of_denom_pub_h ("denoms_h",
- &rh->details.melt.num_fresh_coins,
- &denoms_h),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_uint32 ("noreveal_index",
- &rh->details.melt.noreveal_index),
- &rh->details.melt.no_noreveal_index),
- GNUNET_JSON_spec_mark_optional (
- TALER_JSON_spec_array_of_data ("transfer_pubs",
- sizeof (struct TALER_TransferPublicKeyP),
- &num_transfer_pubs,
- (void **) &transfer_pubs),
- NULL),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (transaction,
- spec,
- NULL, NULL))
{
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ struct TALER_DenominationHashP *denoms_h = NULL;
+ struct TALER_TransferPublicKeyP *transfer_pubs = NULL;
+ size_t num_transfer_pubs = 0;
+ struct GNUNET_JSON_Specification spec[] = {
+ TALER_JSON_spec_amount_any ("melt_fee",
+ &rh->details.melt.melt_fee),
+ GNUNET_JSON_spec_fixed_auto ("rc",
+ &rh->details.melt.rc),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
+ &rh->details.melt.h_age_commitment),
+ &rh->details.melt.no_hac),
+ GNUNET_JSON_spec_fixed_auto ("coin_sig",
+ &rh->details.melt.sig),
+ GNUNET_JSON_spec_fixed_auto ("refresh_seed",
+ &rh->details.melt.refresh_seed),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("blinding_seed",
+ &rh->details.melt.blinding_seed),
+ &rh->details.melt.no_blinding_seed),
+ TALER_JSON_spec_array_of_denom_pub_h ("denoms_h",
+ &rh->details.melt.num_fresh_coins,
+ &denoms_h),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_uint32 ("noreveal_index",
+ &rh->details.melt.noreveal_index),
+ &rh->details.melt.no_noreveal_index),
+ GNUNET_JSON_spec_mark_optional (
+ TALER_JSON_spec_array_of_data ("transfer_pubs",
+ sizeof (struct TALER_TransferPublicKeyP),
+ &num_transfer_pubs,
+ (void **) &transfer_pubs),
+ NULL),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (transaction,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ if (num_transfer_pubs != rh->details.melt.num_fresh_coins)
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ return GNUNET_SYSERR;
+ }
+ rh->details.melt.denoms_h = denoms_h;
+ rh->details.melt.transfer_pubs = transfer_pubs;
+ denoms_h = NULL;
+ transfer_pubs = NULL;
+ GNUNET_JSON_parse_free (spec);
}
- rh->details.melt.denoms_h = denoms_h;
- rh->details.melt.transfer_pubs = transfer_pubs;
- denoms_h = NULL;
- transfer_pubs = NULL;
- GNUNET_JSON_parse_free (spec);
if ( (! rh->details.melt.no_noreveal_index) &&
(rh->details.melt.noreveal_index >= TALER_CNC_KAPPA) )
{