NiceGUI: Local file disclosure via Docutils file insertion in ui.restructured_text()
Description
Summary
ui.restructured_text() renders reStructuredText server-side with Docutils without disabling file insertion directives.
When a NiceGUI application passes attacker-controlled content to ui.restructured_text(), an attacker can use standard Docutils directives (include, csv-table with :file:, raw with :file:) to read local files readable by the NiceGUI server process.
Applications that only pass trusted static strings to ui.restructured_text() are not affected.
Details
The affected component is the reStructuredText renderer:
- File:
nicegui/elements/restructured_text.py - Function:
prepare_content()
prepare_content() renders user-supplied reStructuredText through Docutils:
html = publish_parts(
remove_indentation(content),
writer_name='html4',
settings_overrides={'syntax_highlight': 'short'},
)
The Docutils call only sets syntax_highlight. It does not disable file insertion or raw directives, so Docutils processes directives that read local files and embed their contents into the generated HTML before it is returned to the browser. Frontend sanitization cannot prevent this because the file has already been read server-side.
A minimal vulnerable usage pattern is any page that forwards untrusted input into ui.restructured_text(), e.g. content taken from query parameters, form fields, or other user-controlled sources.
Impact
Local file disclosure. An attacker who can supply reStructuredText content can read files accessible to the NiceGUI server process. Depending on deployment, this may expose:
- application
.envfiles - database URLs, API tokens, session/storage secrets
- OAuth or cloud credentials
- Docker or Kubernetes mounted secrets
- application source files
- logs and other process-readable files
The confirmed impact is confidentiality loss through arbitrary local file read. Applications are only impacted when they pass untrusted or user-controlled reStructuredText into ui.restructured_text().
Recommended fix
Disable unsafe Docutils features in prepare_content():
html = publish_parts(
remove_indentation(content),
writer_name='html4',
settings_overrides={
'syntax_highlight': 'short',
'file_insertion_enabled': False,
'raw_enabled': False,
'_disable_config': True,
},
)
This blocks the include, csv-table :file:, and raw :file: directives as well as local docutils.conf overrides.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
NiceGUI's ui.restructured_text() allows local file disclosure by passing untrusted content to Docutils without disabling file insertion directives.
Vulnerability
ui.restructured_text() in NiceGUI (file nicegui/elements/restructured_text.py, function prepare_content()) renders reStructuredText server-side using Docutils with only syntax_highlight set in settings_overrides, leaving dangerous docutils directives (include, csv-table with :file:, raw with :file:) enabled. Any version using this UI element is affected. The vulnerability is reachable when an application passes attacker-controlled content—e.g., from query parameters, form fields—to ui.restructured_text(). Applications using only trusted static strings are not affected [1], [2], [3].
Exploitation
An attacker needs only the ability to supply reStructuredText input to a NiceGUI application that passes it to ui.restructured_text(). No authentication or special network position is required beyond access to the vulnerable endpoint. The attacker crafts a reStructuredText payload such as .. include:: /etc/passwd or .. csv-table:: :file: /app/.env. Docutils reads the target file server-side and embeds its contents into the generated HTML, which is then returned to the attacker's browser. No user interaction is required [2], [3].
Impact
Successful exploitation results in arbitrary local file disclosure. The attacker can read any file the NiceGUI server process can access, potentially exposing .env files, database URLs, API tokens, session secrets, OAuth credentials, Docker/Kubernetes mounted secrets, application source code, and logs. The impact is confidentiality loss through a server-side file read that cannot be mitigated by frontend sanitization [2], [3].
Mitigation
The recommended fix is to disable unsafe Docutils features in prepare_content() by passing 'file_insertion_enabled': False and 'raw_enabled': False in settings_overrides. The fix was included in a security advisory but no specific patched version number is disclosed in the references; users should monitor the NiceGUI GitHub repository for updates [2], [3]. As a workaround, avoid passing untrusted content to ui.restructured_text(). There is no known KEV listing.
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
2<= 3.11.1+ 1 more
- (no CPE)range: <= 3.11.1
- (no CPE)
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
2News mentions
0No linked articles in our index yet.