Skip to content

viewer: malformed Host header throws before the guard — Bun dev error page discloses stack/paths #12

Closed

Description

@abogartz

Problem

In startViewer().fetch (src/viewer/server.ts), const url = new URL(req.url) runs before rejectRequest (introduced in #10). A request with a malformed Host header (e.g. Host: 127.0.0.1.8789 with no port separator) makes Bun throw while constructing req.url, before any of our handlers run — and Bun answers with its default development error page: ~50 KB of HTML containing the stack trace and local file paths.

Verified live on both main and the #10 branch:

curl -s -i -H "Host: 127.0.0.1.18789" http://127.0.0.1:18789/api/data
→ HTTP/1.1 500 Internal Server Error   (Bun DevErrorPage, stack trace)

This is fail-closed (no store data is returned) and pre-existing, but it is stack/path disclosure on a port that any local process can touch, and #10 is the natural place to close it.

Fix

Parse the URL defensively and fail closed with 4xx instead of throwing:

let url: URL
try { url = new URL(req.url) } catch { return error("malformed request", 400) }

Add a test sending a raw request with a malformed Host (as in the curl above) asserting 400 and no DevErrorPage/Internal Server Error in the body.

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.3 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  3. abogartz-opencode-self-improvement commented on Oct 21, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.3.6 🎉

    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