Security Considerations
Network Access Control
Playwright MCP provides origin filtering to control which websites the browser can access. However, these controls do not serve as a security boundary.Origin filtering does not serve as a security boundary and does not affect redirects.
Allowed Origins
Specify trusted origins the browser is allowed to request:- Full origin:
https://example.com:8080- matches only that origin - Wildcard port:
http://localhost:*- matches any port on localhost with http protocol
Blocked Origins
Specify origins to block. Blocklist is evaluated before allowlist:allowedOrigins and blockedOrigins will be blocked.
File System Access
By default, file system access is restricted to workspace root directories (or current working directory if no roots are configured). Navigation tofile:// URLs is also blocked.
Unrestricted File Access
To allow access to files outside workspace roots:file:// URLs.
Secrets Management
Secrets are used to prevent the LLM from getting sensitive data while automating scenarios such as authentication.Prefer
browser.contextOptions.storageState over secrets file as a more secure alternative.Using Secrets File
Host Validation
The server validates theHost header to prevent DNS rebinding attacks. By default, only the host the server is bound to is allowed.
Custom Allowed Hosts
'*' to disable the host check (not recommended in production).
Service Workers
Block service workers to prevent background script execution:Isolation Strategies
Docker Isolation
For stronger isolation, run Playwright MCP in a Docker container. See the Docker guide for details.Isolated Browser Contexts
Use isolated mode to ensure no persistent state between sessions:Sandbox Mode
Enable browser sandbox for additional process isolation:Best Practices
Use Docker for production deployments
Use Docker for production deployments
Run Playwright MCP in a containerized environment to limit the blast radius of potential security issues.
Restrict file system access
Restrict file system access
Only enable
--allow-unrestricted-file-access when absolutely necessary and in trusted environments.Use isolated mode for untrusted workflows
Use isolated mode for untrusted workflows
Enable
--isolated to ensure no persistent state between sessions when running untrusted automation.Implement proper secrets management
Implement proper secrets management
Use storage state files instead of passing secrets directly. Store sensitive files outside the workspace.
Configure origin filtering
Configure origin filtering
While not a security boundary, origin filtering can help prevent accidental access to unexpected resources.
Monitor and log activity
Monitor and log activity
Use
--save-session and --save-trace to maintain audit logs of browser automation activity.
