Skip to content

viewer /api/restore joins raw body.name — files outside the store can be promoted into memory #21

Closed

Description

@abogartz

Found by the 2026-10-21 security review (SECURITY-REVIEW-2026-10-21.md, finding F2). Reproduced on main 286d2ba.

restoreRoute in src/viewer/server.ts builds paths from raw body.name without basenaming:

snapshotFiles([join(memoryRoot(), name.replace(/^\d+-/, ""))])
restoreSnapshot(join(snapshotDir(), name), ...)

Probe (hermetic store): POST /api/restore with {"name":"../../outside/planted.logfmt"} returned 200, and the planted row appeared as <memDir>/planted.logfmt — loaded by loadAll() and injectable into subsequent sessions.

Impact: any user-readable, logfmt-parseable file anywhere on disk can be promoted into the active store (read + persistent-poisoning primitive; combines with #11 XSS to complete a browser-driven chain). The memory_undo tool path is safe — it basenames first.

Fix direction (P0): basename() + enforce the snapshot-name shape ^<epoch-ms>-<YYYY-MM-DD>.logfmt$ in the route, and verify in restoreSnapshot that the resolved target stays inside the memory root (defense in depth for all callers). Test: ..-bearing and absolute names → 400, nothing written.

Activity

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

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.3.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  3. added 2 commits that reference this issue on Oct 21, 2026
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