Hello,
As requested by the Debian Security Team, I am filing this publicly. The
logrotate fragment shipped by openvas-scanner
(debian/openvas-scanner.logrotate, installed as
/etc/logrotate.d/openvas-scanner) lets the _gvm service account change
ownership of arbitrary files to itself, which leads to local privilege
escalation from _gvm to root.
The fragment is identical in 23.45.1-2 (unstable) and 23.51.0+ds-1
(experimental):
/var/log/gvm/openvas.log {
missingok
notifempty
create 640 _gvm _gvm
daily
rotate 7
compress
postrotate
openvaslogs=`ls /var/log/gvm/openvas.log.*`
if [ -n "$openvaslogs" ]; then
chown _gvm:_gvm $openvaslogs
chmod 640 $openvaslogs
fi
endscript
}
There is no su directive, so postrotate runs as root. Two defects:
1. chown is called without -h/--no-dereference, so a symbolic link among
the glob matches changes ownership of the link TARGET (CWE-59).
2. $openvaslogs is unquoted in both chown and chmod, so a filename
containing whitespace splits into several arguments and a filename
beginning with "-" can be consumed as an option.
Reachability: gvmd.postinst registers "dpkg-statoverride --update --add
_gvm _gvm 0755 /var/log/gvm", so _gvm owns the directory and can create
symlinks matching openvas.log.*. _gvm is the account under which
ospd-openvas, gvmd and gsad run, and openvas parses untrusted scan results
and NASL plugin data, so a compromise of the scanner yields _gvm; this
issue then converts _gvm into root. Administrators who place users in the
_gvm group expose it directly. No race is involved: _gvm controls both the
directory and the log file, and the daily logrotate.timer fires
deterministically.
Reproduced in an isolated container with a synthetic _gvm (uid 113), the
fragment exactly as shipped, and a harmless canary file:
canary before : 0600 root:root /root/canary
log dir : 0755 _gvm:_gvm /var/log/gvm
planted : openvas.log.evil -> /root/canary (as _gvm)
trigger : root runs logrotate; "running postrotate script"
canary after : 0640 _gvm:_gvm /root/canary
A root-owned mode-0600 file outside /var/log/gvm became _gvm-owned with
mode 0640. I deliberately did not build the onward step from arbitrary
chown to a root shell.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H (7.8)
Suggested fix, avoiding the shell entirely:
find /var/log/gvm -maxdepth 1 -type f -name 'openvas.log.*' -exec chown
_gvm:_gvm {} +