PT-2026-59327 · Pypi · Nicegui
Publicado
2026-07-13
·
Atualizado
2026-07-13
CVSS v3.1
7.5
Alta
| Vetor | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
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:python
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():python
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.Correção
Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾
Identificadores relacionados
Produtos afetados
Nicegui