]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-message: validate signature in gvariant messages
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 11 Apr 2019 12:01:38 +0000 (14:01 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 11 Apr 2019 12:01:38 +0000 (14:01 +0200)
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.

src/libsystemd/sd-bus/bus-message.c
test/fuzz/fuzz-bus-message/oss-fuzz-14016 [new file with mode: 0644]

index 11c4648f9111c1cd3a3a28b7a3c7228c399fda2b..a2464e1a46bcc932581de53ef986756ca1ab04aa 100644 (file)
@@ -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 (file)
index 0000000..c82d1ba
Binary files /dev/null and b/test/fuzz/fuzz-bus-message/oss-fuzz-14016 differ