CVE-2026-27156: Nicegui Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-78qv-3mpx-9cqq
CVSS 6.1
CWE-79
Published
Advisory Summary

CVE-2026-27156 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Nicegui libraries in the PyPI ecosystem. The issue involves nicegui vulnerable to xss via code injection during client-side element function execution. Remediation is available by upgrading affected packages to version 3.8.0.

CVE-2026-27156 at a Glance

CVE Identifier CVE-2026-27156
GHSA Identifier GHSA-78qv-3mpx-9cqq
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Nicegui
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-27156

To remediate this vulnerability, upgrade all affected Nicegui dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nicegui fixed: 3.8.0
pip install nicegui>=3.8.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show nicegui

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-27156, inspect your installed packages using pip:

pip show nicegui

Analyze the terminal output to locate any version of Nicegui in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.8.0), your application is affected.

Note: The pip show nicegui command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Nicegui, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary Several NiceGUI APIs that execute methods on client-side elements (`Element.run_method()`, `AgGrid.run_grid_method()`, `EChart.run_chart_method()`, and others) use an `eval()` fallback in the JavaScript-side `runMethod()` function. When user-controlled input is passed as the method name, an attacker can inject arbitrary JavaScript that executes in the victim's browser. Additionally, `Element.run_method()` and `Element.get_computed_prop()` used string interpolation instead of `json.dumps()` for the method/property name, allowing quote injection to break out of the intended string context. ### Attack Vector An attacker crafts a malicious URL with a payload as a query parameter. If the application passes this parameter as a method name to any of the affected APIs, the payload is sent to the client via WebSocket and executed via `eval()`. **Example:** `/?method=alert(document.cookie)` combined with application code like: ```python element.run_method(user_provided_method_name) ``` ### Impact - Cookie/token theft - DOM manipulation (phishing, fake login forms) - Actions performed as the victim user ### Affected Methods 1. `Element.run_method()` 2. `Element.get_computed_prop()` 3. `AgGrid.run_grid_method()` 4. `AgGrid.run_row_method()` 5. `EChart.run_chart_method()` 6. `JsonEditor.run_editor_method()` 7. `Xterm.run_terminal_method()` 8. `Leaflet.run_map_method()` 9. `Leaflet.run_layer_method()` 10. `LeafletLayer.run_method()` ### Fix 1. Use `json.dumps()` for proper escaping of method/property names in `run_method()` and `get_computed_prop()` 2. Remove the `eval()` fallback from `runMethod()` in `nicegui.js` — method names that are not found on the element now raise an error instead of being evaluated as arbitrary JavaScript ### Migration Code that previously passed JavaScript functions as method names needs to use `ui.run_javascript()` instead: ```python # Before: row = await grid.run_grid_method('g => g.getDisplayedRowAtIndex(0).data') # After: row = await ui.run_javascript(f'return getElement({grid.id}).api.getDisplayedRowAtIndex(0).data') ```

CVE-2026-27156 Affected Nicegui Versions

1 component(s)
Fixed Versions:
3.8.0
Product / Package Ecosystem Affected Versions Fixed Version
nicegui
PyPI
< 3.8.0
3.8.0

References

Frequently Asked Questions

What is CVE-2026-27156?
CVE-2026-27156 is a security vulnerability in Nicegui involving NiceGUI vulnerable to XSS via Code Injection during client-side element function execution under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Nicegui versions are affected?
Affected versions include releases prior to 3.8.0 across affected packages: nicegui.
What version fixes CVE-2026-27156?
Upgrading to 3.8.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nicegui affected?
Yes, nicegui is affected in releases prior to 3.8.0. Upgrade your dependency to 3.8.0 or later.
What is the CVSS score of CVE-2026-27156?
CVE-2026-27156 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-27156?
CVE-2026-27156 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check PyPI dependencies for CVE-2026-27156?
Run the dependency tree command: 'pip show nicegui'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-78qv-3mpx-9cqq",
  "modified" : "2026-03-06T19:51:35Z",
  "published" : "2026-02-24T19:56:18Z",
  "aliases" : [ "CVE-2026-27156" ],
  "summary" : "NiceGUI vulnerable to XSS via Code Injection during client-side element function execution",
  "details" : "### Summary\n\nSeveral NiceGUI APIs that execute methods on client-side elements (`Element.run_method()`, `AgGrid.run_grid_method()`, `EChart.run_chart_method()`, and others) use an `eval()` fallback in the JavaScript-side `runMethod()` function. When user-controlled input is passed as the method name, an attacker can inject arbitrary JavaScript that executes in the victim's browser.\n\nAdditionally, `Element.run_method()` and `Element.get_computed_prop()` used string interpolation instead of `json.dumps()` for the method/property name, allowing quote injection to break out of the intended string context.\n\n### Attack Vector\n\nAn attacker crafts a malicious URL with a payload as a query parameter. If the application passes this parameter as a method name to any of the affected APIs, the payload is sent to the client via WebSocket and executed via `eval()`.\n\n**Example:** `/?method=alert(document.cookie)` combined with application code like:\n```python\nelement.run_method(user_provided_method_name)\n```\n\n### Impact\n\n- Cookie/token theft\n- DOM manipulation (phishing, fake login forms)\n- Actions performed as the victim user\n\n### Affected Methods\n\n1. `Element.run_method()`\n2. `Element.get_computed_prop()`\n3. `AgGrid.run_grid_method()`\n4. `AgGrid.run_row_method()`\n5. `EChart.run_chart_method()`\n6. `JsonEditor.run_editor_method()`\n7. `Xterm.run_terminal_method()`\n8. `Leaflet.run_map_method()`\n9. `Leaflet.run_layer_method()`\n10. `LeafletLayer.run_method()`\n\n### Fix\n\n1. Use `json.dumps()` for proper escaping of method/property names in `run_method()` and `get_computed_prop()`\n2. Remove the `eval()` fallback from `runMethod()` in `nicegui.js` — method names that are not found on the element now raise an error instead of being evaluated as arbitrary JavaScript\n\n### Migration\n\nCode that previously passed JavaScript functions as method names needs to use `ui.run_javascript()` instead:\n\n```python\n# Before:\nrow = await grid.run_grid_method('g => g.getDisplayedRowAtIndex(0).data')\n\n# After:\nrow = await ui.run_javascript(f'return getElement({grid.id}).api.getDisplayedRowAtIndex(0).data')\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "nicegui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.8.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.7.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/security/advisories/GHSA-78qv-3mpx-9cqq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-27156"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/commit/1861f59cc374ca0dc9d970b157ef3774720f8dbf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zauberzeug/nicegui"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-24T19:56:18Z",
    "nvd_published_at" : "2026-02-24T18:29:33Z"
  }
}