←新闻详情

邵猛更新于 11月4日 11:32

Playwright 官方澄清浏览器安全:MCP 与 CLI 用正式版 Chrome,测试运行器固定版本且默认关沙箱

别急着删 Playwright:官方讲清楚它和浏览器安全到底是什么关系

AI 导读

Playwright 官方澄清,Playwright 的任何安装包都不带浏览器,因此不必因为漏洞传闻删掉它。用 Playwright MCP 或 CLI 的 Agent 调用的是本机正式版 Chrome 或 Edge,会正常收到安全更新且沙箱默认开启;而 npx playwright install 下载的 Chrome for Testing 版本固定、默认关闭沙箱,只适合对可信应用做端到端测试。直接调用 chromium.launch() 时默认同样是固定版本加沙箱关闭,若代码会访问不受控页面,应改用 chromium.launch({ channel: 'chrome', chromiumSandbox: true }),并保持 Chrome 和 Edge 更新。

推荐理由

AI 评分 51

原文澄清了 Playwright 各使用方式与浏览器安全的关系,并给出爬虫和 Agent 脚本应如何配置沙箱。

主题

标签

引用

Playwright

@playwrightweb

Playwright 与浏览器安全提醒。 我们看到有帖子建议你删除 Playwright,因为它捆绑了带有 CVE 的浏览器。这是一种误解。不要删除 Playwright🙃。下面说明它的工作原理以及你应该怎么做。 没有任何 Playwright 包会捆绑浏览器。Playwright MCP 或 CLI 上的 Agent 运行的是你本机的稳定版 Chrome,它会获得 Chrome 的安全更新,并且沙箱处于开启状态。 🤖 如果你使用 Playwright MCP 或 Playwright CLI 它们使用你机器上的稳定版 Chrome / Edge,因此会获得正常的更新。无需修改配置。 🧪 如果你使用测试运行器 当你运行 npx playwright install 时,Playwright 会下载 Chrome for Testing,并固定到我们测试该版本时所针对的构建版本。这种固定是有意为之。你的测试在每台笔记本电脑和 CI 机器上都运行在同一个浏览器上,浏览器更新不会突然破坏你的测试套件。你可以通过升级 Playwright 来决定何时迁移。新版本通常会固定到比稳定版 Chrome 更超前的构建版本,因此你能在用户之前发现破坏性问题。 我们建议在你自己可信的应用上运行完整的 e2e 测试套件时使用这种方式。该构建版本可能会错过 Chrome 的安全修复,直到下一个 Playwright 版本发布,并且默认情况下它在关闭沙箱的状态下运行。不要在充满敌意的网络上使用它。 📚 如果你使用库 API chromium.launch() 具有相同的默认设置:固定构建版本并关闭沙箱。如果你的代码会访问你无法控制的页面(爬虫、Agent 脚本),请将防护开到最大: chromium.launch({ channel: 'chrome', chromiumSandbox: true }) 🔒 始终让 Chrome / Edge 保持更新。有些漏洞可以逃逸沙箱。 测试愉快!

查看原文

Playwright and browser security reminder. We saw a post suggesting that you delete Playwright because it bundles browsers with CVEs. That is a misconception. Do not delete Playwright🙃. Here is how it works and what you should do. No Playwright package bundles a browser. Agents on Playwright MCP or CLI run your stable Chrome, which gets Chrome's security updates, with the sandbox on. 🤖 If you use Playwright MCP or the Playwright CLI They use the stable Chrome / Edge on your machine, so it gets its normal updates. No config edit is needed. 🧪 If you use the test runner When you run npx playwright install, Playwright downloads Chrome for Testing, pinned to the build we tested that release against. The pin is on purpose. Your tests run on the same browser on every laptop and CI machine, and a browser update cannot suddenly break your suite. You choose when to move by upgrading Playwright. New releases usually pin a build ahead of stable Chrome, so you see breakage before your users do. We recommend this for full e2e test suites on your own trusted app. This build can miss Chrome security fixes until the next Playwright release, and by default it runs with the sandbox off. Do not use it on the hostile web. 📚 If you use the library API chromium.launch() has the same defaults: the pinned build with the sandbox off. If your code visits pages you don't control (scrapers, agent scripts), max out protection: chromium.launch({ channel: 'chrome', chromiumSandbox: true }) 🔒 Always keep Chrome / Edge updated. Some bugs can escape a sandbox. Happy testing!

查看原帖

正文

别急着删 Playwright:官方讲清楚它和浏览器安全到底是什么关系

有人说 Playwright 自带有漏洞的浏览器,所以应该删掉。这是误解,因为 Playwright 的任何安装包里都不带浏览器。真正需要注意的只有一种情况:测试用的固定版本浏览器不适合拿去访问不可信的网页。

用 Playwright MCP 或命令行工具的 Agent

这两种方式调用的是你电脑上的正式版 Chrome 或 Edge。浏览器会正常收到安全更新,沙箱也默认开着,所以不用改任何配置。

用测试运行器跑测试

运行 npx playwright install 时,Playwright 会下载 Chrome for Testing。这是测试专用的浏览器,版本固定为当前这一版 Playwright 测试过的那个版本。

这样做是故意的:每台开发电脑和每台 CI 机器跑的都是同一个浏览器,浏览器不会因为自动更新突然把测试搞挂。什么时候换浏览器版本,由你升级 Playwright 来决定。新版 Playwright 通常会固定一个比正式版 Chrome 更新的版本,所以兼容问题会在用户遇到之前先被你发现。

代价是,在下一版 Playwright 发布之前,这个浏览器可能缺少 Chrome 最新的安全修复,而且默认关闭沙箱。官方建议只用它对你自己可信的应用做端到端测试,不要用它访问来路不明的网站。

直接调用库 API

chromium.launch() 的默认设置和测试运行器一样:用固定版本的浏览器,沙箱关闭。如果你的代码会访问不受你控制的页面,比如爬虫或 Agent 脚本,就应该换成正式版 Chrome,并打开沙箱:

chromium.launch({ channel: 'chrome', chromiumSandbox: true })

另外,有些漏洞能突破沙箱,所以 Chrome 和 Edge 一定要保持更新。

来源

邵猛