Skip to content

Commit dea17b4

Browse files
committed
in_forward: validate array size before accessing message mode fields
The forward protocol parser accesses root.via.array.ptr[2] when the second element is a positive integer or EXT type (message mode), but only checks that the array has at least 2 elements. A 2-element array [tag, integer] passes the size check but causes an out-of-bounds heap read when accessing index 2. Add a size >= 3 check before the message mode branch.
1 parent f6126eb commit dea17b4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎plugins/in_forward/fw_prot.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,14 @@ int fw_prot_process(struct flb_input_instance *ins, struct fw_conn *conn)
14881488
/*
14891489
* Forward format 2 (message mode) : [tag, time, map, ...]
14901490
*/
1491+
if (root.via.array.size < 3) {
1492+
flb_plg_warn(ctx->ins,
1493+
"message mode requires at least 3 elements");
1494+
msgpack_unpacked_destroy(&result);
1495+
msgpack_unpacker_free(unp);
1496+
flb_sds_destroy(out_tag);
1497+
return -1;
1498+
}
14911499
map = root.via.array.ptr[2];
14921500
if (map.type != MSGPACK_OBJECT_MAP) {
14931501
flb_plg_warn(ctx->ins, "invalid data format, map expected");

0 commit comments

Comments
 (0)