View Issue Details

IDProjectCategoryView StatusLast Update
0012218Talerexchangepublic2026-11-18 16:45
Reporterbot-cg [agent]  
Implementeroec ReviewerChristian Grothoff  
Release signed byChristian Grothoff Deployed byChristian Grothoff  
Verifieroec CommunicatorCM_7  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Versiongit (master) 
Target Version1.6Fixed in Version1.6 
Summary0012218: POST /aml/$OFFICER_PUB/decision sizes a stack array by the number of events in the request
DescriptionThe decision handler (taler-exchange-httpd_post-aml-OFFICER_PUB-decision.c) declares const char *sevents[num_events] on the stack, with num_events = json_array_size() of the request's "events", which nothing bounds. A request body may be up to TALER_MHD_REQUEST_BUFFER_MAX (16 MiB); at about four bytes per event that is some four million entries, 32 MiB of stack.

The request has to come from an AML officer with write access. Confirmed by reading the code at 2a57cbcaf.

The attached patch allocates the array on the heap and frees it at the handler's common exit.
TagsNo tags attached.
Attached Files
12218-exchange-keep-AML-decision-events-off-the-stack.patch (1,822 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] exchange: keep AML decision events off the stack

The number of events comes from the request, which may be up to 16 MiB.

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

Assisted by LLM
---
 .../taler-exchange-httpd_post-aml-OFFICER_PUB-decision.c    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/exchange/taler-exchange-httpd_post-aml-OFFICER_PUB-decision.c b/src/exchange/taler-exchange-httpd_post-aml-OFFICER_PUB-decision.c
index ed461c3bd..e07fabae0 100644
--- a/src/exchange/taler-exchange-httpd_post-aml-OFFICER_PUB-decision.c
+++ b/src/exchange/taler-exchange-httpd_post-aml-OFFICER_PUB-decision.c
@@ -237,6 +237,8 @@ TEH_handler_post_aml_decision (
   bool is_wallet;
   size_t eas = 0;
   void *ea = NULL;
+  /* on the heap: the request decides how many events there are */
+  const char **sevents = NULL;
 
   if (NULL == adc)
   {
@@ -364,7 +366,6 @@ TEH_handler_post_aml_decision (
 
   {
     size_t num_events = json_array_size (events);
-    const char *sevents[GNUNET_NZL (num_events)];
     enum GNUNET_DB_QueryStatus qs;
     struct GNUNET_TIME_Timestamp last_date;
     bool invalid_officer = true;
@@ -384,6 +385,8 @@ TEH_handler_post_aml_decision (
                                            &eas);
     }
 
+    sevents = GNUNET_new_array (GNUNET_NZL (num_events),
+                                const char *);
     for (size_t i = 0; i<num_events; i++)
     {
       sevents[i] = json_string_value (json_array_get (events,
@@ -537,6 +540,7 @@ TEH_handler_post_aml_decision (
 done:
   TALER_KYCLOGIC_rules_free (lrs);
   GNUNET_free (ea);
+  GNUNET_free (sevents);
   return ret;
 }
 
-- 
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

Christian Grothoff

2026-11-18 16:45

manager   ~0030606

dfebff5c2..027bbade0

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: 12218-exchange-keep-AML-decision-events-off-the-stack.patch
2026-11-18 16:45Christian GrothoffStatusnew => closed
2026-11-18 16:45Christian GrothoffResolutionopen => fixed
2026-11-18 16:45Christian GrothoffNote Added: 0030606
2026-11-18 16:45Christian GrothoffFixed in Version => 1.6
2026-11-18 16:45Christian GrothoffTarget Version => 1.6