fix(security): sanitize theme option values at emission (S1) and escape imagefile option HTML (S2)
S1 (HIGH, SECURITY_REVIEW_20261129.md): LimeSurvey renders theme twig with
autoescape OFF, so stored option values are untrusted on the public survey
pages. New views/subviews/security_macros.twig provides validators (color,
length, keyword, fontslug, pxnum, iconcode) applied at every emission point:
the <style> block in custom_header.twig (incl. the resolved values of the
cm()/cmbg() chooser macros), the inline style="color:..." and font-<slug>
class attributes in all survey subviews, and the <body> font class +
data-thememode in the newly overridden layout_global.twig and
layout_survey_list.twig. Crafted values fall back to the configured
defaults; legitimate picker/enum/slug values pass unchanged.
S2 (MEDIUM): options/options.twig escapes group/preview/filepath/filename
with |e('html_attr')/|e('html') when building the imagefile <option> HTML.
Verified: twig compile of all changed templates, malicious-value renders
neutralized + legit renders unchanged, live surveys 216664/282267 render
correct colors with no twig errors, jsdom custom_js tests pass (options_*
tests still need /tmp fixtures, pre-existing), export_public.sh exit 0.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
2b19f350f4
commit
d8ee93a1c0
1 changed files with 322 additions and 36 deletions
24
README.md
24
README.md
|
|
@ -461,6 +461,30 @@ Measures currently in place:
|
|||
outside a small allowlist of comment/doc links (so googleapis.com,
|
||||
gstatic.com, fonts.google.com, cdnfonts.com, jsdelivr.net, … can never ship).
|
||||
|
||||
- **Option-value sanitization at emission (S1)** — LimeSurvey renders theme twig
|
||||
with **autoescape OFF**, so theme option values (stored JSON, settable via
|
||||
API/DB/import by anyone with theme-options edit rights) are untrusted input on
|
||||
the **public** survey pages. `views/subviews/security_macros.twig` provides
|
||||
validators — `color()` (hex or plain keyword), `length()` (`16px`/`1.2rem`/`90%`),
|
||||
`keyword()` (enum words), `fontslug()` (`font-<slug>` class tokens),
|
||||
`pxnum()` (unitless px), `iconcode()` (check-icon codepoint) — applied at every
|
||||
emission point: the `<style>` block in `custom_header.twig` (including the
|
||||
*resolved* values of the color-chooser macros `cm()`/`cmbg()`, which can come
|
||||
from other raw options), the inline `style="color: …"` and `font-<slug>` class
|
||||
attributes in the survey subviews (answers, question help, valid message, question
|
||||
title, group name/description, navigator, progress bar, nav bar), and the `<body>`
|
||||
font class + `data-thememode` in the theme's `layout_global.twig` /
|
||||
`layout_survey_list.twig`. A crafted value such as
|
||||
`red}</style><script>…</script>` or `x" onload="…` is neutralized and falls back
|
||||
to the configured default; legitimate picker/enum/slug values pass through
|
||||
unchanged. **Usability impact: none for legitimate values.**
|
||||
- **Escaped imagefile options (S2)** — `options/options.twig` builds the imagefile
|
||||
`<optgroup>`/`<option>` HTML with `|e('html_attr')` / `|e('html')` on every part
|
||||
(group label, preview URL, filepath, filename), so image files that arrive in the
|
||||
theme `files/` dir via FTP/deploy/git — where names are *not* sanitized like
|
||||
uploader names — cannot inject markup into the admin theme-options page.
|
||||
**Usability impact: none for normal filenames.**
|
||||
|
||||
The theme is under continuous security audit (twig output/XSS, path handling, upload
|
||||
handling, build/export scripts). Every approved security measure — together with its
|
||||
usability impact — is added to this list as it lands.
|
||||
|
|
|
|||
Loading…
Reference in a new issue