BrowserOS icon indicating copy to clipboard operation
BrowserOS copied to clipboard

Local MCP endpoint: no credential required, and upload tool reads arbitrary local files

Open WindriseAI opened this issue 3 weeks ago • 0 comments

Two related issues in the local MCP surface. They compound each other, so filing them together.

1. Loopback MCP endpoint serves the full tool surface without any credential

Summary

The local MCP endpoint (/mcp on the claw-server loopback port) lets any client initialize and use every tool — navigation, input, file upload, evaluate — without any token or credential. The only ingress filter is mcp_request_hygiene in packages/browseros-agent/apps/claw-server/src/api/http/mod.rs, which rejects browser-page requests (Origin / Sec-Fetch-Site headers) and enforces JSON content types, but never checks authentication. The header allow-list even passes authorization through untouched.

The TS sidecar has a lease-token mechanism, but it is optional (main @ 1d3c3dfa): apps/server/src/api/routes/mcp.ts:107 only validates when a token is present (if (leaseToken) { ... }), and apps/server/src/api/services/mcp/browser-mcp-module.ts:134-143 builds the server with no lease and therefore the full BROWSER_TOOLS set (read-only only when the caller asks for it via ?read_only=1).

Impact

  • Any local process (or anything that can reach the port) gets full control of the browser session with no user prompt: read page content, drive input, upload local files (see the separate upload report), evaluate JS.
  • Combined with the wildcard bind on the server proxy (#2424 / #3156), the exposure extends to the LAN: any device on the network can drive the browser. Even with the loopback fix, local malware/other users' processes remain in scope.

Suggested fix

  • Require a credential by default on the MCP endpoint (reuse the existing lease-token design: server mints it, trusted local clients read it from a per-install file with restrictive ACLs).
  • Keep an explicit opt-in for tokenless local access, and document the threat model (Host/Origin checks block web pages only).

2. MCP upload tool accepts arbitrary local file paths without a workspace allowlist or user consent (local file exfiltration via prompt injection)

Summary

The MCP upload tool (both the TS and Rust implementations) accepts an absolute local file path and hands it to DOM.setFileInputFiles with no check that the file is inside a user-approved workspace. A page that can influence the agent (e.g. through prompt injection in page content) can instruct it to upload a sensitive local file — SSH keys, browser profile data, tokens — to a remote form, and the user only sees a normal "upload" step.

Affected code

  • packages/browseros-agent/packages/browser-mcp/src/tools/upload.ts — passes file/files straight to ctx.session.input(...).uploadFile(...).
  • packages/browseros-agent/crates/browseros-mcp/src/tools/upload.rs — same via browser.files().upload(...).
  • packages/browseros-agent/crates/browseros-core/src/file_transfers/mod.rs — validates only fs::metadata(path).is_file() (exists + regular file). No allowlist, no real-path containment check, no symlink/.. resolution against an approved root.

The tool description even documents the behavior: "files must exist on the server/browser filesystem".

Reproduction

  1. Open a page with a file input (https://the-internet.herokuapp.com/upload).
  2. Call upload with an absolute path outside any workspace, e.g. the user's SSH private key or a file under the browser profile directory.
  3. The tool reports success and the page receives the file contents on submit.

Impact

  • Arbitrary local file read → exfiltration to any website, triggered by page content (prompt injection), with no user visibility of the path.
  • Compounded by the wildcard-bind issue (#2424 / #3156) and the unauthenticated loopback MCP endpoint (separate report): a remote attacker who can reach the MCP port can drive the same flow.

Suggested fix

  • Restrict uploads to an explicit workspace-root allowlist (same roots the filesystem tools use); resolve realpath before dispatch and reject symlink/.. escapes, directories, and special files.
  • Require explicit per-file user confirmation for anything outside the roots; log path + size (never contents) in the audit trail.
  • After setFileInputFiles, read back input.files[0].size and fail on 0 bytes instead of reporting success.

Also reported privately earlier as GHSA-9q5g-wxjv-f233; filing publicly so the fix can be tracked in the open.

WindriseAI avatar Nov 07 '26 16:11 WindriseAI