Repository navigation
fix(render): accept only plain hosts in --allow-host (#2496) - #4180
Merged
Merged
Conversation
Each allowHosts entry becomes one EXCLUDE in the renderer's Chrome DNS blackhole, whose rule list is comma-separated with wildcard patterns. `*` exempted every host, and a comma injected another rule. A shared render-template check now accepts only a plain host name or IP literal: createRenderer throws before any launch, and `brain render --allow-host` turns it into a usage error naming the value. An allowed host also admits only http and https requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
Independent reviewReviewed head 4471a27 against base c26fb22. Reviewer: agent. No findings. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4180,
"head": "4471a270163d350e0d0978c803571af6f1a72b52",
"base": "c26fb229fa1ef920ce219e77256e859e9982c263",
"reviewer": "agent",
"outcome": "no-findings",
"findings": []
} |
schlessera
marked this pull request as ready for review
November 17, 2026 11:32
9 of 10 tasks
5 tasks
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.
Closes #2496.
What this does
Each
allowHostsentry becomes oneEXCLUDE <host>in the renderer's Chrome DNS blackhole (--host-resolver-rules), the load-bearing network-denial layer. Nothing validated the entries, so--allow-host '*'exempted every host, and a value with a comma injected another resolver rule.allowHostProblem/normalizeAllowHostsin@schlessera/brain-render-template/internal(packages/render-template/src/allow-hosts.ts). An entry must be lowercase-able labels of letters, digits,-and_, or a bracketed IPv6 literal, and must round-trip unchanged throughnew URL("http://" + h).hostname. The pattern is load-bearing: the WHATWG URL parser keeps*and,in a host name, so the round trip alone accepts both.createRenderernormalizes the list through that check and throws on the first bad entry, before any launch. The resolver rule uses the normalized entries.brain render --allow-hostturns the same check into aUsageError(exit 1) naming the value, before any document is built or rendered. The renderer is an optional peer that core imports dynamically, so the CLI checks on its own, from the shared function.hostRequestAllowed(extracted from the renderer'shostAllowed) also requireshttp:orhttps:.docs/cli.mdand the renderer README state the rule. Therender-templateAPI report lists the two new internal exports.Acceptance criteria
*,a.test, MAP * 10.0.0.1,a.test b.test,https://a.test,a.test:8080each throw before any launchrenderer.test.ts"createRenderer refuses … before any launch" (alsoa,b.test,*.ithaca.test,a.test/path,""), each asserting zero launchesEXCLUDEper entry and no other rule--host-resolver-rulesargument; a second test covers mixed case, IPv4, bracketed IPv6 and_brain render doc.md --allow-host '*' --jsonexits with the usage error and names the valuepackages/core/tests/render.test.ts"--allow-host '*' is a usage error…" forhtmlandpdf, plus the comma-injection valuehostAllowedrefuses a non-HTTP(S) URL on an allowed hostws:,wss:,ftp:,file:)*case failsProof
hostRequestAllowedextracted unchanged and no validation, all nine refusal cases failed on "Received function did not throw", the scheme test failed onws://img.example.test/live, and the three CLI tests failed on the exit code. The launch-args test passed before and after, as a characterization of valid input.createRenderer refuses "*" before any launchwith "Received function did not throw".*,a,b.testand*.ithaca.test.bun run test packages/ui-render-puppeteer packages/core/tests/render.test.ts: 72 pass.packages/core/tests: 3422 pass, 6 fail. The six are environment-only on this host: two real-Chrome PDF tests ("No Chrome/Chromium executable found"), a real-worker tmpfs test and three paid-provider offline runtime tests. None runs the changed code paths without Chrome. Hosted CI runs them.check:prpass.Contract impact
None to the contract surface: the
brain render --jsonenvelope, MCP tools,schema_versionand frontmatter are unchanged.--allow-hostnow refuses values such as*that it used to accept and that defeated the network denial. The changeset names the refusal.Collisions
bun scripts/collisions.ts --json --pr 4180at head 4471a27: closure reports only (shared test categories and workspaces) with #3054, #3056, #3059, #3069, #3581, #3622, #4002, #4036, #4151, #4157, #4166, #4168, #4172, #4173, #4175, #4177 and #4179. No PR edits the changed source files.{"version":1,"kind":"brain-check-pr-receipt","head":"7cf0e198ad1a7643561298ee08a622d909ff7034","base":"origin/main","mode":"focused","startedAt":"2026-11-17T11:29:54.245Z","finishedAt":"2026-11-17T11:31:38.846Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12800.032302999998},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":110.83405800000037},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":75.72482799999852},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":21.958631000001333},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":91575.58518699999}]}🤖 Generated with Claude Code