To restrict a browser agent's network access, decide which sites the task needs, enforce that list somewhere the agent cannot change it, and block internal addresses by default. This is one of the few controls that still works after an agent has been misled by a web page.
What is prompt injection, and why does it matter for browser agents?
Prompt injection is input that changes a language model's behaviour in ways its operator did not intend. OWASP defines it as occurring "when user prompts alter the LLM's behavior or output in unintended ways", and separates the indirect kind: "Indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files" (OWASP LLM01:2025, read 2026-11-24).
Browser agents meet the indirect kind on every page they read. NIST describes the core problem: "Because GenAI models combine the data and instruction channels, attackers can leverage the data channel to affect system operations" (NIST AI 100-2e2025, read 2026-11-24).
How often do injection attacks succeed against web agents?
Published studies report that injection attacks against web agents often succeed, at least in part.
Table: Published results on attacks against web and computer-use agents
| Study | Setting | Reported result |
|---|---|---|
| WASP (arXiv 2504.18575) | Injections on self-hosted web apps | "attacks partially succeed in up to 86% of the case" |
| EIA (arXiv 2409.11295) | Hidden elements on real websites | "up to 70% ASR in stealing specific PII" |
| Pop-up attacks (arXiv 2411.02391) | Pop-ups in OSWorld and VisualWebArena | Agents clicked pop-ups in "86% on average" of cases |
| Adversarial images (arXiv 2406.12814) | One changed image on a VisualWebArena page | "success rates up to 67%" |
All read 2026-11-24. The WASP authors add a useful nuance: agents "often struggle to fully complete the attacker goals". That is not a defence. An attack that half works may still send one cookie or one address to the wrong place.
NIST's own evaluation of agent hijacking found that red-teamed attacks raised attack success "from 11% for the strongest baseline attack to 81% for the strongest new attack" (NIST agent hijacking evaluations, read 2026-11-24).
What does a network allow-list protect against?
A network allow-list protects against what a misled agent can do with the network: send data to an attacker, download a tool, or reach systems it should not. It does not stop the agent from reading the injected text.
NIST's guidance points to this kind of design. It advises that designers "may design systems with the assumption that prompt injection attacks are possible if a model is exposed to untrusted input sources" (NIST AI 100-2e2025, read 2026-11-24). An allow-list is such an assumption turned into a rule.
Step 1: How do I decide what to allow?
Decide what to allow from the task, not from the agent.
- List the sites the task must visit, by hostname.
- Run the task with logging on and record every hostname the pages actually load: scripts, fonts, APIs and image hosts.
- Allow the task's sites and the supporting hosts they need. Leave out analytics and ad hosts the task can work without.
- Write the list down per task type. A booking task and a research task should not share one long list.
- Default to deny for everything else.
Step 2: How do I enforce the list outside the browser?
Enforce the list outside the browser, where the agent has no control.
- A forward proxy. Point the browser at a proxy that only forwards allowed hostnames. Playwright can set a proxy for the whole browser or per context; the per-context option is "Network proxy settings to use with this context" (Playwright Browser API, read 2026-11-24). Chromium's
--proxy-serverswitch "tells Chrome to use a custom proxy configuration" (Chromium network settings, read 2026-11-24). - A container network with firewall rules. Give the browser container a network whose only route out is the proxy. Then a browser that ignores its proxy setting still cannot connect elsewhere.
The firewall matters because a proxy setting alone does not cover every lookup. Chromium's SOCKS proxy page notes that with a proxy set, parts of the browser such as the DNS prefetcher can still resolve names locally, and gives a catch-all rule, --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE myproxy", "to prevent Chrome from sending any DNS requests over the network" (Chromium SOCKS proxy, read 2026-11-24).
Step 3: Which addresses should always be blocked?
Always block addresses that lead into your own systems, even if a hostname on the list resolves to them.
- Private network ranges and loopback addresses.
- The link-local range, which includes the cloud instance metadata address that can hand out machine credentials.
- Internal DNS names, such as names under your company's internal domains.
- The address of the agent's own control services and any container management socket.
Check the resolved address at the proxy, not only the hostname, so that a public name pointing at an internal address is refused.
Step 4: How do I add routing rules inside the browser?
Add in-browser routing as a second layer, for clearer errors and faster failure. Playwright's context.route() can abort any request: "Routing provides the capability to modify network requests that are made by any page in the browser context" (Playwright BrowserContext API, read 2026-11-24).
- Register a route for
**/*that aborts requests whose hostname is not on the list. - Launch contexts with
serviceWorkers: 'block'. Playwright warns that routing "will not intercept requests intercepted by Service Worker" and recommends "disabling Service Workers when using request interception" (same page). - Log every blocked request with the page that made it. A spike in blocks is a sign of an injection attempt.
Note that "Enabling routing disables http cache" (same page), so expect slightly slower page loads.
Step 5: What else limits the damage of an injection?
Other controls cover what an allow-list cannot.
- Least privilege. OWASP: "Restrict the model's access privileges to the minimum necessary for its intended operations" (OWASP LLM01:2025, read 2026-11-24).
- Human approval for risky actions. OWASP lists "Require human approval for high-risk actions". Posting, paying, deleting and sending messages are the usual candidates.
- Mark untrusted content. OWASP's advice to "Separate and clearly denote untrusted content" applies to what the harness passes to the model.
- No secrets in context. An agent that never saw a password cannot type it into a form. See keeping credentials out of a browser agent.
- Disposable sessions. Anything an injection plants dies with the session.
How do I test the restrictions?
Test the restrictions by attacking your own agent in a safe environment.
- From inside a session, try to load a site that is not on the list. It should fail at the proxy.
- Try an internal address and the metadata address directly. Both should fail.
- Put a page with an injected instruction on an allowed test site and check what the agent does.
- Use published injection benchmarks, such as WASP, which runs on self-hosted copies of web apps and simulates attacks "without exposing the agent to real harm" (WASP repository, read 2026-11-24).
What we read for this article
- OWASP LLM01:2025 Prompt Injection, read 2026-11-24
- NIST AI 100-2e2025, Adversarial Machine Learning, read 2026-11-24
- NIST technical blog on agent hijacking evaluations, read 2026-11-24
- WASP (arXiv 2504.18575) and repository, read 2026-11-24
- EIA (arXiv 2409.11295), read 2026-11-24
- Attacking Vision-Language Computer Agents via Pop-ups (arXiv 2411.02391), read 2026-11-24
- Dissecting Adversarial Robustness of Multimodal LM Agents (arXiv 2406.12814), read 2026-11-24
- Playwright BrowserContext API and Browser API, read 2026-11-24
- Chromium network settings and SOCKS proxy, read 2026-11-24
Frequently asked
What is prompt injection in a browser agent?
It is text on a web page, in a document or in an email that the agent reads and follows as if it were an instruction. OWASP calls this indirect prompt injection, because it arrives through content rather than from the user.
Does a network allow-list stop prompt injection?
No. The agent can still read the injected text and act on it. An allow-list limits the damage, because the browser cannot reach sites outside the list to send data or download tools.
Can an agent leak data through an allowed site?
Yes. If an allowed site accepts user content, such as a forum post, an issue or a search query, an attacker can ask the agent to put data there. Allow only what the task needs and require approval for posting.
Is blocking requests with Playwright's route enough?
Not on its own. Routing runs inside the browser your agent controls, and Playwright notes it does not see requests handled by service workers. Enforce the list at a proxy or firewall outside the browser too.