CVE-2024-51092: OS Command Injection

Published Nov 15, 2024
·
Updated

Summary An authenticated attacker can create dangerous directory names on the system and alter sensitive configuration parameters through the web portal. Those two defects combined then allows to inject arbitrary OS commands inside shellexec() calls, thus achieving arbitrary code execution.

Details OS Command Injection We start by inspecting the file app/Http/Controllers/AboutController.php, more particularly the index() method which is executed upon simply visiting the /about page: php public function index(Request $request) { $version = Version::get();

return view('about.index', [ <TRUNCATED>

'versionwebserver' => $request->server('SERVERSOFTWARE'), 'versionrrdtool' => Rrd::version(), 'versionnetsnmp' => strreplace('version: ', '', rtrim(shellexec(Config::get('snmpget', 'snmpget') . ' -V 2>&1'))),

<TRUNCATED> ]); }

We can see that the versionnetsnmp key receives a value direclty dependent of a shellexec() call. The argument to this call reflects a configuration parameter with no sanitization. Should an attacker identify a way to alter this parameter, the server is at risk of being compromised.

Configuration parameters poisoning We now focus on the update() method of the SettingsController.php script. This method is called when the user visits the route /settings/{key} via HTTP PUT. The key parameter here is simply the name of the configuration key the user wishes to modify. php public function update(DynamicConfig $config, Request $request, $id) { $value = $request->get('value');

if (! $config->isValidSetting($id)) { return $this->jsonResponse($id, ':id is not a valid setting', null, 400); }

$current = \LibreNMS\Config::get($id); $configitem = $config->get($id);

if (! $configitem->checkValue($value)) { return $this->jsonResponse($id, $configitem->getValidationMessage($value), $current, 400); }

if (\LibreNMS\Config::persist($id, $value)) { return $this->jsonResponse($id, "Successfully set $id", $value); }

return $this->jsonResponse($id, 'Failed to update :id', $current, 400); }

We can see that some protections are implemented around the configuration parameters by $configitem->checkValue($value), with a format of data being expected depending on the data type of the variable the user wants to modify. Specifically, the snmpget configuration variable expects a valid path to an existing binary on the system. To summarize : if an attacker finds a valid full-path to a system binary, while that full-path also holds shell metacharacters, then those characters would be interpreted by the shellexec() call defined above and allow for arbitrary command execution.

Arbitrary directory creation When creating a new Device through the "Add Device" page, the server allows the user to send malformed or impossible hostnames and force the data to be stored, with no sanitization being performed on this field.

In the file app/Jobs/PollDevice.php, the initRrdDirectory() method is responsible for creating a directory named after the Device's hostname. We can see the mkdir() call inside the try block: php private function initRrdDirectory(): void { $hostrrd = \Rrd::name($this->device->hostname, '', ''); if (Config::get('rrd.enable', true) && ! isdir($hostrrd)) { try { mkdir($hostrrd); Log::info("Created directory : $hostrrd"); } catch (\ErrorException $e) { Eventlog::log("Failed to create rrd directory: $hostrrd", $this->device); Log::info($e); } } }

This method is called by initDevice(), which is itself called by the handle() method (executed when the job starts). \Rrd::name() simply concatenates a string following the format <LIBRENMSINSTALLDIR>/rrd/<DEVICEHOSTNAME>.

Summary With all this, an authenticated attacker can: - Create a malicious Device with shell metacharacters inside its hostname - Force the creation of directory containing shell metacharacters through the PollDevice job - Modify the snmpget configuration variable to point to a valid system binary, while also using the directory created in the previous step via a path traversal (i.e: /path/to/install/dir/rrd/<DEVICEHOSTNAME>/../../../../../../../bin/ls) - Trigger a code execution via the shellexec() call contained in the AboutController.php script

PoC For proof of concept, we will create a file located at /tmp/rce-proof on the server's filesystem.

Consider the following command : /usr/bin/touch /tmp/rce-proof, encoded in base64 (L3Vzci9iaW4vdG91Y2ggL3RtcC9yY2UtcHJvb2Y=). This encoding is necesary whenever the command contains '/' characters, as this would otherwise generate invalid directory paths. Create a new Device with a name that contains the command you wish to execute enclosed in semi-colons, ending with a '3' character: !librenms-1

Be careful to tick the "Force Add" option, otherwise the request will be rejected. Click add: !librenms-2

A directory matching the hostname of the Device will be created whenever a PollDevice job is launched. For the purpose of the demonstration, we will be triggering this manually with artisan: !librenms-4

We can confirm that this directory indeed exists on the system: !librenms-5

We can now update the snmpget parameter value to point to any binary on the system, making sure that the specified path includes the directory that was just created: !librenms-13

Visiting the /about page will trigger the payload, then we can check that our code was indeed executed: !librenms-10

Impact Server takeover

Other sources

LibreNMS before 24.10.0 allows a remote attacker to execute arbitrary code via OS command injection involving AboutController.php's index(), SettingsController.php's update(), and PollDevice.php's initRrdDirectory().

MITRE

Affected Software

2 affected componentsFixes available
composer/librenms/librenms<=24.9.1
24.10.0
librenms librenms<24.10.0

Event History

Nov 15, 2024
Advisory Published
via GitHub·03:54 PM
May 8, 2026
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
Description
Data Sourced
via NVD·06:16 AM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-51092?

CVE-2024-51092 has a high severity level due to the potential for arbitrary code execution.

2

How do I fix CVE-2024-51092?

To fix CVE-2024-51092, update librenms/librenms to version 24.10.0 or later.

3

What are the consequences of CVE-2024-51092?

The consequences of CVE-2024-51092 include unauthorized access to sensitive configurations and execution of arbitrary OS commands.

4

Who is affected by CVE-2024-51092?

CVE-2024-51092 affects users running librenms/librenms versions up to and including 24.9.1.

5

When was CVE-2024-51092 discovered?

CVE-2024-51092 was disclosed in the GitHub advisory on a specific date that can be referred to in documentation.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203