+ "details": "## Summary\n\nA **Boolean-Based Blind SQL Injection** vulnerability was identified in the LibreNMS application at the `/ajax_output.php` endpoint. The `hostname` parameter is interpolated directly into an SQL query without proper sanitization or parameter binding, allowing an attacker to manipulate the query logic and infer data from the database through conditional responses.\n\n---\n\n## Details\n\n- **Vulnerable Endpoint:** `GET /ajax_output.php\n \n- **Parameter:** `hostname`\n\n- **Authentication Required:** Admin privileges required to access `/ajax_output.php` discovery endpoint\n\n- **Vulnerability type:** Boolean-Based Blind SQL Injection — input is concatenated into a SQL statement without proper escaping\n\n---\n\n## Description\n\nThe LibreNMS application uses the `hostname` parameter during device discovery operations to query the database for matching devices. \nHowever, user-supplied data is concatenated directly into the SQL query within `/opt/librenms/includes/html/output/capture.inc.php` without adequate sanitization..\n\nThis allows attackers to modify the query logic using Boolean expressions. \nWhen crafted conditions evaluate to **true**, the application behaves normally and returns the expected device data. \nWhen conditions evaluate to **false**, the response is altered (e.g., the queried host is not found).\n\nThis difference in behavior confirms that the parameter’s value is being interpreted as SQL logic, demonstrating a **Boolean-Based Blind SQL Injection**.\n\nNote: This vulnerability requires an authenticated user with **administrator privileges** to access the affected discovery functionality. While this limits exploitation to internal or compromised admin sessions, the vulnerability still represents a critical security risk due to the ability to manipulate backend SQL logic in privileged contexts.\n\n---\n\n## Proof of Concept (PoC)\n\n1 - **Authenticate with an administrator account.** \nThe discovery endpoint `/ajax_output.php` is accessible only to users with admin-level privileges.\n\n2 - Access the following URL with the payload that evaluates to `TRUE`:\n\n```\nGET /ajax_output.php?id=capture&format=text&type=discovery&hostname=10.0.5.4'+AND+1=1+AND+'1'='1 HTTP/1.1\nHost: 10.0.5.5:8000\nAccept: */*\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nReferer: http://10.0.5.5:8000/device/3/capture\nCookie: laravel_session=[ADMIN_SESSION_COOKIE]\nPriority: u=0\n```\n\n3 - Observe that the system returns the expected data and triggers the discovery process.\n\n<img width=\"1507\" height=\"666\" alt=\"image\" src=\"https://github.com/user-attachments/assets/584e871a-a01a-4bad-8e09-c6dcb0e6cd1d\" />\n\n4 - Now repeat the request with a `FALSE` condition:\n\n```\nGET /ajax_output.php?id=capture&format=text&type=discovery&hostname=10.0.5.4'+AND+1=2+AND+'1'='1 HTTP/1.1\nHost: 10.0.5.5:8000\nAccept: */*\nAccept-Language: en-US,en;q=0.5\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\nReferer: http://10.0.5.5:8000/device/3/capture\nCookie: laravel_session=[SESSION COOKIE]\nPriority: u=0\n```\n\n5 - Observe that the response is altered: no device is found, and no discovery is triggered.\n\n<img width=\"1496\" height=\"662\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b7d227bd-0a37-4589-81b6-26cca5135837\" />\n\n### Query behavior observed in logs\n\n``SQL[SELECT * FROM `devices` WHERE disabled = 0 AND `hostname` LIKE '10.0.5.4' AND 1=1 AND '1'='1' ORDER BY device_id DESC [] 0.5ms]``\n\nThe difference in output confirms that the injected Boolean logic is being executed by the database.\n\n---\n\n## Impact\n\nBoolean-based SQL Injection can have severe consequences depending on the deployment context:\n\n- **Data extraction:** Attackers can infer database data (schema, users, configuration) through Boolean inference techniques.\n \n- **System compromise:** Database or application state could be manipulated if the injection is further exploited.\n \n- **Information disclosure:** Reveals internal SQL structure and logic of the LibreNMS backend.\n \n\n---\n\n## References\n\n- CWE-89 — Improper Neutralization of Special Elements used in an SQL Command (‘SQL Injection’)\n \n- OWASP SQL Injection Prevention Cheat Sheet",
0 commit comments