CVE-2024-38972

6.1 MEDIUM

📋 TL;DR

This CVE describes a cross-site scripting (XSS) vulnerability in NetBox v4.0.3 that allows attackers to inject malicious scripts into the Name parameter when adding power ports. Attackers can execute arbitrary web scripts or HTML in victims' browsers, potentially stealing session cookies or performing actions on behalf of authenticated users. Organizations running vulnerable NetBox instances are affected.

💻 Affected Systems

Products:
  • NetBox
Versions: v4.0.3
Operating Systems: All platforms running NetBox
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects the /dcim/power-ports/add/ endpoint with Name parameter. Requires attacker to have access to the application interface.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could steal administrator session cookies, gain administrative access to NetBox, pivot to internal systems, and potentially compromise the entire infrastructure.

🟠

Likely Case

Attackers steal authenticated user sessions, modify or delete network configuration data, or redirect users to malicious sites.

🟢

If Mitigated

With proper input validation and output encoding, the attack would fail to execute scripts, limiting impact to data corruption at most.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires the attacker to have access to the power port creation interface, which typically requires authentication. The vulnerability is in a specific form field with public proof-of-concept available.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: v4.0.4 or later

Vendor Advisory: https://github.com/netbox-community/netbox/releases

Restart Required: Yes

Instructions:

1. Backup your NetBox database and configuration. 2. Update NetBox to version 4.0.4 or later using pip: 'pip install --upgrade netbox'. 3. Run database migrations: 'python manage.py migrate'. 4. Restart the NetBox service: 'systemctl restart netbox'.

🔧 Temporary Workarounds

Input Validation Filter

all

Implement server-side input validation to sanitize the Name parameter before processing.

Modify /opt/netbox/netbox/dcim/forms.py to add validation for PowerPortForm Name field

WAF Rule

all

Deploy a web application firewall rule to block XSS payloads in the Name parameter.

Add ModSecurity rule: SecRule ARGS:name "@detectXSS" "id:1001,phase:2,deny,status:403"

🧯 If You Can't Patch

  • Implement strict Content Security Policy (CSP) headers to prevent script execution
  • Disable or restrict access to the /dcim/power-ports/add/ endpoint using network controls

🔍 How to Verify

Check if Vulnerable:

Test by attempting to inject a basic XSS payload like '<script>alert(1)</script>' into the Name field when adding a power port. If the script executes when viewing the power port, the system is vulnerable.

Check Version:

python -c "import netbox; print(netbox.__version__)"

Verify Fix Applied:

After patching, repeat the XSS test. The payload should be properly escaped and displayed as text rather than executed as script.

📡 Detection & Monitoring

Log Indicators:

  • Unusual POST requests to /dcim/power-ports/add/ with script tags in parameters
  • Multiple failed login attempts followed by power port creation requests

Network Indicators:

  • HTTP requests containing <script>, javascript:, or other XSS patterns in the Name parameter

SIEM Query:

source="netbox.log" AND ("POST /dcim/power-ports/add/" AND ("<script>" OR "javascript:" OR "onerror="))

🔗 References

📤 Share & Export