security-model

The security design rules for r3, including how it protects a local web service from browser-based attacks such as DNS rebinding and from casual remote access. They define binding, host checks, and the limits of the protection.

In plain words
What is it for?
Use them when changing r3's network binding, host allowlists, public URL handling, login gate, or API request checks.
Why use it?
They explain which requests must be guarded and which threats the system does and does not address. This prevents changes that accidentally weaken its security boundaries.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hyperlogue/r3/security-model
Any agent
npx skills add hyperlogue/r3 --skill security-model
Clone the repo
git clone --depth 1 https://github.com/hyperlogue/r3

Made for: Claude Code, Codex.

Per session 120 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,288 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00120 $0.02288
Opus 5 $0.00060 $0.01144
Sonnet 5 $0.00024 $0.00458
Haiku 4.5 $0.00012 $0.00229

Measured 2d ago against content hash e0ca00bbbec1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

security-model scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

`Origin` header (as `curl` sends none), so while the daemon isn't exposed, any
.claude/skills/security-model/SKILL.md · 177 lines

How it starts

The opening of the file, as written. The whole thing — 177 lines — stays where its author put it; the contents beside it link to each section on GitHub.

r3's security model

This file is the design source of truth for r3's security posture — update it here when the posture changes. AGENTS.md carries only the one-line invariants; the reasoning lives here.

The threat model r3 actually defends: browser-borne attack (DNS rebinding, cross-origin fetch) and casual remote access. It explicitly does not defend against other local UIDs — see "What this does not protect" below.

The bind

Binds 127.0.0.1 by default. R3_BIND overrides it, and that is an explicit opt-in with consequences (it arms the login gate — below). Never bind 0.0.0.0.

Layer 1 — the Host guard (DNS-rebinding defense)

Every request that returns data or the token — i.e. all of /api/*, including /api/boot — must carry a Host that is one of:

  • loopback,
  • an allowlisted name (R3_ALLOWED_HOSTS, exact names, never *), or
  • the advertised public host, derived from R3_PUBLIC_URL and allowed implicitly (config.ts) — since r3 hands that URL out, it must resolve. This is why a single R3_PUBLIC_URL=https://<name> is enough for tailscale serve, with no separate R3_ALLOWED_HOSTS for the common one-host case.

The static SPA shell + hashed JS/CSS/favicon are served natively by Bun.serve's routes, outside this Hono guard. That's fine: they carry no secrets and grant no capability — the app is inert until the Host-gated /api/boot bootstraps it. Never let a data/token endpoint out from behind the guard.

Every /api data endpoint requires the per-user token or a valid session cookie (resolveAuth) — reads as well as writes.

Always token-free (still Host-gated):

Route Extra gate
/api/health
/api/boot same-origin
/api/auth/login same-origin (you have no session yet)
/api/events only while REQUIRE_LOGIN is off

/api/events is the subtle one: EventSource can't set headers, so SSE goes token-free while login isn't required. Once REQUIRE_LOGIN is on, a session cookie rides EventSource and it's gated like any read. Note the condition is REQUIRE_LOGIN, not "exposed" — there is no EXPOSED predicate, and R3_REQUIRE_LOGIN=0 on an exposed daemon leaves SSE open.

Read the full file on GitHub · 177 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 177 lines · 120 tokens per session scan A e0ca00bbbec1

Subscribe to this mod's changes

security-model is a skill published in the GitHub repository hyperlogue/r3 (23 stars, last pushed 7d ago), licensed MIT. It adds 120 tokens to every session and 2,288 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.