llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · @appium/base-driver

GHSA-4356-HM4H-WW9C

CORS allowlist bypass in @appium/base-driver

Parche disponible
Descargar PNG JSON
CVSS 3.1
8.3
Alta
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:L Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche a -23 d de la divulgación
Exposición66 dDesde la divulgación, 16 sept 2026, 9:12 a. m.
Detección63 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir de cerca
Monitorear y programar la remediación
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico total. Hay versiones corregidas disponibles.
Ponle una regla en tu SIEM y seguimos.Medio riesgo, cero excusas.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 10.8.0
Monitoreo
Detectada +1
24 ago 26
16 sept 26
18 nov 26
21 nov 26
24 ago 26
15 sept 26
8 oct 26
30 oct 26
21 nov 26
FechaFaseEventoDetalle
Remediación Parche 10.8.0 @appium/base-driver · -23 d desde divulgación
Divulgación Publicada GHSA-4356-HM4H-WW9C divulgada · CVSS 8.3 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

## Summary
Appium's HTTP server exposes an unauthenticated WebDriver API and relies on the browser Same-Origin Policy plus the `--allow-cors` switch (default `false`) to prevent malicious web pages from driving a locally running Appium server. When `--allow-cors` is disabled, `packages/base-driver/lib/express/server.ts` installs the `allowCrossDomainAsyncExecute(basePath)` middleware, which is intended to grant permissive CORS headers only to the `receive_async_response` endpoint.

The middleware in `packages/base-driver/lib/express/middleware.ts:44-57` builds a regular expression that is not anchored with `^`, and tests it against `req.url`, which in Express still contains the raw query string. Because `RegExp.prototype.test()` performs a substring search, an attacker-controlled web page can append a harmless-looking query parameter such as `?_=/session/aaaaaaaa/receive_async_response` to ANY Appium endpoint and force the server to emit `Access-Control-Allow-Origin: *`. This defeats the `--allow-cors` security control in its default hardened state, letting any website cross-origin read every WebDriver API response from a local or intranet-reachable Appium server, including session creation results, capabilities, page source, and screenshots.

## Details
Root cause

Two defects combine in `allowCrossDomainAsyncExecute` (`packages/base-driver/lib/express/middleware.ts:44-57`):

  1. Missing anchors. The pattern `${util.escapeRegExp(basePath)}/session/[a-f0-9-]+/(appium/)?receive_async_response` has no `^` start anchor and no end anchor. `RegExp.prototype.test()` therefore succeeds if the pattern appears anywhere inside the tested string, not just at its beginning.
  2. Testing `req.url` instead of `req.path`. In Express, `req.url` retains the full original request target including the query string, whereas `req.path` is the query-stripped pathname. By testing `req.url`, attacker-controlled query data is treated as if it were part of the routed path.

Trust boundary failure

The middleware is the trust boundary that decides whether a cross-origin browser is allowed to read an Appium response. Because the decision input (`req.url`) contains a fully attacker-controlled segment (the query string) and the matcher is unanchored, the allowlist collapses: the attacker, not the server, decides which endpoints are CORS-enabled.

Entry point to dangerous operation chain

  1. `packages/appium/lib/bootstrap/main-helpers.ts:176` forwards `parsedArgs.allowCors` into `ServerOpts`. The schema default is `false` (`packages/schema/lib/appium-config-schema.ts:41-46`), so a stock server is in the "CORS disabled" state.
  2. `packages/base-driver/lib/express/server.ts:208-212` selects the `else` branch and registers `allowCrossDomainAsyncExecute(basePath)`. Critically, this happens BEFORE `addRoutes(app, {basePath, extraMethodMap})` at `server.ts:225`, so the middleware runs for every Appium route.
  3. `packages/base-driver/lib/constants.ts` defines `DEFAULT_BASE_PATH = ''`. With an empty `basePath`, `util.escapeRegExp('')` yields an empty string and the pattern degenerates to `/session/[a-f0-9-]+/(appium/)?receive_async_response`, matchable after any path prefix — widening the false-positive surface further.
  4. `middleware.ts:49` runs `receiveAsyncResponseRegExp.test(req.url)`. A request to `/session?_=/session/aaaaaaaa/receive_async_response` matches because of the substring in the query string.
  5. `middleware.ts:53` calls `allowCrossDomain()`, which at `middleware.ts:22-34` unconditionally writes `Access-Control-Allow-Origin: *`, `Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE`, and `Access-Control-Allow-Headers`, and short-circuits `OPTIONS` preflights with `res.sendStatus(200)`.
  6. `next()` then hands the request to the normal WebDriver route handlers (for example `POST /session`, defined at `packages/base-driver/lib/protocol/routes/w3c.ts:9-15`). The response body is returned to the attacker's page with wildcard CORS headers attached, so the cross-origin script can read it in full.

Missing validation

There is no `Origin` allowlist, no CSRF token, no authentication middleware, and no `Host` header validation anywhere in `packages/base-driver` or `packages/appium`, so there is no secondary defence once this middleware misfires. The project's own warning text at `packages/appium/lib/bootstrap/appium-main-runner.ts:107-114` ("Be careful not to visit sites which could maliciously try to start Appium sessions on your machine") confirms that the browser-origin threat model is exactly what `--allow-cors` is meant to defend against.

Verification performed

The regex semantics were reproduced independently (JS `RegExp.test` and Python `re.search` are equivalent for this unanchored pattern). Results with the default empty `basePath`: `/session` does not match (expected), while `/session?_=/session/aaaaaaaa/receive_async_response`, `/session/DEADBEEF/url?x=/session/a/receive_async_response`, and `/appium/storage/reset?p=/session/0/receive_async_response` all match, confirming that a query string alone is sufficient to trigger CORS on arbitrary endpoints.

Core vulnerable code path:

// packages/base-driver/lib/express/middleware.ts:44-57
export function allowCrossDomainAsyncExecute(basePath: string): RequestHandler {
  function allowCrossDomainAsyncExecuteHandler(req: Request, res: Response, next: NextFunction): void {
    const receiveAsyncResponseRegExp = new RegExp(
      `${util.escapeRegExp(basePath)}/session/[a-f0-9-]+/(appium/)?receive_async_response`,
    );
    if (!receiveAsyncResponseRegExp.test(req.url)) {
      next();
      return;
    }
    allowCrossDomain(req, res, next);
  }

  return allowCrossDomainAsyncExecuteHandler;
}

The core defect. The regular expression lacks a `^` start anchor and any end anchor, and it is tested against `req.url`, which in Express includes the raw attacker-controlled query string. Because `RegExp.prototype.test()` is a substring search, appending `?_=/session/aaaaaaaa/receive_async_response` to any endpoint makes this allowlist check pass and delegates to the permissive CORS handler. With the default empty `basePath`, `util.escapeRegExp('')` produces an empty prefix, so the pattern can also match after an arbitrary path prefix.

// packages/base-driver/lib/express/middleware.ts:22-35
export function allowCrossDomain(req: Request, res: Response, next: NextFunction): void {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, OPTIONS, DELETE');
  res.header(
    'Access-Control-Allow-Headers',
    'Cache-Control, Pragma, Origin, X-Requested-With, Content-Type, Accept, User-Agent',
  );

  if (req.method === 'OPTIONS') {
    res.sendStatus(200);
    return;
  }
  next();
}

The dangerous sink. It writes a wildcard `Access-Control-Allow-Origin: *` with no Origin allowlist and answers `OPTIONS` preflights with 200. Once the flawed matcher above routes an arbitrary request here, the browser Same-Origin Policy no longer prevents the attacker's page from reading the Appium response body.

// packages/base-driver/lib/express/server.ts:205-226
if (useLegacyUpgradeHandler) {
    app.use(handleUpgrade(webSocketsMapping));
  }
  if (allowCors) {
    app.use(allowCrossDomain);
  } else {
    app.use(allowCrossDomainAsyncExecute(basePath));
  }
  app.use(handleIdempotency);
  app.use(defaultToJSONContentType);
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(methodOverride());
  app.use(catchAllHandler);

  // make sure appium never fails because of a file size upload limit
  app.use(bodyParser.json({limit: '1gb'}));

  // set up start logging (which depends on bodyParser doing its thing)
  app.use(startLogFormatter);

  addRoutes(app, {basePath, extraMethodMap});

Shows that the vulnerable middleware is installed exactly in the hardened default path (`allowCors === false`) and is registered globally before `addRoutes()` at line 225. Therefore the flawed matcher is evaluated for every Appium HTTP route, not only for the async-response endpoint it was meant to cover.

// packages/schema/lib/appium-config-schema.ts:41-46
'allow-cors': {
          description: 'Whether the Appium server should allow web browser connections from any host',
          title: 'allow-cors config',
          type: 'boolean',
          default: false,
        },

Confirms `--allow-cors` is an explicit security control that defaults to `false`. This proves the vulnerability affects stock/default deployments and constitutes a bypass of a documented protection rather than an intentionally permissive configuration.

## POC
Preconditions

  • An Appium server started with default arguments, i.e. `--allow-cors` is NOT set (`allowCors === false`).
  • The server is reachable from the victim's browser (default `http://127.0.0.1:4723`; typical on developer workstations and CI nodes).
  • The victim visits an attacker-controlled web page in a browser on that machine.
  • At least one driver is installed so `POST /session` returns a meaningful body. Even without a driver, the error response is still cross-origin readable, which by itself demonstrates the security-control bypass and information disclosure.

Step 1 — Start the server in its hardened default state

Run `appium --port 4723`. Confirm the startup log does NOT contain "You have enabled CORS requests from any host" (emitted by `warnIfCorsEnabled` at `packages/appium/lib/bootstrap/appium-main-runner.ts:107-114`). Absence of this warning proves CORS is disabled.

Step 2 — Baseline: confirm CORS is genuinely off

Send an `OPTIONS` preflight to endpoint `/session` on `http://127.0.0.1:4723` with request headers `Origin: https://evil.example` and `Access-Control-Request-Method: POST`.

Expected result: the response contains NO `Access-Control-Allow-Origin` header — the control is working as designed.

Step 3 — Trigger the bypass

Repeat the same `OPTIONS` preflight, but target the endpoint `/session` with the appended query parameter `_` whose value is the string `/session/aaaaaaaa/receive_async_response`. Same headers as Step 2.

Expected result: `HTTP/1.1 200 OK` with `Access-Control-Allow-Origin: *` and `Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE`. The preflight is now allowed, proving the allowlist was bypassed purely via the query string.

Step 4 — Confirm the actual response is cross-origin readable

Send `POST` to the same `/session` endpoint carrying the identical `_` query parameter, with headers `Origin: https://evil.example` and `Content-Type: application/json`. The JSON body is a standard W3C new-session payload containing a `capabilities` object with an `alwaysMatch` object specifying `platformName` and `appium:automationName`.

Expected result: the response carries `Access-Control-Allow-Origin: *` and the body is the full W3C createSession JSON. On success it includes `value.sessionId`; on failure it includes the full error detail. Both outcomes are readable by the attacker's page.

Step 5 — End-to-end browser PoC

Host a page on `https://evil.example` whose script issues a cross-origin `fetch()` to `http://127.0.0.1:4723/session` with the same `_` query-parameter suffix, method `POST`, header `Content-Type: application/json`, and the same W3C capabilities JSON body. The script reads the response text and exfiltrates it (for example via `navigator.sendBeacon` to an attacker collector endpoint).

Expected result: the browser console prints the complete Appium response JSON including `sessionId`, with no CORS error, and the attacker's collector receives the leaked data. With the obtained `sessionId`, the same query-parameter suffix can be reused against `/session/{sessionId}/screenshot`, `/session/{sessionId}/source`, and any other WebDriver endpoint to continue cross-origin reads and to issue device-control commands.

## Impact
Appium performs no authentication by default; its security model depends on the browser Same-Origin Policy and on `--allow-cors` to block browser-originated cross-site attacks. This vulnerability defeats that defence in the default hardened configuration.

  • Confidentiality (High). An attacker page can cross-origin read every WebDriver endpoint response: `sessionId`, full `capabilities` (which frequently contain device serial numbers, application paths, and cloud-service credentials), page source via `GET /session/{id}/source`, screenshots via `GET /session/{id}/screenshot`, and device logs.
  • Integrity (High). With a leaked `sessionId`, the attacker can issue arbitrary WebDriver commands cross-origin and remotely drive the connected physical device or emulator — taps, text input, application installation, activity launching.
  • Availability (Low). `DELETE /session/{id}` can terminate running test sessions, and repeated `POST /session` calls can exhaust device resources.

Developer workstations and CI nodes running long-lived Appium servers alongside a browser are the primary exposure scenario.

## Remediation
1. Anchor the pattern. Use a start anchor and constrain the end, for example `^${util.escapeRegExp(basePath)}/session/[a-f0-9-]+/(appium/)?receive_async_response/?$`, so only the intended endpoint matches.
2. Match on `req.path`, not `req.url`. `req.path` is the query-stripped pathname; using it prevents attacker-controlled query data from influencing a path-based allowlist decision. This is the single most important fix — even an anchored pattern would still be bypassable via a crafted path if the query string were included.
3. Replace the wildcard origin. Add an explicit `Origin` allowlist to `allowCrossDomain` instead of unconditionally emitting `Access-Control-Allow-Origin: *`. Even for `receive_async_response`, restrict responses to trusted origins and avoid reflecting arbitrary origins.
4. Audit sibling code. `handleLogContext` at `packages/base-driver/lib/express/middleware.ts:63-80` applies the same `req.url`-plus-unanchored-regex idiom (`SESSION_ID_PATTERN` at line 16) and should be reviewed for the same class of confusion.
5. Add regression tests. Assert that URLs such as `/session` with a query parameter containing `/session/a/receive_async_response` receive NO CORS headers, and that a legitimate `/session/{uuid}/receive_async_response` request still does.
6. Defence in depth. Consider binding to `127.0.0.1` by default and documenting that Appium must not be exposed on interfaces reachable by untrusted browsers.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:R
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:L
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
8.3/ 10Alto
Vector 8.3 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
@appium/base-driver≤ 10.7.2
10.7.2
10.8.3
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npm@appium/base-driver
Corregida 10.8.0 -23 d 10.8.3 no afectada
Versiones corregidas10.8.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/appium/appium/security/advisories/GHSA-4356-hm4h-ww9c

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.