fix: TUI hardening — non-loopback LAN gate + assert cc_entrypoint (#115)#122
Merged
Conversation
Two TUI-mode findings from the 2026-05-31 audit (ADR 0007):
1. The fail-loud LAN gate refused TUI boot only when CLAUDE_BIND === "0.0.0.0",
but binding to a concrete LAN IP, a Tailscale 100.x address, or IPv6 :: is
equally network-exposed and slipped through — letting any reachable peer drive
the operator's full-filesystem claude session. New isLoopbackBind() treats only
127.0.0.0/8 / ::1 / localhost / ::ffff:127.0.0.1 as safe; the gate now trips on
any non-loopback bind (OCP_TUI_ALLOW_LAN=1 escape hatch retained).
2. verifyEntrypoint() was implemented and unit-tested but never wired: readTuiTranscript
discarded the events and returned only text, so a silent degrade to the metered
sdk-cli (Agent SDK) billing pool — which still returns text but costs money — went
undetected. readTuiTranscript now returns { text, entrypoint }; runTuiTurn passes it
through; callClaudeTui logs a "tui_entrypoint_mismatch" warning when configured cli
mode yields a non-cli entrypoint (including null/unverified). callClaudeTui still
returns Promise<string>, so singleflight/cache/completion downstream is unchanged.
ALIGNMENT.md: TUI is a proxy-side execution-mode bridge (ADR 0007); this adds a local
bind classifier (startup gate) + a non-fatal log assertion of an existing classification
— no Anthropic operation forwarded, so a cli.js citation is N/A under Rule 2. No
blacklisted tokens or port literals introduced; alignment.yml passes.
Independent fresh-context reviewer (opus): APPROVE WITH MINOR (Iron Rule 10) — verified
isLoopbackBind via truth table (no exposed address misclassified as loopback — the
dangerous direction), the full string→{text,entrypoint} contract ripple across all
callers (Promise<string> preserved), the mismatch logic (warns on sdk-cli AND null in
cli mode, silent for auto/off, non-fatal), and ALIGNMENT N/A via a fetch/header grep.
Minors are process-only (this commit body; a future lib/ extraction of the test-mirrored
helper). npm test → 181 passed, 0 failed.
Closes #115.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the two TUI-mode hardening findings from the 2026-05-31 audit (#115, P2; ADR 0007).
0.0.0.0; a concrete LAN IP / Tailscale100.x/ IPv6::slipped through (any reachable peer could drive the operator's full-filesystem claude session). NewisLoopbackBind()treats only127.0.0.0/8/::1/localhost/::ffff:127.0.0.1as safe; the gate now trips on any non-loopback bind.OCP_TUI_ALLOW_LAN=1escape hatch retained.cc_entrypoint—verifyEntrypoint()was implemented + unit-tested but never wired;readTuiTranscriptdiscarded the events, so a silent degrade to the meteredsdk-clipool (still returns text, but costs money) went undetected.readTuiTranscriptnow returns{ text, entrypoint };runTuiTurnpasses it through;callClaudeTuilogstui_entrypoint_mismatchwhen configuredclimode yields a non-clientrypoint (incl.null/unverified).callClaudeTuistill returnsPromise<string>→ downstream unchanged.ALIGNMENT.md
alignment.ymlpasses.isLoopbackBindvia truth table (no exposed address misclassified as loopback — the dangerous direction is sound; default127.0.0.1still boots), the fullstring→{text,entrypoint}contract ripple across every caller (grepped;Promise<string>preserved for singleflight/cache/completion), the mismatch logic (warns onsdk-cliANDnullinclimode, silent forauto/off, non-fatal), and ALIGNMENT N/A via a fetch/header grep.npm test→ 181 passed, 0 failed. Verdict APPROVE WITH MINOR (process-only minors).Closes #115.
🤖 Generated with Claude Code