]> git.ipfire.org Git - thirdparty/chrony.git/commit
client: mitigate unsafe permissions change on chronyc socket
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 16 Jul 2025 13:55:05 +0000 (15:55 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 30 Jul 2025 12:46:59 +0000 (14:46 +0200)
commit90d808ed28977ff79aaf3913ba477466c19d4695
tree075f3e4640ccded0e0a9132fb7a6e8f76609b39c
parent1d9e080749d1c705263fb88438b889213689dccc
client: mitigate unsafe permissions change on chronyc socket

When chronyc running under root binds its Unix domain socket, it needs
to change the socket permissions in order for chronyd running without
root privileges to be able to send a response to the socket.

There is a race condition between the bind() and chmod() calls. If an
attacker was able to execute arbitrary code in the chronyd process, it
might be able to wait for chronyc to be executed under root, replace the
socket with a symlink between the two calls, and cause the privileged
chronyc process to change permissions of something else, possibly
leading to a privilege escalation.

There doesn't seem to be a safe and portable way to change the socket
permissions directly. Changing the process umask could be problematic in
future with threads.

Hide the socket in two levels of subdirectories (the lower one having
a randomly generated name and not visible to the chronyd process) to
make the socket path unpredictable, and force the bind() or chmod() call
to fail if the visible upper directory is replaced.

Reported-by: Matthias Gerstner <mgerstner@suse.de>
client.c