Kritisch

LibreNMS has an Authenticated OS Command Injection

  • Veröffentlicht: 15.11.2024
  • Aktualisiert: 11.10.2026 10:22

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 shell_exec() 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>

            'version_webserver' => $request->server('SERVER_SOFTWARE'),
            'version_rrdtool' => Rrd::version(),
            'version_netsnmp' => str_replace('version: ', '', rtrim(shell_exec(Config::get('snmpget', 'snmpget') . ' -V 2>&1'))),

           <TRUNCATED>
        ]);
    }

We can see that the version_netsnmp key receives a value direclty dependent of a shell_exec() 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);
    $config_item = $config->get($id);

    if (! $config_item->checkValue($value)) {
        return $this->jsonResponse($id, $config_item->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 $config_item->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 shell_exec() 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
{
    $host_rrd = \Rrd::name($this->device->hostname, '', '');
    if (Config::get('rrd.enable', true) && ! is_dir($host_rrd)) {
        try {
            mkdir($host_rrd);
            Log::info("Created directory : $host_rrd");
        } catch (\ErrorException $e) {
            Eventlog::log("Failed to create rrd directory: $host_rrd", $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 <LIBRENMS_INSTALL_DIR>/rrd/<DEVICE_HOSTNAME>.

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/<DEVICE_HOSTNAME>/../../../../../../../bin/ls)
  • Trigger a code execution via the shell_exec() 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

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Composer-Paket librenms/librenms < 24.10.0 24.10.0

Verweise

CVSS-Wert 9.1/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:L
Schwäche (CWE)
CWE-78
Plattform
Composer
Paket
librenms/librenms
Veröffentlicht
15.11.2024
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-x645-6pf9-xwxw - CC BY 4.0

Schwachstellenhistorie: librenms/librenms

Alle veröffentlichten Schwachstellen dieses Pakets (Composer-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (106) im Archiv
Einträge insgesamt
106
Erste → letzte
10.2019 08.2026
Ohne Fix
6
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 5
  • Hoch 39
  • Mittel 56
  • Niedrig 6

Veröffentlichungen pro Jahr

  1. 2019: 6
  2. 2020: 0
  3. 2021: 7
  4. 2022: 26
  5. 2023: 12
  6. 2024: 24
  7. 2025: 15
  8. 2026: 16
Schweregrad:
  1. Hoch · 7.1 CVE-2026-84192 < 26.5.0 26.5.0
  2. Hoch · 7.1 CVE-2020-36947 <= 1.46 keine Korrektur
  3. LibreNMS has an Authenticated OS Command Injection dieser Eintrag
    Kritisch · 9.1 CVE-2024-51092 < 24.10.0 24.10.0
  4. Hoch · 7.8 CVE-2023-5591 < 23.10.0 23.10.0
  5. Hoch · 8.4 CVE-2023-5060 < 23.9.1 23.9.1
  6. Hoch · 7.6 CVE-2023-4347 < 23.8.0 23.8.0
  7. Hoch · 8.8 CVE-2022-3525 < 22.10.0 22.10.0
  8. Hoch · 7.6 CVE-2022-4068 < 22.10.0 22.10.0
  9. Kritisch · 9.8 CVE-2022-4070 < 22.10.0 22.10.0
  10. Hoch CVE-2022-29712 < 22.4.0 22.4.0
  11. Kritisch · 9.8 CVE-2019-10665 <= 1.47 keine Korrektur
  12. Kritisch · 9.8 CVE-2018-20434 = 1.46 keine Korrektur
  13. Hoch · 8.8 CVE-2018-20678 < 1.65 1.65
  14. Hoch · 7.1 CVE-2022-0580 < 22.2.0 22.2.0
  15. Hoch · 7.1 CVE-2022-0587 < 22.2.0 22.2.0
  16. Kritisch · 9.8 CVE-2021-44278 <= 21.11.0 keine Korrektur
  17. Hoch · 8.8 CVE-2020-15877 < 1.65.1 1.65.1
  18. Hoch · 8.8 CVE-2020-35700 < 21.1.0 21.1.0
Mehr anzeigen (4) 40 von 44 angezeigt

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.