Summary
LibreNMS versions prior to 24.10.0 contain an OS command injection vulnerability that allows remote attackers to execute arbitrary system commands on the monitoring server.
The issue is triggered through parameters reaching AboutController.php::index(), SettingsController.php::update(), and PollDevice.php::initRrdDirectory() where user-controlled data is incorporated into shell commands without proper sanitization.
Affected context
This vulnerability affects LibreNMS deployments where user-supplied or remotely influenced input is passed into system-level operations by:
- Web controllers such as AboutController::index() and SettingsController::update()
- Backend polling logic in PollDevice::initRrdDirectory()
It typically manifests when configuration values, device attributes, or request parameters are used to build shell commands or paths without robust escaping, validation, or avoiding the shell altogether. The risk is highest on instances exposed to untrusted users or integrated with external systems that can influence these inputs.
Exploit preconditions
- Attack surface: HTTP(S) interface and/or device/poller workflows that eventually invoke the affected PHP methods.
- Required access: Ability to supply or modify inputs processed by:
- AboutController::index()
- SettingsController::update()
- PollDevice::initRrdDirectory()
This may be via authenticated web sessions, misconfigured API access, or indirectly through configuration or device data.
- Trigger point: Execution paths where the application constructs shell commands or invokes OS utilities with attacker-controlled values.
- Why exploitation is possible: Inputs are concatenated or interpolated into shell commands or passed to command-executing APIs (e.g., exec-like functions) without strict validation, canonicalization, and argument separation, allowing injection of additional command syntax.
Why this happens
The root cause aligns with CWE-78: OS Command Injection. Application code in the referenced controllers and poller method appears to:
- Accept external input (from HTTP requests, configuration, or device data),
- Incorporate that data directly into shell command strings or system calls,
- Execute those commands via PHP functions that interpret the entire string as a shell command.
Because the shell interprets metacharacters (such as separators, redirections, or subshell constructs), the attacker can escape intended arguments and introduce arbitrary commands. The fundamental bug is relying on string-based shell invocation with insufficient normalization and without enforcing strict, allowlisted arguments, instead of using safer, non-shell system interfaces.
Potential impact
- Remote execution of arbitrary OS commands under the web server or poller process account
- Installation of backdoors, web shells, or persistent malware on the LibreNMS host
- Exfiltration or tampering with monitoring data, credentials, and configuration files
- Pivoting to other systems within the monitored network environment
- Disruption of monitoring operations, including disabling alerts or falsifying metrics
General mitigation guidance
Effective mitigation typically focuses on removing the need to invoke the shell with untrusted input and reducing the privileges of any remaining command execution:
- Replace shell-based calls with high-level library functions or APIs that do not spawn a shell (e.g., direct PHP or system libraries for file, process, or RRD operations).
- When external commands are unavoidable, use argument-array execution functions that bypass the shell and treat each parameter as a distinct argument.
- Apply strict input validation and allowlists on all parameters that may influence command execution—only allow known-safe values and formats.
- Normalize and canonicalize path and configuration inputs; reject or sanitize characters with special meaning in shells.
- Run LibreNMS services under least-privilege accounts and apply OS-level controls (e.g., restricted sudo, AppArmor/SELinux profiles, containerization) to limit blast radius.
- Separate configuration duties from routine viewing/monitoring roles, ensuring only trusted administrators can modify sensitive settings.
How teams detect issues like this
Organizations can look for this vulnerability pattern using several complementary approaches:
- Static analysis: Configure SAST tools or custom rules to flag uses of exec-like functions (e.g., exec, system, shell_exec, passthru, backticks) where arguments incorporate request data, configuration fields, or device attributes.
- Code review: During manual review, trace data flows in controller and poller code from HTTP or external inputs to any command execution APIs, paying attention to string concatenation and interpolation.
- Runtime monitoring: Deploy application and host-level monitoring to capture suspicious command executions initiated by the web or poller processes (unexpected interpreters, network tools, or file modification commands).
- Policy enforcement: Enforce secure coding standards that require non-shell alternatives, strict allowlists, and mandatory review whenever shell commands are introduced or modified.

