localhost-origin-guard
로컬 에이전트로 가는 요청을 Host가 정확히 루프백이고 Origin이 허용 목록에 있을 때만 통과시킵니다.
어떤 문제를 푸나The problem
아무 웹 페이지에서나 닿는 로컬 서버는 원격 조종 통로가 됩니다. Host와 Origin을 정확히 비교하면 교차 사이트 요청과 DNS 리바인딩 같은 호스트(localhost:8731.evil.example)를 막을 수 있습니다.
이런 분께 맞습니다Who it is for
브라우저 앱과 로컬 에이전트·브리지를 연결하는 도구를 만드는 개발자.
무엇을 하나What it does
- requestAllowed({host, origin, port, allowedOrigins})는 true나 false만 돌려줍니다. 인수가 없거나 형식이 틀려도 던지지 않고 false입니다.
- Host는 localhost:PORT, 127.0.0.1:PORT, [::1]:PORT만 허용하고 Origin은 목록에 있는 정식 형태여야 합니다.
- HTTP 요청과 WebSocket 핸드셰이크 모두에 적용하라고 안내합니다.
직접 돌려 본 출력Real output
저장소의 examples 폴더를 실행한 결과입니다.
$ 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
알아둘 한계Limits
- 입력 필터 하나일 뿐 인증이 아닙니다. 루프백 바인딩, 별도의 세션 자격, 본문 크기 제한을 함께 쓰십시오.
- Origin이 없는 네이티브 클라이언트는 별도의 인증 경로가 필요합니다.
받아서 쓰기Get it
# 저장소를 받습니다
git clone https://github.com/Kein-chronicle/localhost-origin-guard.git
# Claude Code 스킬로 쓰려면 이 폴더 이름으로 받습니다
git clone https://github.com/Kein-chronicle/localhost-origin-guard.git ~/.claude/skills/local-origin-guard
정보Info
- 분류Category
- 문서·데이터 라이브러리Document & data libraries
- 형태Type
- 라이브러리Library
- 라이선스License
- MIT
- 필요한 것Requires
- Node.js 22 이상
- 저장소Repository
- localhost-origin-guard
- 토픽Topics
securitylocalhostcorsdns-rebindingwebsocketjavascriptesmzero-dependencies
2026-10-18 기준: 저장소의 테스트를 로컬에서 실행해 통과했고, 예제 출력은 저장소의 examples 폴더를 실제로 실행한 결과입니다.