PR #26081 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26081
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26081.patch


>From 8ed7a0d19a69dbdb0c181fcb22ace35e884100c5 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:14:09 +0100
Subject: [PATCH 1/8] avfilter/af_dynaudnorm: resize the gain histories by the
 change of the filter size

Fixes: out of array access (memmove with negative size)
Fixes: out of array write
Fixes: ArUvqAYbevNM
Fixes: AISLE-2026-0166-00680

Found-by: Joshua Rogers (AISLE)
The out of array write was found during triage of the security report

Out of array access Replicated through UnModified FFmpeg with ASAN
Out of array write Replicated through UnModified FFmpeg with ASAN
no further issues found with 3000 iterations of a random gausssize command 
sequence generator
---
 libavfilter/af_dynaudnorm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 98a3bb91e5b..b732361aeb6 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -261,13 +261,14 @@ static void cqueue_resize(cqueue *q, int new_size)
     av_assert2(q->max_size >= new_size);
     av_assert2(MIN_FILTER_SIZE <= new_size);
 
-    if (new_size > q->nb_elements) {
-        const int side = (new_size - q->nb_elements) / 2;
+    if (cqueue_empty(q)) {
+    } else if (new_size > q->size) {
+        const int side = (new_size - q->size) / 2;
 
         memmove(q->elements + side, q->elements, sizeof(double) * 
q->nb_elements);
         for (int i = 0; i < side; i++)
             q->elements[i] = q->elements[side];
-        q->nb_elements = new_size - 1 - side;
+        q->nb_elements += side;
     } else {
         int count = (q->size - new_size + 1) / 2;
 
-- 
2.54.0


>From 1058819621f2cf1fccc036bc07b6684234252a1b Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:18:49 +0100
Subject: [PATCH 2/8] avfilter/f_zmq: do not store the message size in an int

Fixes: out of array access (memcpy with negative size)
Fixes: Nf17YjGEKIAG
Fixes: AISLE-2026-0166-00548

Found-by: Joshua Rogers (AISLE)

Out of array access Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/f_zmq.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
index 647ee379639..6b9e55897bc 100644
--- a/libavfilter/f_zmq.c
+++ b/libavfilter/f_zmq.c
@@ -115,7 +115,7 @@ static int parse_command(Command *cmd, const char 
*command_str, void *log_ctx)
     return 0;
 }
 
-static int recv_msg(AVFilterContext *ctx, char **buf, int *buf_size)
+static int recv_msg(AVFilterContext *ctx, char **buf)
 {
     ZMQContext *zmq = ctx->priv;
     zmq_msg_t msg;
@@ -135,14 +135,9 @@ static int recv_msg(AVFilterContext *ctx, char **buf, int 
*buf_size)
         goto end;
     }
 
-    *buf_size = zmq_msg_size(&msg) + 1;
-    *buf = av_malloc(*buf_size);
-    if (!*buf) {
+    *buf = av_strndup(zmq_msg_data(&msg), zmq_msg_size(&msg));
+    if (!*buf)
         ret = AVERROR(ENOMEM);
-        goto end;
-    }
-    memcpy(*buf, zmq_msg_data(&msg), *buf_size - 1);
-    (*buf)[*buf_size-1] = 0;
 
 end:
     zmq_msg_close(&msg);
@@ -157,12 +152,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*ref)
     while (1) {
         char cmd_buf[1024];
         char *recv_buf = NULL, *send_buf = NULL;
-        int recv_buf_size;
         Command cmd = {0};
         int ret;
 
         /* receive command */
-        if (recv_msg(ctx, &recv_buf, &recv_buf_size) < 0)
+        if (recv_msg(ctx, &recv_buf) < 0)
             break;
         zmq->command_count++;
 
@@ -196,7 +190,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
     end:
         av_freep(&send_buf);
         av_freep(&recv_buf);
-        recv_buf_size = 0;
         av_freep(&cmd.target);
         av_freep(&cmd.command);
         av_freep(&cmd.arg);
-- 
2.54.0


>From 0b64be009817afc5eab2755e16acf0b119aa0faf Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:20:17 +0100
Subject: [PATCH 3/8] avfilter/f_zmq: reply to commands that cannot be parsed

Found during triage of the security report AISLE-2026-0166-00548
---
 libavfilter/f_zmq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
index 6b9e55897bc..9a3630eced9 100644
--- a/libavfilter/f_zmq.c
+++ b/libavfilter/f_zmq.c
@@ -161,11 +161,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*ref)
         zmq->command_count++;
 
         /* parse command */
-        if (parse_command(&cmd, recv_buf, ctx) < 0) {
+        ret = parse_command(&cmd, recv_buf, ctx);
+        if (ret < 0) {
             av_log(ctx, AV_LOG_ERROR, "Could not parse command #%d\n", 
zmq->command_count);
-            goto end;
-        }
-
+            cmd_buf[0] = 0;
+        } else {
         /* process command */
         av_log(ctx, AV_LOG_VERBOSE,
                "Processing command #%d target:%s command:%s arg:%s\n",
@@ -174,6 +174,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
                                           cmd.target, cmd.command, cmd.arg,
                                           cmd_buf, sizeof(cmd_buf),
                                           AVFILTER_CMD_FLAG_ONE);
+        }
         send_buf = av_asprintf("%d %s%s%s",
                                -ret, av_err2str(ret), cmd_buf[0] ? "\n" : "", 
cmd_buf);
         if (!send_buf) {
-- 
2.54.0


>From 090567f5939af333a69828ca90ef1df887fc01fe Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:20:24 +0100
Subject: [PATCH 4/8] avfilter/f_zmq: reindent after the previous commit

---
 libavfilter/f_zmq.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
index 9a3630eced9..df195d7eb32 100644
--- a/libavfilter/f_zmq.c
+++ b/libavfilter/f_zmq.c
@@ -166,14 +166,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*ref)
             av_log(ctx, AV_LOG_ERROR, "Could not parse command #%d\n", 
zmq->command_count);
             cmd_buf[0] = 0;
         } else {
-        /* process command */
-        av_log(ctx, AV_LOG_VERBOSE,
-               "Processing command #%d target:%s command:%s arg:%s\n",
-               zmq->command_count, cmd.target, cmd.command, cmd.arg);
-        ret = avfilter_graph_send_command(ff_filter_link(inlink)->graph,
-                                          cmd.target, cmd.command, cmd.arg,
-                                          cmd_buf, sizeof(cmd_buf),
-                                          AVFILTER_CMD_FLAG_ONE);
+            /* process command */
+            av_log(ctx, AV_LOG_VERBOSE,
+                   "Processing command #%d target:%s command:%s arg:%s\n",
+                   zmq->command_count, cmd.target, cmd.command, cmd.arg);
+            ret = avfilter_graph_send_command(ff_filter_link(inlink)->graph,
+                                              cmd.target, cmd.command, cmd.arg,
+                                              cmd_buf, sizeof(cmd_buf),
+                                              AVFILTER_CMD_FLAG_ONE);
         }
         send_buf = av_asprintf("%d %s%s%s",
                                -ret, av_err2str(ret), cmd_buf[0] ? "\n" : "", 
cmd_buf);
-- 
2.54.0


>From ce7db9f737fd60182095d2a2f103613553c58ce5 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:22:02 +0100
Subject: [PATCH 5/8] avfilter/vf_scale: reject commands using ref variables
 without a ref input

Fixes: out of array read
Fixes: qNXODI0YyLo1
Fixes: AISLE-2026-0166-00236

Found-by: Joshua Rogers (AISLE)
The rejected expression case was found during triage of the security report

Out of array read Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_scale.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 6c1bf888796..6f0840801a5 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -257,7 +257,7 @@ static int check_exprs(AVFilterContext *ctx)
 static int scale_parse_expr(AVFilterContext *ctx, char *str_expr, AVExpr 
**pexpr_ptr, const char *var, const char *args)
 {
     ScaleContext *scale = ctx->priv;
-    int ret, is_inited = 0;
+    int ret, is_inited = 0, old_uses_ref = scale->uses_ref;
     char *old_str_expr = NULL;
     AVExpr *old_pexpr = NULL;
 
@@ -285,6 +285,12 @@ static int scale_parse_expr(AVFilterContext *ctx, char 
*str_expr, AVExpr **pexpr
     if (ret < 0)
         goto revert;
 
+    if (is_inited && scale->uses_ref && ctx->nb_inputs == 1) {
+        av_log(ctx, AV_LOG_ERROR, "Expressions with ref variables need the ref 
input, a command cannot add it.\n");
+        ret = AVERROR(EINVAL);
+        goto revert;
+    }
+
     if (is_inited && (ret = config_props(ctx->outputs[0])) < 0)
         goto revert;
 
@@ -295,6 +301,7 @@ static int scale_parse_expr(AVFilterContext *ctx, char 
*str_expr, AVExpr **pexpr
     return 0;
 
 revert:
+    scale->uses_ref = old_uses_ref;
     av_expr_free(*pexpr_ptr);
     *pexpr_ptr = NULL;
     if (old_str_expr) {
-- 
2.54.0


>From 5f70667316e26dbae2ffecdfe9d70bd0dcc693a6 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:23:08 +0100
Subject: [PATCH 6/8] avfilter/vf_deband: reject the coupling command for
 subsampled formats

Fixes: out of array access
Fixes: QJKTLuAvDBVR
Fixes: AISLE-2026-0166-00123

Found-by: Joshua Rogers (AISLE)

Out of array read and write Replicated through UnModified FFmpeg with ASAN
---
 libavfilter/vf_deband.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavfilter/vf_deband.c b/libavfilter/vf_deband.c
index 2ff4fca6fa4..6dd08dd10f8 100644
--- a/libavfilter/vf_deband.c
+++ b/libavfilter/vf_deband.c
@@ -438,11 +438,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 static int process_command(AVFilterContext *ctx, const char *cmd, const char 
*args,
                            char *res, int res_len, int flags)
 {
+    DebandContext *s = ctx->priv;
     int ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
 
     if (ret < 0)
         return ret;
 
+    if (s->coupling && (s->shift[0] || s->shift[1])) {
+        av_log(ctx, AV_LOG_ERROR, "coupling needs a pixel format without 
chroma subsampling\n");
+        s->coupling = 0;
+        return AVERROR(EINVAL);
+    }
+
     return config_input(ctx->inputs[0]);
 }
 
-- 
2.54.0


>From c3a7c76f77b762c79e83e070bb99e0e1bb0ec7ec Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sat, 14 Nov 2026 05:24:19 +0100
Subject: [PATCH 7/8] avfilter/f_zmq: bind to the loopback interface by default

Fixes: command socket listening on all interfaces by default
Fixes: Pmsg6bRXwMLx
Fixes: AISLE-2026-0166-00034
Fixes: acf_90a050c2e0508c199c8d42dec17b7778

Found-by: Joshua Rogers (AISLE)

Listening on all interfaces Replicated through UnModified FFmpeg with ss
---
 doc/filters.texi    | 2 +-
 libavfilter/f_zmq.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index fb866d24d16..6e8fe148856 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -35146,7 +35146,7 @@ For more information about libzmq see:
 The @code{zmq} and @code{azmq} filters work as a libzmq server, which
 receives messages sent through a network interface defined by the
 @option{bind_address} (or the abbreviation "@option{b}") option.
-Default value of this option is @file{tcp://localhost:5555}. You may
+Default value of this option is @file{tcp://127.0.0.1:5555}. You may
 want to alter this value to your needs, but do not forget to escape any
 ':' signs (see @ref{filtergraph escaping}).
 
diff --git a/libavfilter/f_zmq.c b/libavfilter/f_zmq.c
index df195d7eb32..52d778750ef 100644
--- a/libavfilter/f_zmq.c
+++ b/libavfilter/f_zmq.c
@@ -45,8 +45,8 @@ typedef struct ZMQContext {
 #define OFFSET(x) offsetof(ZMQContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | 
AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption options[] = {
-    { "bind_address", "set bind address", OFFSET(bind_address), 
AV_OPT_TYPE_STRING, {.str = "tcp://*:5555"}, 0, 0, FLAGS },
-    { "b",            "set bind address", OFFSET(bind_address), 
AV_OPT_TYPE_STRING, {.str = "tcp://*:5555"}, 0, 0, FLAGS },
+    { "bind_address", "set bind address", OFFSET(bind_address), 
AV_OPT_TYPE_STRING, {.str = "tcp://127.0.0.1:5555"}, 0, 0, FLAGS },
+    { "b",            "set bind address", OFFSET(bind_address), 
AV_OPT_TYPE_STRING, {.str = "tcp://127.0.0.1:5555"}, 0, 0, FLAGS },
     { NULL }
 };
 
-- 
2.54.0


>From 267894f2e6fcc65fdb6111397aa85dd8fa54edeb Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Sun, 15 Nov 2026 19:39:13 +0100
Subject: [PATCH 8/8] doc/filters: state that zmq commands are not
 authenticated

Fixes: acf_90a050c2e0508c199c8d42dec17b7778
---
 doc/filters.texi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 6e8fe148856..ae75410eca4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -35150,6 +35150,9 @@ Default value of this option is 
@file{tcp://127.0.0.1:5555}. You may
 want to alter this value to your needs, but do not forget to escape any
 ':' signs (see @ref{filtergraph escaping}).
 
+Commands are not authenticated, protect a non-loopback
+@option{bind_address} with a firewall.
+
 The received message must be in the form:
 @example
 @var{TARGET} @var{COMMAND} [@var{ARG}]
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to