Repository navigation
Description
Context
The puppeteer renderer's network denial depends on a Chrome DNS blackhole. The comment calls it "the load-bearing layer", because request interception never sees prerender, preconnect, iframes, popups or WebSocket handshakes. Each allowHosts entry is pasted into that rule verbatim (packages/ui-render-puppeteer/src/renderer.ts:217-223):
`--host-resolver-rules=MAP * ~NOTFOUND${allowHosts.map((h) => `, EXCLUDE ${h}`).join("")}`Nothing validates an entry on the way in:
brain render --allow-host <value>collects values withrepeatedValues(packages/core/src/cli/commands/render.ts:75-85, called at:294). That only checks the value is present and does not start with--. It is passed on at:306and:365.createRendererlowercases the entries intoallowedHostSet(renderer.ts:157-158) and otherwise trusts them.
Chrome's host-resolver-rules syntax is a comma-separated list of rules, and EXCLUDE takes a host pattern with wildcards. So:
--allow-host '*'producesEXCLUDE *, which exempts every host from the blackhole.- An entry containing a comma injects a further rule, e.g.
--allow-host 'x.test, MAP * 10.0.0.1'.
A second, smaller gap: hostAllowed (renderer.ts:265-272) compares only new URL(url).hostname, so an interception for any scheme on an allowed host passes, not only http:/https:.
brain render is usually run by an agent that may have read untrusted content. Scripts are off by default, which limits the impact, but the allowlist is the boundary that keeps a rendered document from reaching the network.
Scope
createRendererrejects (throws) anyallowHostsentry that is not a plain DNS hostname or IP literal: no wildcard, comma, whitespace, scheme, port or path. Normalize throughnew URL("http://" + h).hostnameand require the result to equal the lowercased input.brain render --allow-hostsurfaces that rejection as aUsageErrornaming the bad value, before any browser launches.hostAllowedalso requires the URL's protocol to behttp:orhttps:.
Out of scope
- Allowing wildcard or suffix patterns (
*.example.test). That is a feature request, not this fix. - Changing how render-template placeholders remote images (
packages/render-template/src/template.ts:63-64). - The image-placeholder bypasses tracked in render: responsive and shadow images bypass remote-image placeholders #1827.
Acceptance criteria
-
createRenderer({ allowHosts: ["*"] }),["a.test, MAP * 10.0.0.1"],["a.test b.test"],["https://a.test"]and["a.test:8080"]each throw before any launch. A test asserts each one and fails before the change. - A test inspecting the launch args for a valid list (
["img.example.test", "192.0.2.10"]) shows exactly oneEXCLUDEper entry and no other rule. -
brain render doc.md --allow-host '*' --jsonexits with the usage error code and names the value, proven by a CLI test. -
hostAllowedrefuses a non-HTTP(S) URL on an allowed host, with a test. - Mutation receipt: remove the validation and watch the
*case fail on its named assertion.
Verification
bun run test packages/ui-render-puppeteer packages/core/tests
bun run typecheck
bun run lintContract impact
None to the contract surface: the brain render --json envelope, MCP tools, schema_version and frontmatter do not change. --allow-host starts refusing values such as * that it used to accept and that defeated the network denial. That is a published behaviour fix, and its changeset should name the refusal.
Found by a repository review on 2026-10-22.
Activity
schlessera commentedon Nov 17, 2026
Claimed for implementation. Claim token:
claim-8531d0d4. Branch:fix/2496-validate-allow-host.Collisions: closure reports only (shared test categories), no PR edits renderer.ts or render.ts.
fix(render): accept only plain hosts in --allow-host (#2496) (#4180)
schlessera commentedon Nov 17, 2026
Delivered in #4180 (squash df1e105). A shared check in
@schlessera/brain-render-template/internal(allowHostProblem,normalizeAllowHosts) accepts only a plain host name or IP literal.createRendererthrows on any other entry before a launch, andbrain render --allow-hostreports it as a usage error naming the value, before anything renders. The resolver rule is built from the normalized entries, and an allowed host admits onlyhttp:andhttps:requests. Each acceptance case has a test that failed before the change. The PR records the mutation receipts.