Hide Forgot
A flaw was found in systemd-journald. An uncontrolled alloca() by writing a crafted message to /run/systemd/journal/socket that results in a stack buffer overflow. This can lead to a denial of service attack or arbitrary code execution in some cases.
The exploit described by reporter is a stack clash: since crafted input can cause a maximum alloca() of 4GiB (which may not be entirely written to) it is possible to jump over the guard page if the randomized offset between the stack and the next writeable segment on the heap is smaller than this. This is claimed to occur approx 1/2048 of the time. Testing on rhel-7 bears this out approximately. The rest of the time, this attack will be harmless (and noisy, as journald will log the message). An attacker is not able to significantly increase their chances even if they were able to force journald to restart repeatedly: default StartLimit* settings will throttle restarts to 5/sec.
This vulnerability was introduced in systemd v38 and became exploitable in systemd v201.
Acknowledgments: Name: Qualys Research Labs
Function journal_file_append_entry() in journal-file.c allocates an array of EntryItem structures through alloca(), however the number of entries can be controlled by a local attacker. By directly accessing the UNIX domain socket (by default at /run/systemd/journal/socket) a local attacker could send many items to the socket, making the alloca() function allocate the array on top of another memory region, overwriting data that resides there. This may crash systemd-journald or even allow to escalate the privileges of the attacker.
If systemd is compiled with -fstack-clash-protection flag, like in Fedora 28/29, the flaw is not exploitable because stack clashing is prevented.
Small fix to comment 0 (stack buffer overflow vs stack overflow) > A flaw was found in systemd-journald. An uncontrolled alloca() by writing a crafted message to /run/systemd/journal/socket that results in a stack buffer overflow. A flaw was found in systemd-journald. An uncontrolled alloca() by writing a crafted message to /run/systemd/journal/socket that results in a stack overflow.
Changing CVSSv3 to Attack Vector:Network (AV:N) because the attack can be performed through systemd-journal-remote service as well. The service allows to receive journal messages over the network and it can receive messages big enough to receive many items and trigger the flaw in journal_file_append_entry().
Statement: This issue affects the versions of systemd as shipped with Red Hat Enterprise Linux 7. Red Hat Product Security has rated this issue as having a security impact of Important because it allows an attacker to crash systemd-journald or escalate his privileges. For additional information, refer to the Issue Severity Classification: https://access.redhat.com/security/updates/classification/. Red Hat Enterprise Linux 7 ships systemd-journal-remote through the optional systemd-journal-gateway package, which is not installed, nor enabled by default.
Created systemd tracking bugs for this issue: Affects: fedora-all [bug 1664973]
External References: https://www.qualys.com/2019/01/09/system-down/system-down.txt
Upstream patches: https://github.com/systemd/systemd/commit/052c57f132f04a3cf4148f87561618da1a6908b4 https://github.com/systemd/systemd/commit/ef4d6abe7c7fab6cbff975b32e76b09feee56074
This issue has been addressed in the following products: Red Hat Enterprise Linux 7 Via RHSA-2019:0049 https://access.redhat.com/errata/RHSA-2019:0049
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.5 Extended Update Support Via RHSA-2019:0204 https://access.redhat.com/errata/RHSA-2019:0204
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.4 Extended Update Support Via RHSA-2019:0271 https://access.redhat.com/errata/RHSA-2019:0271
This issue has been addressed in the following products: Red Hat Virtualization 4 for Red Hat Enterprise Linux 7 Via RHSA-2019:0342 https://access.redhat.com/errata/RHSA-2019:0342
This issue has been addressed in the following products: Red Hat Virtualization 4 for Red Hat Enterprise Linux 7 Via RHSA-2019:0361 https://access.redhat.com/errata/RHSA-2019:0361
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.3 Advanced Update Support Red Hat Enterprise Linux 7.3 Update Services for SAP Solutions Red Hat Enterprise Linux 7.3 Telco Extended Update Support Via RHSA-2019:2402 https://access.redhat.com/errata/RHSA-2019:2402