Skip to content

Commit 3ded00c

Browse files
committed
conf: Make sure to sanitize input for SavePairRecord command
A path traversal vulnerability was discovered in usbmuxd that allows arbitrary, unprivileged local users to delete and create files named `*.plist` as the `usbmux` user. See https://bugzilla.opensuse.org/show_bug.cgi?id=1254302
1 parent 2efa75a commit 3ded00c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/conf.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <libgen.h>
3535
#include <sys/stat.h>
3636
#include <errno.h>
37+
#include <ctype.h>
3738

3839
#include <libimobiledevice-glue/utils.h>
3940
#include <plist/plist.h>
@@ -425,13 +426,19 @@ int config_set_device_record(const char *udid, char* record_data, uint64_t recor
425426
if (!udid || !record_data || record_size < 8)
426427
return -EINVAL;
427428

428-
plist_t plist = NULL;
429-
if (memcmp(record_data, "bplist00", 8) == 0) {
430-
plist_from_bin(record_data, record_size, &plist);
431-
} else {
432-
plist_from_xml(record_data, record_size, &plist);
429+
/* verify udid input */
430+
const char* u = udid;
431+
while (*u != '\0') {
432+
if (!isalnum(*u) && (*u != '-')) {
433+
usbmuxd_log(LL_ERROR, "ERROR: %s: udid contains invalid character.\n", __func__);
434+
return -EINVAL;
435+
}
436+
u++;
433437
}
434438

439+
plist_t plist = NULL;
440+
plist_from_memory(record_data, record_size, &plist, NULL);
441+
435442
if (!plist || plist_get_node_type(plist) != PLIST_DICT) {
436443
if (plist)
437444
plist_free(plist);

0 commit comments

Comments
 (0)