fix: escape provider text in the batch scanner #90

Merged
jfro merged 1 commit from fix/batch-scanner-escape into main 2026-10-25 22:54:35 +00:00
Owner

Fixes a stored-XSS in the batch scanner found in the v0.9 review (no ticket).

Provider text (book title, author, ISBN, media type, error messages) was interpolated into innerHTML in the result rows (addResultItem) and in showToast. Open Library records are publicly editable, so a title like <img src=x onerror=...> would run script in the signed-in user's session when scanned.

  • Small esc() helper for every untrusted value in the row templates
  • Toast and scanner-status text now set with textContent (icons stay markup)
  • book.id in the View link is URI-encoded

Testing:

  • Nye's jsdom proof (drives the page's real processBarcode flow) fails on main, passes here
  • Extra jsdom cases for the "exists" row, error rows and toasts: fail on main, pass here
  • Chromium check on the dev server: hostile text renders as text, normal rows/links/icons unchanged
  • mix precommit: 635 passed

No in-repo JS test: the project has no JS test runner and this didn't seem worth adding one (jsdom) for. Touches the same file as #85; expect a trivial rebase.

Fixes a stored-XSS in the batch scanner found in the v0.9 review (no ticket). Provider text (book title, author, ISBN, media type, error messages) was interpolated into `innerHTML` in the result rows (`addResultItem`) and in `showToast`. Open Library records are publicly editable, so a title like `<img src=x onerror=...>` would run script in the signed-in user's session when scanned. - Small `esc()` helper for every untrusted value in the row templates - Toast and scanner-status text now set with `textContent` (icons stay markup) - `book.id` in the View link is URI-encoded Testing: - Nye's jsdom proof (drives the page's real `processBarcode` flow) fails on main, passes here - Extra jsdom cases for the "exists" row, error rows and toasts: fail on main, pass here - Chromium check on the dev server: hostile text renders as text, normal rows/links/icons unchanged - `mix precommit`: 635 passed No in-repo JS test: the project has no JS test runner and this didn't seem worth adding one (jsdom) for. Touches the same file as #85; expect a trivial rebase.
jfro added this to the v0.9.0 milestone 2026-10-25 21:22:48 +00:00
fix: escape provider text in the batch scanner
All checks were successful
CI / test (pull_request) Successful in 47s
2dc4c04362
Book titles, authors and errors from providers (Open Library records are
publicly editable) went into innerHTML in result rows and toasts, so a
title like <img onerror=...> ran script in the signed-in session. Escape
them with a small esc() helper, and set toast and status text via
textContent.
jfro merged commit e6ef95f160 into main 2026-10-25 22:54:35 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/fuzzy_catalog!90
No description provided.