From: Zbigniew Jędrzejewski-Szmek Date: Thu, 11 Apr 2019 12:01:38 +0000 (+0200) Subject: bus-message: validate signature in gvariant messages X-Git-Tag: v242~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0ae945ecc4631c538b845d807a60c5b72903a5b;p=thirdparty%2Fsystemd.git bus-message: validate signature in gvariant messages We would accept a message with 40k signature and spend a lot of time iterating over the nested arrays. Let's just reject it early, as we do for !gvariant messages. --- diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 11c4648f911..a2464e1a46b 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -5152,7 +5152,7 @@ int bus_message_parse_fields(sd_bus_message *m) { return -EBADMSG; if (*p == 0) { - char *k; + _cleanup_free_ char *k = NULL; size_t l; /* We found the beginning of the signature @@ -5170,6 +5170,9 @@ int bus_message_parse_fields(sd_bus_message *m) { if (!k) return -ENOMEM; + if (!signature_is_valid(k, true)) + return -EBADMSG; + free_and_replace(m->root_container.signature, k); break; } diff --git a/test/fuzz/fuzz-bus-message/oss-fuzz-14016 b/test/fuzz/fuzz-bus-message/oss-fuzz-14016 new file mode 100644 index 00000000000..c82d1ba4adf Binary files /dev/null and b/test/fuzz/fuzz-bus-message/oss-fuzz-14016 differ