Skip to content

render: unvalidated --allow-host entries can switch off the renderer's DNS blackhole #2496

Closed

Description

@schlessera

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 with repeatedValues (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 :306 and :365.
  • createRenderer lowercases the entries into allowedHostSet (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 '*' produces EXCLUDE *, 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

  • createRenderer rejects (throws) any allowHosts entry that is not a plain DNS hostname or IP literal: no wildcard, comma, whitespace, scheme, port or path. Normalize through new URL("http://" + h).hostname and require the result to equal the lowercased input.
  • brain render --allow-host surfaces that rejection as a UsageError naming the bad value, before any browser launches.
  • hostAllowed also requires the URL's protocol to be http: or https:.

Out of scope

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 one EXCLUDE per entry and no other rule.
  • brain render doc.md --allow-host '*' --json exits with the usage error code and names the value, proven by a CLI test.
  • hostAllowed refuses 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 lint

Contract 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

  1. added
    type: fix
    area: core
    area: render
    priority: p1
    agent-ready
    security
    on Oct 21, 2026
  2. self-assigned this
    on Nov 17, 2026
  3. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    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.

  4. added this to the 0.45.0 milestone on Nov 17, 2026
  5. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    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. createRenderer throws on any other entry before a launch, and brain render --allow-host reports 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 only http: and https: requests. Each acceptance case has a test that failed before the change. The PR records the mutation receipts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: corearea: renderpriority: p1securitytype: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions