CVE-2022-46945
CVE-2022-46945
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- Low
- User Interaction
- None
- Scope
- Changed
- Confidentiality
- High
- Integrity
- Low
- Availability
- Low
Description
Nagvis before 1.9.34 was discovered to contain an arbitrary file read vulnerability via the component /core/classes/NagVisHoverUrl.php.
Comprehensive Technical Analysis of CVE-2022-46945 (NagVis Arbitrary File Read Vulnerability)
1. Vulnerability Assessment and Severity Evaluation
CVE ID: CVE-2022-46945
CVSS Score: 9.1 (Critical) – [CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N]
Vulnerability Type: Arbitrary File Read (Information Disclosure)
Component Affected: /core/classes/NagVisHoverUrl.php
Severity Breakdown:
- Attack Vector (AV:N): Network-exploitable, allowing remote attackers to trigger the vulnerability without authentication.
- Attack Complexity (AC:L): Low – Exploitation requires minimal effort, as no special conditions are needed.
- Privileges Required (PR:N): None – Unauthenticated attackers can exploit this flaw.
- User Interaction (UI:N): None – No user interaction is required.
- Scope (S:U): Unchanged – The impact is confined to the vulnerable NagVis instance.
- Confidentiality (C:H): High – Arbitrary file read can expose sensitive system files (e.g.,
/etc/passwd, configuration files, credentials). - Integrity (I:H): High – While primarily an information disclosure flaw, file read access could facilitate further attacks (e.g., credential theft, reconnaissance).
- Availability (A:N): None – The vulnerability does not directly impact system availability.
Justification for Critical Severity: The combination of unauthenticated remote access, low attack complexity, and high impact on confidentiality and integrity justifies the CVSS 9.1 rating. This vulnerability is particularly dangerous in environments where NagVis is exposed to untrusted networks (e.g., the internet or DMZs).
2. Potential Attack Vectors and Exploitation Methods
Exploitation Mechanism:
The vulnerability resides in NagVisHoverUrl.php, which improperly handles user-supplied input when processing hover URLs. An attacker can manipulate the url parameter to traverse directories and read arbitrary files on the underlying system.
Exploitation Steps:
- Identify Target: Locate a vulnerable NagVis instance (versions before 1.9.34).
- Craft Malicious Request:
- Send a GET/POST request to the NagVis endpoint (e.g.,
/nagvis/frontend/nagvis-js/index.php). - Inject a path traversal payload in the
urlparameter:/nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=hover&url=../../../../../../etc/passwd
- Send a GET/POST request to the NagVis endpoint (e.g.,
- File Read: The server processes the request and returns the contents of the specified file (e.g.,
/etc/passwd).
Advanced Exploitation Scenarios:
- Credential Theft: Read sensitive files such as:
/etc/shadow(if permissions allow)- NagVis configuration files (
/etc/nagvis/nagvis.ini.php) - Database credentials (
/etc/nagvis/conf.d/auth.db)
- Reconnaissance: Enumerate system files to identify further attack vectors (e.g., SSH keys, web server configs).
- Chaining with Other Vulnerabilities:
- If NagVis is integrated with Checkmk (as referenced in the SonarSource advisory), this vulnerability could be part of a Remote Code Execution (RCE) chain (e.g., CVE-2022-46946, CVE-2022-46947).
- File read access could enable LFI-to-RCE via log poisoning or PHP wrappers (if PHP is misconfigured).
Proof-of-Concept (PoC) Example:
GET /nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=hover&url=../../../../../../etc/passwd HTTP/1.1
Host: vulnerable-nagvis.example.com
User-Agent: Mozilla/5.0
Connection: close
Expected Response:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
3. Affected Systems and Software Versions
Vulnerable Versions:
- NagVis versions before 1.9.34 (all prior releases are affected).
Systems at Risk:
- Nagios-based monitoring environments (NagVis is commonly used as a visualization tool for Nagios/Icinga/Checkmk).
- Checkmk deployments (as referenced in the SonarSource advisory, this vulnerability is part of a multi-stage RCE chain in Checkmk).
- Linux servers running NagVis (most common deployment environment).
- Web-exposed NagVis instances (increased risk if accessible from untrusted networks).
Unaffected Versions:
- NagVis 1.9.34 and later (patched version).
4. Recommended Mitigation Strategies
Immediate Actions:
-
Upgrade to NagVis 1.9.34 or Later:
- Apply the official patch from the NagVis GitHub repository.
- Follow the upgrade guide.
-
Temporary Workarounds (if patching is not immediately possible):
- Restrict Network Access:
- Use firewall rules to limit access to NagVis to trusted IPs only.
- Deploy WAF (Web Application Firewall) rules to block path traversal attempts (e.g.,
../sequences).
- Disable Hover URL Functionality:
- Modify
NagVisHoverUrl.phpto sanitize input or disable the feature entirely.
- Modify
- File System Hardening:
- Restrict NagVis process permissions (run as a non-root user with minimal privileges).
- Use AppArmor/SELinux to confine NagVis access to only necessary files.
- Restrict Network Access:
-
Monitor for Exploitation Attempts:
- Log Analysis: Monitor web server logs for suspicious requests containing
../orurl=parameters. - IDS/IPS Rules: Deploy Snort/Suricata rules to detect path traversal attempts:
alert tcp any any -> $HTTP_SERVERS $HTTP_PORTS (msg:"CVE-2022-46945 NagVis Path Traversal Attempt"; flow:to_server,established; content:"/nagvis/frontend/nagvis-js/index.php"; nocase; content:"url=..%2F"; nocase; reference:cve,2022-46945; classtype:attempted-recon; sid:1000001; rev:1;)
- Log Analysis: Monitor web server logs for suspicious requests containing
Long-Term Recommendations:
- Regular Vulnerability Scanning: Use tools like Nessus, OpenVAS, or Nuclei to detect unpatched NagVis instances.
- Least Privilege Principle: Ensure NagVis runs with the minimum required permissions.
- Network Segmentation: Isolate monitoring tools (NagVis, Nagios, Checkmk) in a dedicated VLAN with strict access controls.
- Patch Management: Subscribe to NagVis security advisories and apply updates promptly.
5. Impact on the Cybersecurity Landscape
Broader Implications:
-
Increased Attack Surface for Monitoring Tools:
- NagVis is widely used in enterprise monitoring environments, making it a high-value target for attackers.
- Similar vulnerabilities in Nagios, Icinga, and Checkmk have been exploited in the past (e.g., CVE-2021-37333, CVE-2022-40684).
-
Exploitation in Multi-Stage Attacks:
- As demonstrated in the SonarSource advisory, this vulnerability can be chained with other flaws (e.g., CVE-2022-46946, CVE-2022-46947) to achieve RCE in Checkmk.
- Attackers may use file read access to steal credentials, escalate privileges, or move laterally within a network.
-
Supply Chain Risks:
- NagVis is often bundled with other monitoring tools (e.g., Checkmk), increasing the risk of supply chain attacks.
- Organizations using outdated versions of NagVis may unknowingly expose critical infrastructure.
-
Compliance and Regulatory Impact:
- Failure to patch may result in non-compliance with PCI DSS, ISO 27001, or NIST SP 800-53 requirements.
- Organizations may face legal liabilities if sensitive data is exposed due to this vulnerability.
6. Technical Details for Security Professionals
Root Cause Analysis:
The vulnerability stems from improper input validation in NagVisHoverUrl.php, where the url parameter is not sanitized before being used in file operations. Specifically:
- The code fails to validate path traversal sequences (
../). - The
file_get_contents()function is used without proper path restrictions, allowing arbitrary file reads.
Vulnerable Code Snippet (Pre-Patch):
// NagVisHoverUrl.php (Vulnerable Version)
public function getHoverUrlContents($url) {
if (preg_match('/^http(s)?:\/\//', $url)) {
return file_get_contents($url); // Unsafe for local file reads
} else {
return file_get_contents($url); // No path validation
}
}
Patched Code (NagVis 1.9.34):
// NagVisHoverUrl.php (Fixed Version)
public function getHoverUrlContents($url) {
if (preg_match('/^http(s)?:\/\//', $url)) {
return file_get_contents($url);
} else {
// Validate path to prevent directory traversal
if (strpos($url, '..') !== false || strpos($url, '/') === 0) {
throw new NagVisException('Invalid URL');
}
$path = cfg('paths', 'base') . '/share/' . $url;
if (!file_exists($path)) {
throw new NagVisException('File not found');
}
return file_get_contents($path);
}
}
Exploitation Detection:
- Log Indicators:
- Web server logs showing requests with
url=../../orurl=/etc/passwd. - Unusual file access patterns in system logs (
auditd,syslog).
- Web server logs showing requests with
- Network Indicators:
- HTTP requests to
/nagvis/frontend/nagvis-js/index.phpwith suspiciousurlparameters. - Outbound connections from the NagVis server (if exfiltrating data).
- HTTP requests to
Forensic Analysis:
- Check for Compromise:
- Review web server logs for exploitation attempts.
- Inspect NagVis configuration files for unauthorized modifications.
- Check for unexpected files in
/tmp/or/var/www/(potential staging areas for exfiltration).
- Memory Forensics:
- Use Volatility or Rekall to analyze NagVis process memory for injected payloads.
Advanced Exploitation Techniques:
- Bypassing Basic Filters:
- URL Encoding:
../→%2e%2e%2f - Double Encoding:
%252e%252e%252f - Null Byte Injection:
../../../../etc/passwd%00
- URL Encoding:
- Chaining with Other Vulnerabilities:
- If NagVis is integrated with Checkmk, attackers may use this flaw to steal credentials and pivot to RCE (as seen in the SonarSource advisory).
Conclusion
CVE-2022-46945 represents a critical arbitrary file read vulnerability in NagVis, enabling unauthenticated attackers to access sensitive system files. Given its high CVSS score (9.1) and potential for chaining into RCE, organizations must prioritize patching and implement defensive measures (e.g., WAF rules, network segmentation).
Security teams should:
- Immediately upgrade to NagVis 1.9.34.
- Monitor for exploitation attempts using IDS/IPS and log analysis.
- Assess the broader impact on integrated monitoring tools (e.g., Checkmk).
- Review access controls to ensure NagVis is not exposed to untrusted networks.
Failure to mitigate this vulnerability could lead to data breaches, credential theft, and further compromise of critical infrastructure.