GnuPG — unbounded memory leak in iobuf_set_partial_body_length_mode
Testing, NormalPublic

Assigned To
Authored By
• gniibe
Thu, Nov 26, 6:41 AM

Description

When gpg parses an OpenPGP message, each partial-body-length packet pushes a
block filter onto the input iobuf. iobuf_push_filter() refuses the push once
the filter chain reaches MAX_NESTING_FILTER (64), but
iobuf_set_partial_body_length_mode() (common/iobuf.c) ignores that failure:
it has already xcalloc'd a block_filter_ctx_t, and on a refused push the
context is never attached to the chain, so IOBUFCTRL_FREE never reaches it
and it is leaked.

Reported-by: Marius van der Wijden

Event Timeline

Suggested fix from reporter:

diff --git a/common/iobuf.c b/common/iobuf.c
index 769df958d..b5d5fc031 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -2837,7 +2837,8 @@ iobuf_set_partial_body_length_mode (iobuf_t a, size_t len)
       ctx->partial = 1;
       ctx->size = 0;
       ctx->first_c = len;
-      iobuf_push_filter (a, block_filter, ctx);
+      if (iobuf_push_filter (a, block_filter, ctx))
+        xfree (ctx);
     }
 }
• werner lowered the priority of this task from Unbreak Now! to Normal.Thu, Nov 26, 10:55 AM
• werner removed a project: Security.

Memory leaks are not a s security issue - at least not for a short-living process.

• werner shifted this object from the Restricted Space space to the S1 Public space.Thu, Nov 26, 10:55 AM
• werner changed the visibility from "g10code (Project)" to "Public (No Login Required)".
• werner changed the edit policy from "Custom Policy" to "Contributor (Project)".
• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Nov 30, 5:20 AM
• gniibe changed the task status from Open to Testing.Wed, Dec 2, 6:26 AM