Summary
Nagios Core and Nagios XI contain an OS command injection vulnerability in custom-variable macro expansion performed by the Nagios Remote Data Processor (NRDP). An authenticated attacker with NRDP access may inject operating-system commands when a custom variable is referenced by a shell-executed command in a non-default configuration.
Affected context
The vulnerability can occur in Nagios deployments where all of the following conditions are present:
- NRDP is enabled and accessible to an authenticated user.
- A custom variable is defined for a host, service, or contact.
- That variable is referenced in a command executed through a shell.
- The variable value is incorporated into the command without adequate neutralization or strict validation.
Exploit preconditions
- Attack surface: The Nagios Remote Data Processor (NRDP) interface.
- Required access: Valid authenticated access capable of submitting or influencing NRDP data.
- Configuration requirement: A custom variable must be defined and referenced by a shell-executed command.
- Trigger point: Processing and execution of the command line after custom-variable macro expansion.
- Why exploitation is possible: Attacker-influenced macro content can become part of a shell command rather than remaining inert data.
Why this happens
The underlying flaw is insufficient separation between custom-variable data and shell command syntax. When a macro is expanded into a command line that is later interpreted by a shell, untrusted or insufficiently constrained variable content may alter the command's meaning or introduce additional operating-system commands. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly called OS command injection.
Potential impact
- An attacker may execute arbitrary commands with the privileges of the Nagios process.
- The attacker could access monitoring data, credentials, or local configuration.
- The Nagios host may be used for lateral movement or additional compromise.
- Monitoring integrity could be degraded through service disruption or data manipulation.
- Host or service checks could be altered to conceal malicious activity.
General mitigation guidance
Mitigation generally focuses on preventing untrusted macro values from reaching shell interpreters.
Common defensive patterns include:
- Prefer direct process execution with argument arrays over shell-based command execution.
- Apply strict allowlist validation and context-appropriate escaping to custom-variable values.
- Avoid placing attacker-influenced variables in command or interpreter arguments.
- Minimize NRDP permissions and restrict access to trusted administrative networks or identities.
- Run monitoring components with least privilege and isolate their access to sensitive files and systems.
- Use secure-by-default command definitions that do not require shell interpretation.
- Treat submitted monitoring data as untrusted even when it comes from an authenticated user.
How teams detect issues like this
Detection programs can review command definitions and macro expansion paths for custom variables that flow into shell execution.
Useful approaches include:
- Static analysis for shell invocation APIs, command-string concatenation, and macro substitution.
- Code review checks for custom variables embedded directly in executable command lines.
- Configuration audits identifying commands that invoke shell interpreters or evaluate dynamic text.
- Policy enforcement requiring allowlisted values and non-shell process execution for monitoring actions.
- Runtime monitoring for unusual child processes, command interpreters, or activity initiated by Nagios services.
Automated security review tools may help identify data flows from NRDP inputs to command execution.

