viewer/studio: escape texture preview URL and format in texture grid cards (VIEWER-STUDIO-TEXTURE-ESCAPE) #704

Manually merged
github merged 1 commit from gh-pr/704/head into gh-pr/704/base 2026-11-26 09:17:09 +00:00
Owner

@⁠kirigayakazima on GitHub · 2026-11-24 12:25 UTC · original
kirigayakazima:fix/viewer-studio-texture-escape → main · +36 −4 · 2 files · 1 commits · merged 2026-11-24 14:37 UTC

Claimed in the coordination issue as: VIEWER-STUDIO-TEXTURE-ESCAPE #14

What and why

In viewer/studio.html (renderTexturesGrid), escapeHtml was applied to t.name, while t.preview (src="...") and t.format (<span>...</span>) were interpolated raw into card.innerHTML in both the initial 80-card batch and the "show all" batch.

A hostile t.preview or t.format string containing quotes/markup (for example "><img src=x onerror=alert(1)>) broke out of the HTML attribute/element and injected elements/event handlers. Escaping both fields with escapeHtml(t.preview) and escapeHtml(t.format) in both batches aligns them with t.name and the model list in renderAccordionList.

Adds a synthetic regression test in tests/test_viewer_studio.cjs covering both preview and format across card 0 (initial batch) and card 80 ("show all" batch). No game files used.

Tested

Windows 11 x64, Node v24.19.0, Python 3.14.7, CPU only, synthetic inputs only (no game files). Commit 9280ce0370ecbfe935a445e8cb125d1bdb9bfccf.

  • node tests/test_viewer_studio.cjs:
    • before the fix in viewer/studio.html: new test fails with injected <img src=x onerror=alert(1)> tag in tagShape(...);
    • with the fix: 12/12 passed, 0 failed.
  • node tests/test_viewer_streaming.cjs: 57/57 passed, 0 failed.
  • python -I tests/test_viewer_cdn_integrity.py: 10 tests, OK.
  • python -I tests/test_ci_registration.py: 15 tests, OK.
  • python -I tests/test_text_write_line_endings.py: 3 tests, OK.
  • python -I scripts/check_no_game_data.py viewer/studio.html tests/test_viewer_studio.cjs and git diff --check: clean (exit 0).

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)
**@⁠kirigayakazima** on GitHub · 2026-11-24 12:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/704) `kirigayakazima:fix/viewer-studio-texture-escape` → `main` · +36 −4 · 2 files · 1 commits · merged 2026-11-24 14:37 UTC Claimed in the coordination issue as: VIEWER-STUDIO-TEXTURE-ESCAPE https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 ### What and why In `viewer/studio.html` (`renderTexturesGrid`), `escapeHtml` was applied to `t.name`, while `t.preview` (`src="..."`) and `t.format` (`<span>...</span>`) were interpolated raw into `card.innerHTML` in both the initial 80-card batch and the `"show all"` batch. A hostile `t.preview` or `t.format` string containing quotes/markup (for example `"><img src=x onerror=alert(1)>`) broke out of the HTML attribute/element and injected elements/event handlers. Escaping both fields with `escapeHtml(t.preview)` and `escapeHtml(t.format)` in both batches aligns them with `t.name` and the model list in `renderAccordionList`. Adds a synthetic regression test in `tests/test_viewer_studio.cjs` covering both `preview` and `format` across card 0 (initial batch) and card 80 (`"show all"` batch). No game files used. ### Tested Windows 11 x64, Node v24.19.0, Python 3.14.7, CPU only, synthetic inputs only (no game files). Commit `9280ce0370ecbfe935a445e8cb125d1bdb9bfccf`. - `node tests/test_viewer_studio.cjs`: - before the fix in `viewer/studio.html`: new test fails with injected `<img src=x onerror=alert(1)>` tag in `tagShape(...)`; - with the fix: **12/12 passed, 0 failed**. - `node tests/test_viewer_streaming.cjs`: **57/57 passed, 0 failed**. - `python -I tests/test_viewer_cdn_integrity.py`: **10 tests, OK**. - `python -I tests/test_ci_registration.py`: **15 tests, OK**. - `python -I tests/test_text_write_line_endings.py`: **3 tests, OK**. - `python -I scripts/check_no_game_data.py viewer/studio.html tests/test_viewer_studio.cjs` and `git diff --check`: clean (exit `0`). GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:08 +00:00
github manually merged commit 9280ce0370 into gh-pr/704/base 2026-11-26 09:17:09 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 12:29 UTC · original · approved these changes

Reviewed and verified VIEWER-STUDIO-TEXTURE-ESCAPE. Escaping \ .preview\ in the <img>\ src attribute and \ .format\ in the texture metadata card with \escapeHtml()\ closes markup injection vectors in both initial and show-all batches. Unit test in \ ests/test_viewer_studio.cjs\ confirms tag shape stability and unescaped payload rejection. Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 12:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/704#pullrequestreview-6039198638) · **approved these changes** Reviewed and verified VIEWER-STUDIO-TEXTURE-ESCAPE. Escaping \ .preview\ in the \<img>\ src attribute and \ .format\ in the texture metadata card with \escapeHtml()\ closes markup injection vectors in both initial and show-all batches. Unit test in \ ests/test_viewer_studio.cjs\ confirms tag shape stability and unescaped payload rejection. Approved.
This discussion has been locked. Commenting is limited to contributors.
No description provided.