Skip to content

fix(browser): check fs access in builtin commands [backport to v3]#10679

Merged
hi-ogawa merged 4 commits into
vitest-dev:v3from
hi-ogawa:fix/browser-command-write-gate-v3
Jul 1, 2026
Merged

fix(browser): check fs access in builtin commands [backport to v3]#10679
hi-ogawa merged 4 commits into
vitest-dev:v3from
hi-ogawa:fix/browser-command-write-gate-v3

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Description

The fix is only ported for upload, screenshot, onTaskAnnotate since other surfaces didn't exist in v3.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

…cess [backport to v3]

Manual backport of the browser command permission gate. v3 only exposes
the vulnerable `screenshot` (write) and `upload` (read) commands, so gate
those via shared `assertBrowserApiWrite`/`assertBrowserFileAccess` helpers
(using v3's `isFileServingAllowed`). Tests follow the v3 `errors-fs` spec
style with stderr assertions.

Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
@netlify

netlify Bot commented Jun 30, 2026

Copy link
Copy Markdown

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4658ce6
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a44d6d0a89ed30008113021
😎 Deploy Preview https://deploy-preview-10679--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

…t to v3]

The `onTaskAnnotate` RPC recorded a client-supplied annotation attachment
path with no gate. Since attachments are copied into `attachmentsDir`, an
arbitrary path (e.g. `/etc/passwd`) could be disclosed regardless of
`allowWrite`. Add `checkFileAccess` for the attachment path and strip it
when `allowWrite` is disabled.

Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
@hi-ogawa
hi-ogawa marked this pull request as ready for review June 30, 2026 08:41
@sheremet-va

Copy link
Copy Markdown
Member

Related tests seem to be failing 🤔

…ions [backport to v3]

The screenshot command builds its save path with `node:path` normalize,
so the "Access denied"/"Cannot modify file" messages use backslashes on
Windows while the test compares against forward-slash `pathe` paths.
Normalize separators in the assertion so it passes on all platforms.

Co-authored-by: OpenCode (claude-opus-4-8) <[email protected]>
@sheremet-va

sheremet-va commented Jul 1, 2026

Copy link
Copy Markdown
Member

Could we add zizmor to v3? Or should we remove the zizmor requirement from v* branches? Cannot merge this otherwise

@hi-ogawa

hi-ogawa commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

I thought we already aligned all. I should include that in:

@hi-ogawa

hi-ogawa commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

I can merge now. Merging!

@hi-ogawa
hi-ogawa merged commit b795e36 into vitest-dev:v3 Jul 1, 2026
13 of 17 checks passed
@hi-ogawa
hi-ogawa deleted the fix/browser-command-write-gate-v3 branch July 1, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants