Package: nagios4-common Version: 4.4.6-4.1+deb13u2 Severity: important Tags: security X-Debbugs-CC: [email protected]
nagios4-common.postinst follows symlinks that the nagios service account places in /var/log/nagios4 and /var/lib/nagios4. When an administrator upgrades or reinstalls nagios4-common, root changes the owner and mode of the symlink's target. I reported this privately to the Debian security team and the maintainer, with a reproducer. I am filing it publicly at the security team's request. The setperm function tests each path with -e, then runs chown and chmod without refusing symlinks. These operations run if the path exists and has no dpkg-statoverride entry. A default installation has no such override. The nagios account owns the parent directories. No timing race is required. Tested on Debian 13 with nagios4 4.4.6-4.1+deb13u2 using a root-owned test directory. In 10 of 10 attempts, reinstallation of nagios4-common changed the test directory from root:root 0755 to nagios:adm 2751 (exit status 0), giving the nagios account write access. Source inspection identified the same unsafe operations on /var/lib/nagios4/spool/checkresults and /var/lib/nagios4/rw. The same setperm code is present in bookworm (4.4.6-4+deb12u1 and 4.4.6-4+deb12u2) and sid (4.5.14+ds-1). Reported by Hasnain Naeem and Ryan Henry (University of Calgary).

