Kein-chronicle

Localhost Origin Guard — Development skill for Claude Code

Development community

Allow a browser app to talk to your local agent or bridge only if the Host is exact loopback and the Origin is explicitly allow-listed.

How to install Localhost Origin Guard

This entry records only its repository, not the path inside it, so there is no exact command to give. Open Kein-chronicle/localhost-origin-guard and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Localhost Origin Guard does

Allow a browser app to talk to your local agent or bridge only if the Host is exact loopback and the Origin is explicitly allow-listed.

Alternatives in Development

  • CORS — Scan an endpoint for CORS misconfiguration — arbitrary-origin reflection, null-origin trust, credential exposu 4.5k ★
  • Add To Amux Board — You are adding an item to the amux local kanban board at https://localhost:8822/api/board 86 ★
  • Review Extension — Browser-extension + bridge review with extension-reviewer (Primary Owner) 52 ★

README

localhost-origin-guard

**Allow a browser app to talk to your local agent or bridge only if the Host is exact loopback and the Origin is explicitly allow-listed.**

[![test](https://github.com/Kein-chronicle/localhost-origin-guard/actions/workflows/test.yml/badge.svg)](https://github.com/Kein-chronicle/localhost-origin-guard/actions/workflows/test.yml) ![license](https://img.shields.io/badge/license-MIT-blue.svg) ![dependencies](https://img.shields.io/badge/dependencies-none-brightgreen.svg)

Why

A local server reachable from any web page is a remote-control surface. Checking `Origin` and the `Host` header exactly blocks cross-site requests and DNS-rebinding style hosts such as `localhost:8731.evil.example`.

Install

**As a Claude Code skill** (Claude uses it when the task matches the skill description):

git clone https://github.com/Kein-chronicle/localhost-origin-guard.git ~/.claude/skills/local-origin-guard

For a single project, clone into `/.claude/skills/local-origin-guard` instead, then start a new Claude Code session.

**As a library** (Node.js 22+, no dependencies):

npm install github:Kein-chronicle/localhost-origin-guard

or copy the one file you need: `scripts/guard.mjs` is self-contained.

**Requires:** Node.js 22+.

Quick start

Run the quickstart:

$ node examples/quickstart.mjs
true  allowed origin on loopback
true  127.0.0.1 is fine too
false unlisted origin
false origin with trailing slash (not canonical)
false DNS-rebinding style Host
false wrong port in Host
false no Origin header at all

The output above is real: it is produced by the files in `examples/`.

API

import { requestAllowed } from 'localhost-origin-guard';

requestAllowed({
  host: req.headers.host, origin: req.headers.origin,
  port: 8731, allowedOrigins: ['https://editor.example.com'],
});  // true / false

`Host` must be exactly `localhost:PORT`, `127.0.0.1:PORT` or `[::1]:PORT`; `Origin` must be in the list and