Skip to content

viewer: escape ts and superseded_by cells in page.html (stored-XSS defense-in-depth) #11

Closed

Description

@abogartz

Context

Found while reviewing #10 (viewer request guards). The bundled page renders store data via innerHTML; every field passes through esc() except two cells:

  • src/viewer/page.html — the ts cell: ${m.ts.split("T")[0]} and ${(m.ts.split("T")[1] || "").slice(0,8)} (~line 201)
  • src/viewer/page.html — the superseded badge: badge("status-superseded", \superseded → ${m.superseded_by.slice(0,8)}`); badge()` (~line 229) interpolates its text argument raw into HTML.

Why it matters

Store values come from files on disk. ts and superseded_by are normally written by code as ISO timestamps, but the record-split injection fixed in #9 was exactly the route by which a hostile memory_import file or auto-capture could plant arbitrary values in those fields. A value like <img src=x onerror=…> would execute in the viewer's own origin, inheriting its same-origin write access to the whole store.

#9 closes the injection route; the reader should still not trust the store (defense in depth).

Fix

Wrap both cells in esc(). One-line change each. Add a test seeding a row whose superseded_by contains HTML and asserting the rendered page escapes it (or at least a unit test on the render helper if extracted).

Related: the sibling hardening of validating ts shape at read time is tracked separately.

Activity

  1. added
    bug
    on Oct 21, 2026
  2. abogartz-opencode-self-improvement commented on Oct 22, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.6.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions