]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-bus: add depth limit to message_skip_fields() to prevent stack overflow
authorTristanInSec <tristan.mtn@gmail.com>
Tue, 19 May 2026 21:33:06 +0000 (17:33 -0400)
committerTristanInSec <tristan.mtn@gmail.com>
Tue, 19 May 2026 21:33:06 +0000 (17:33 -0400)
commit9b21738498affe2b7ec477be1b55e79a052d852f
treebfaf4ef9664130e9cf110cdd9018a56735f651cd
parent6080d1cc42b674515ac31f783a15477f47a28e92
sd-bus: add depth limit to message_skip_fields() to prevent stack overflow

message_skip_fields() recurses for each nested variant ('v') type in
D-Bus message header fields. A crafted message with deeply nested
variants (e.g., a variant containing a variant containing a variant...)
causes unbounded stack growth, leading to stack overflow and crash.

Add a depth parameter that increments on each recursive call and
rejects messages exceeding BUS_CONTAINER_DEPTH with -EBADMSG. This
matches the existing depth limits enforced elsewhere in the sd-bus
message processing (e.g., bus_message_enter_container).
src/libsystemd/sd-bus/bus-message.c