Two handlers in the same dispatch table branch on the UUID. The third uses it as a label.
The three handlers live in the same object literal at lib/server.js. _progress starts on line 369:
'_progress': function progressHandler(uri, body, request, response) {
var uuid = getWorkerUuid(request);
if (!uuid) {
sendError(response, 'worker not found', 404);
return;
}
...
_report starts on line 405:
'_report': function reportHandler(uri, body, request, response) {
var uuid = getWorkerUuid(request);
if (!uuid) {
sendError(response, 'worker not found', 404);
return;
}
...
_log starts on line 491:
'_log': function logHandler(uri, body, request, response) {
var uuid = getWorkerUuid(request);
var query = null;
try {
query = CircularJSON.parse(body);
} catch (e) {
query = body;
}
logger.trace('[%s] _log', ((uuid && workers[uuid]) || {}).id, query);
...
The variable uuid in _log is referenced exactly once after assignment. The reference is ((uuid && workers[uuid]) || {}).id, which logger.trace interpolates into the %s of the trace message. When no X-Worker-UUID header is sent, the expression evaluates to undefined, the trace prints [undefined] _log ..., and the handler continues. When a valid UUID is sent, the expression evaluates to the worker's id and the trace prints [ie11-win10] _log .... Either way, the remaining 20 lines of the handler do not read the variable again.
The legitimate caller is patched into every test page by lib/_patch/browserstack.js, which wraps console.log and console.warn to POST { arguments: args } to /_log/ with X-Worker-UUID and X-Browser-String headers set from the query string of the test page URL. The credential is provisioned end to end. The cloud browser sends it. The server captures it. The handler binds it to a variable. The variable is the log-line label. This is the shape we are calling gate-was-decoration: the auth helper is in the source, the branch on the auth helper is not, and the only consumer of the call's return value is a string interpolation in a logger.trace argument.
The Node documentation says the vm module is not a sandbox. The comment above it says safely.
The 20 lines that follow the trace are the rest of the handler:
if (query && Array.isArray(query.arguments)) {
var context = { input: query.arguments, format: util.format, output: '' };
var tryEvalOrString = 'function (arg) { try { return eval(\'o = \' + arg); } catch (e) { return arg; } }';
try {
// eval each element of query.arguments safely in an isolated context
vm.runInNewContext('output = format.apply(null, input.map(' + tryEvalOrString + '));', context);
logger.info('[' + request.headers['x-browser-string'] + '] ' + context.output);
logged = true;
} catch (e) {
logger.debug('_log: failed to format console log data', query);
}
}
Mechanically: take the JSON array query.arguments from the request body, map each element through a function that calls eval('o = ' + arg), apply util.format to the resulting array, and assign the formatted string to output. The whole expression runs inside vm.runInNewContext with a context object containing the user input, the util.format function from Node's standard library, and an output slot for the result.
The comment on the line above vm.runInNewContext describes what the code is meant to do: eval each element of query.arguments safely in an isolated context. The word safely is the developer's belief about the construct they were writing. The Node.js documentation for vm is direct about that construct:
The vm module is not a security mechanism. Do not use it to run untrusted code.
The sentence sits at the top of every page of the vm module documentation. It is there because of the second mechanic of the vm context: any non-primitive value bound into the context, a Function, an Array, an Object created in the host realm, carries a reference back to its constructor, which carries a reference to the Function constructor in the host realm, which lets sandboxed code construct a function that runs in the host realm. The escape primitive is this.constructor.constructor('return process')(). The _log handler binds util.format into the context object as the format field. That binding alone is sufficient.
The advisory's PoC reads:
curl -s http://127.0.0.1:8888/_log \
-H "Content-Type: application/json" \
-d '{"arguments":["this.constructor.constructor(\"return process.mainModule.require(`child_process`).execSync(`id`).toString()\")()"]}'
The runner's terminal prints [undefined] uid=1000(user) gid=1000(user) .... The [undefined] is the worker id label, the consequence of uuid being null because the curl did not send the header. The variable did exactly what its only call site asked of it.
The safely comment shipped in February 2016. The CVE shipped in June 2026.
git log -L 491,523:lib/server.js traces the handler's history through the commits that touched those lines.
| Commit |
Date |
What the commit did to _log |
9888613 |
2015-10-23 |
Handler born. Five lines. Logs the request body. No getWorkerUuid call. No eval. No vm. |
4ab2993 |
2016-01-23 |
var uuid = getWorkerUuid(request); added. Same commit added the same line to _progress and _report, both of which gated on it. _log did not. |
1cb8deb |
2016-02-08 |
vm.runInNewContext call lands with the safely comment above it. Author wanted console.log of objects in the cloud browser to render as {foo: 1} in the runner's terminal instead of as the literal string [object Object]. The mechanism they reached for was eval wrapped in vm. |
ad86ae8 |
2016-02-08 |
tryEvalOrString refactored from a JS function (serialized via .toString()) to a literal source-string. The change makes the sandbox source more stable across Node versions; it does not touch the auth call. |
e21a4b1 |
2017-01-27 |
JSON parse error catches and falls back to query = body. The author touches the handler a third time. The uuid call is still on the first line. It is still not read. |
1e85e55 |
2021-04-21 |
Version 0.9.5 published to npm. Handler ships unchanged. |
5ee5ad0 |
2023-07-03 |
Repository's most recent commit. It is a CODEOWNERS file. No code touched. |
CVE-2026-49143 |
2026-06-04 |
GitHub Advisory Database lists "Patched versions: None." |
Ten years and four months separate the author's belief that vm is a sandbox from the advisory that says it is not.
The advisory's remediation list is addressed to a project with no maintainer.
The advisory's three-item remediation reads:
- Remove
eval() and vm.runInNewContext() from the _log handler, use JSON.stringify() for safe logging.
- Add UUID authentication to
_log (matching _progress and _report handlers).
- Bind the HTTP server on
127.0.0.1 instead of 0.0.0.0.
Item 1 is the actual fix. Item 2 is the four-line check the two sibling handlers already have. Item 3 is the host argument that was never passed to server.listen:
// bin/cli.js, line 131
server.listen(parseInt(config.test_server_port, 10));
Node's http.Server#listen documentation: "If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise." The author wrote one argument. Node filled in the other.
All three items are fixes a maintainer would write in an afternoon. The browserstack/browserstack-runner repository's last commit landed on July 3, 2023. The last npm publish was 0.9.5 on April 21, 2021. The advisory was filed in June 2026. The Patched versions field reads None. The npm registry still serves the same tarball, and every developer who runs npm install browserstack-runner receives the code the author shipped in February 2016.
This is the same shape that has made browserstack-runner an exhibit on The Detector Is The Target: the QA engineer's instrument becomes the attacker's foothold on the QA engineer's workstation, the way Apktool's path-decoder bug becomes the malware-analyst's foothold on the malware-analyst's. The blast radius is one developer laptop at a time. The prerequisite is one packet on the same LAN.
The threat model was "BrowserStack will call this." The implementation was "everyone on the LAN will call this."
browserstack-runner exists because BrowserStack's cloud browsers, running in BrowserStack's data center, need to fetch the test HTML and JS that live on the developer's local filesystem. The product solves this with a local HTTP server (the runner, on port 8888) and a tunnel binary (BrowserStackLocal) that BrowserStack runs to forward requests from the cloud browser back to the dev's localhost:8888. The architecture's expected caller of localhost:8888 is the tunnel, which is a localhost-only process on the dev's machine.
That is the threat model the _log handler was written under. The caller is a cloud browser. The cloud browser is on BrowserStack's side of the tunnel. The cloud browser is calling because the test it is running just executed console.log({foo: 1}) and wants the runner to print that in the dev's terminal. Inside that threat model, vm.runInNewContext of attacker-controlled JavaScript is still wrong, but it is wrong against an attacker who already controls the cloud browser, which is a population of one: BrowserStack.
server.listen(8888) with no host argument is not the implementation of that threat model. It is the implementation of "any TCP client on any interface that can reach port 8888." On a developer's machine joined to a co-working space wireless network, that population includes every other person at the co-working space. On a CI runner sharing a Kubernetes node with other tenants, it includes every other pod on the node. On a hotel conference Wi-Fi the morning before a release, it includes every device in the conference. The CVSS vector reads AV:A, adjacent network, which is the polite phrasing of "anyone the developer is sharing a broadcast domain with."
What the attacker collects on a successful curl: the BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables (lib/config.js reads them at startup and they live in process.env for the life of the node process), the contents of the working directory, any AWS or GCP credentials the developer happened to have exported, the dev's SSH agent socket if it is forwarded, and whatever the dev's shell history says about what else they were doing this morning. The _log handler was written to print formatted console output. The same handler returns shell output formatted by util.format.
PoC: GHSA-6vr3-7wcx-v5g5
The advisory shipped its remediation list in June 2026. The repository shipped its last commit in July 2023.