|
Pablo Greco |
48fc63 |
From efecb8966520f1782501f8f5f05c89fde0c19deb Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
48fc63 |
From: Riccardo Schirone <rschiron@redhat.com>
|
|
Pablo Greco |
48fc63 |
Date: Mon, 4 Feb 2019 14:29:09 +0100
|
|
Pablo Greco |
48fc63 |
Subject: [PATCH] Refuse dbus message paths longer than BUS_PATH_SIZE_MAX
|
|
Pablo Greco |
48fc63 |
limit.
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
Even though the dbus specification does not enforce any length limit on the
|
|
Pablo Greco |
48fc63 |
path of a dbus message, having to analyze too long strings in PID1 may be
|
|
Pablo Greco |
48fc63 |
time-consuming and it may have security impacts.
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
In any case, the limit is set so high that real-life applications should not
|
|
Pablo Greco |
48fc63 |
have a problem with it.
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
Related: #1667871
|
|
Pablo Greco |
48fc63 |
---
|
|
Pablo Greco |
48fc63 |
src/libsystemd/sd-bus/bus-internal.c | 2 +-
|
|
Pablo Greco |
48fc63 |
src/libsystemd/sd-bus/bus-internal.h | 4 ++++
|
|
Pablo Greco |
48fc63 |
2 files changed, 5 insertions(+), 1 deletion(-)
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
diff --git a/src/libsystemd/sd-bus/bus-internal.c b/src/libsystemd/sd-bus/bus-internal.c
|
|
Pablo Greco |
48fc63 |
index 91b288cd25..c952d63e10 100644
|
|
Pablo Greco |
48fc63 |
--- a/src/libsystemd/sd-bus/bus-internal.c
|
|
Pablo Greco |
48fc63 |
+++ b/src/libsystemd/sd-bus/bus-internal.c
|
|
Pablo Greco |
48fc63 |
@@ -58,7 +58,7 @@ bool object_path_is_valid(const char *p) {
|
|
Pablo Greco |
48fc63 |
if (slash)
|
|
Pablo Greco |
48fc63 |
return false;
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
- return true;
|
|
Pablo Greco |
48fc63 |
+ return (q - p) <= BUS_PATH_SIZE_MAX;
|
|
Pablo Greco |
48fc63 |
}
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
char* object_path_startswith(const char *a, const char *b) {
|
|
Pablo Greco |
48fc63 |
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
|
|
Pablo Greco |
48fc63 |
index 9c1e5a35b8..1c5fbeac2a 100644
|
|
Pablo Greco |
48fc63 |
--- a/src/libsystemd/sd-bus/bus-internal.h
|
|
Pablo Greco |
48fc63 |
+++ b/src/libsystemd/sd-bus/bus-internal.h
|
|
Pablo Greco |
48fc63 |
@@ -331,6 +331,10 @@ struct sd_bus {
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
#define BUS_MESSAGE_SIZE_MAX (128*1024*1024)
|
|
Pablo Greco |
48fc63 |
#define BUS_AUTH_SIZE_MAX (64*1024)
|
|
Pablo Greco |
48fc63 |
+/* Note that the D-Bus specification states that bus paths shall have no size limit. We enforce here one
|
|
Pablo Greco |
48fc63 |
+ * anyway, since truly unbounded strings are a security problem. The limit we pick is relatively large however,
|
|
Pablo Greco |
48fc63 |
+ * to not clash unnecessarily with real-life applications. */
|
|
Pablo Greco |
48fc63 |
+#define BUS_PATH_SIZE_MAX (64*1024)
|
|
Pablo Greco |
48fc63 |
|
|
Pablo Greco |
48fc63 |
#define BUS_CONTAINER_DEPTH 128
|
|
Pablo Greco |
48fc63 |
|