servers icon indicating copy to clipboard operation
servers copied to clipboard

puppeteer: update old MCP SDK and add browser-automation guardrails by default

Open lcv-leo opened this issue 6 months ago • 11 comments

Summary

While auditing and hardening local MCP server usage, I reviewed @modelcontextprotocol/[email protected] and built a local hardened wrapper for our environment. I am opening this issue to share findings and possible upstream improvements.

Browser automation exposed as an MCP tool is high impact: it can navigate to arbitrary targets, execute page JavaScript, capture screenshots, submit forms, and interact with local/private network targets if not constrained. The current server appears designed as a reference/demo server; the suggestions below are intended to make it safer for default agent use.

Package/runtime reviewed

  • Package: @modelcontextprotocol/[email protected]
  • npm latest observed: 2025.5.12
  • License observed: MIT
  • Author observed: Anthropic, PBC
  • Issue tracker declared by package: https://github.com/modelcontextprotocol/servers/issues
  • Maintainers observed from npm metadata: jspahrsummers, thedsp, ashwin-ant
  • Local dependency resolution:
@modelcontextprotocol/[email protected]
+-- @modelcontextprotocol/[email protected]
`-- [email protected]

Audit finding: old MCP SDK bundled with published package

Using a temporary lockfile for @modelcontextprotocol/[email protected], npm audit --omit=dev --audit-level=moderate reports:

@modelcontextprotocol/sdk  <=1.25.1
Severity: high
Anthropic's MCP TypeScript SDK has a ReDoS vulnerability - https://github.com/advisories/GHSA-8r9q-7v3j-jr4g
Model Context Protocol (MCP) TypeScript SDK does not enable DNS rebinding protection by default - https://github.com/advisories/GHSA-w48q-cv73-mx4w
No fix available
node_modules/@modelcontextprotocol/sdk
  @modelcontextprotocol/server-puppeteer  *
  Depends on vulnerable versions of @modelcontextprotocol/sdk

2 high severity vulnerabilities

The package currently depends on @modelcontextprotocol/[email protected], so consumers inherit these advisories.

Behavioral findings

From local inspection of dist/index.js and README behavior:

  1. Arbitrary URL schemes are accepted by page.goto(args.url). There is no explicit http/https restriction, embedded-credential rejection, host allowlist/denylist, or private-network blocking.

  2. Redirect/subresource requests are not guarded. A public page can load or redirect to local/private targets unless request interception or equivalent policy is applied.

  3. Caller-supplied launchOptions are powerful. The server has a dangerous-args list, but callers can still influence browser launch behavior. Safer defaults should be stricter for autonomous agent environments.

  4. NPX default opens a visible non-headless browser. This may be surprising for unattended MCP sessions.

  5. Screenshots and console logs are stored in memory without obvious caps. A long-running server can accumulate unbounded screenshots/log entries.

  6. puppeteer_fill echoes filled values. If an agent fills a password/token field, echoing the value back increases the risk of credential retention in chat/session logs.

  7. puppeteer_evaluate lacks explicit script/result caps and redaction. Evaluation is useful, but bounded input, bounded output, timeout, and redaction make it safer.

Local hardening behavior that worked well

For our local wrapper, we preserved the upstream 7 tool names exactly:

puppeteer_navigate
puppeteer_screenshot
puppeteer_click
puppeteer_fill
puppeteer_select
puppeteer_hover
puppeteer_evaluate

We added:

  • @modelcontextprotocol/[email protected] locally instead of the package's bundled SDK 1.0.1
  • default headless=true
  • isolated profile under a user data directory, with refusal to use node_modules
  • top-level http/https only by default
  • optional explicit LCV_PUPPETEER_ALLOW_FILE_URLS=1 override
  • embedded-credential rejection
  • DNS/private/reserved/loopback/link-local address blocking
  • request interception so subresources also pass through the URL/IP guard
  • optional allowlist/denylist host controls
  • restricted launch options by default, with an explicit unsafe escape hatch
  • screenshot dimensions and screenshot count caps
  • selector/value/script/result caps
  • console log ring buffer
  • secret redaction
  • no echo of filled values

Validation from local wrapper

7-tool parity:

514:server.registerTool("puppeteer_navigate", {
536:server.registerTool("puppeteer_screenshot", {
572:server.registerTool("puppeteer_click", {
584:server.registerTool("puppeteer_fill", {
601:server.registerTool("puppeteer_select", {
614:server.registerTool("puppeteer_hover", {
626:server.registerTool("puppeteer_evaluate", {

Smoke output:

puppeteer tools: puppeteer_click,puppeteer_evaluate,puppeteer_fill,puppeteer_hover,puppeteer_navigate,puppeteer_screenshot,puppeteer_select
puppeteer file block: Blocked unsupported URL scheme: file:
puppeteer loopback block: Blocked private or reserved IP address: 127.0.0.1
puppeteer example.com final=https://example.com/ title=Example Domain
puppeteer evaluate: Execution result:
puppeteer screenshot: Screenshot 'smoke' taken at 640x480
lcv-hardened-puppeteer 1.0.0 running on stdio; headless=true; block_private=true

Local dependency audit after using newer SDK and overriding ip-address:

$ npm ls ip-address express-rate-limit @modelcontextprotocol/sdk
lcv-workspace@ C:\Users\leona\lcv-workspace
`-- @modelcontextprotocol/[email protected]
  `-- [email protected]
    `-- [email protected] overridden

$ npm audit --audit-level=moderate
found 0 vulnerabilities

Suggested upstream changes

  • Update @modelcontextprotocol/sdk dependency to a non-vulnerable current release.
  • Add default URL policy: http/https only, reject embedded credentials, optional allowlist/denylist.
  • Add DNS/private/reserved address blocking, including redirects and subresource requests.
  • Add request interception to apply policy to all browser network requests.
  • Default to headless mode for stdio agent usage, or document the non-headless default more prominently.
  • Restrict launchOptions to a safe subset by default. Keep an explicit ALLOW_DANGEROUS/unsafe override for users who need it.
  • Add caps for screenshots, console logs, selectors, fill values, evaluate scripts, and evaluate result size.
  • Do not echo filled values back to the model; return selector and character count instead.
  • Redact common secret patterns in console/evaluate output.
  • Add smoke tests for: scheme block, loopback/private IP block, tool list parity, screenshot cap, and launchOption rejection.

Compatibility note

These changes can preserve the current 7 tool names and schemas. The main compatibility risk is users who intentionally depend on local/private-network navigation or custom launch args. Those use cases can be preserved behind explicit environment flags.

lcv-leo avatar May 06 '26 09:05 lcv-leo

The findings here are solid. One framing distinction worth drawing out: the guardrails you're proposing (URL allowlists, JS execution controls, private-network blocking) belong to two different layers with different ownership.

Server-side defaults (what this issue is asking for): useful for anyone running the reference server, but maintainers have to ship and operators have to update.

Consumer-side enforcement: a tool allowlist or approval gate applied before any tool call reaches the Puppeteer server, regardless of what version is installed. That layer catches configuration drift, third-party servers you didn't harden, and cases where the server itself is compromised.

For the SDK version finding specifically, that's a straightforward upstream fix and worth a separate PR. For the behavioural guardrails, I'd argue the strongest path is both: safer defaults upstream AND enforcement at the consumer layer for anything you don't own. If your team is running multiple MCP servers you didn't build, that second layer is what PolicyLayer handles - tool-call allowlists, rate limits, and approval gates across the whole fleet.

policylayer-dan avatar May 06 '26 11:05 policylayer-dan

Thanks for the framing. I agree that there are two layers here and they should not be conflated.

This issue is intentionally scoped to the reference Puppeteer server defaults: update the MCP SDK and add safer browser-automation guardrails where the server can enforce them directly. Consumer-side tool-call policy, approval gates, and fleet-wide allowlists are valuable defense in depth, especially for third-party servers or configuration drift, but I would treat them as complementary rather than a substitute for safer upstream defaults.

The SDK update is the most straightforward upstream fix. The behavioral guardrails are still worth pursuing as server defaults so baseline installs are less risky before any external policy layer is added.

lcv-leo avatar May 07 '26 17:05 lcv-leo

test via sendkeysOne operational default that helped us a lot: emit a structured audit event for every navigate/evaluate/fill/screenshot call with URL, final resolved host, and whether a policy check or redaction fired. The allow/deny layer matters, but the audit trail is what made it possible to debug weird agent behavior without replaying the entire session. Especially for browser tools, I think safer defaults plus a compact per-tool audit log would go a long way.

eddyaipt avatar May 09 '26 11:05 eddyaipt

One operational guardrail that helps a lot in agent setups is forcing deterministic verification before any browser action is treated as success. Restricting navigation schemes matters, but the other big win is returning compact typed verification signals instead of raw page dumps so the agent stays inside a narrow feedback loop.

eddyaipt avatar May 12 '26 13:05 eddyaipt

Default browser-automation guardrails seem like the right default here. For teams attaching MCP tooling to a real browser, the biggest practical win is starting from an explicit policy surface instead of discovering after the fact that a workflow had broader permissions than expected.

eddyaipt avatar May 12 '26 14:05 eddyaipt

One upstream-friendly addition would be a small audit artifact after each navigation: final URL, redirect chain, top-level origin, and any blocked private-network/subresource requests. That makes agent-side verification easier when a run 'succeeds' but policy enforcement silently changed what actually loaded.

eddyaipt avatar May 13 '26 13:05 eddyaipt

One operational boundary that seems worth making first-class is an allowlist + review surface for navigation targets and network reachability. In practice the risky path is not only page scripting, but silent access to localhost, metadata endpoints, or internal-only web apps through a browser tool that otherwise looks harmless.

eddyaipt avatar May 13 '26 14:05 eddyaipt

A small audit artifact per transition would make this even easier to operate in production. When the agent hits a guardrail, having a compact machine-readable record of state, action, and failure reason helps teams debug without replaying the whole run.

eddyaipt avatar May 15 '26 13:05 eddyaipt

Thanks @eddyaipt, I agree that a compact audit artifact would be a good upstream-friendly addition here.

For the Puppeteer server specifically, I think each browser action result could expose a bounded structured record rather than a raw trace dump. Useful fields would be:

  • action kind (navigate, evaluate, fill, screenshot, etc.);
  • requested URL and final URL, where applicable;
  • redirect chain and final top-level origin;
  • policy decision and reason;
  • blocked private-network/subresource attempts, if any;
  • redaction status for page text, screenshot, or extracted content.

That shape would let agent hosts verify what actually happened without replaying the browser session, and it would make guardrail tests stronger: the test can assert both the user-visible tool result and the audit event emitted for the same action.

lcv-leo avatar Jun 04 '26 21:06 lcv-leo

@lcv-leo @eddyaipt @policylayer-dan

If you are looking for an alternative to the Puppeteer MCP that avoids bot detection entirely, we built a stealth MCP server using nodriver (CDP-based). It automatically strips 30+ detectable Chrome flags that Puppeteer leaves behind and passes Cloudflare Turnstile:

https://github.com/user-attachments/assets/c4de61ae-6878-4fff-9bfd-65cdd4fadc2f

Demo on YouTube

pip install stealth-chrome-devtools-mcp

https://github.com/DevinoSolutions/stealth-chrome-devtools-mcp

AminDhouib avatar Jun 24 '26 01:06 AminDhouib

Thanks for the report! This server is no longer maintained in this repo. It was moved to servers-archived, which is read-only, so there is no place for this change to land. If you need the behavior, a fork published to the MCP Registry is the way to go.

Closing this issue.

olaservo avatar Sep 29 '26 03:09 olaservo