Summary
Mesop versions 1.2.2 and below expose a debugging Flask endpoint that accepts base64-encoded Python source code and executes it on the host without any authentication or validation.
Anyone able to send HTTP requests to this /exec-py route can achieve unrestricted remote code execution on the underlying machine.
Affected context
This vulnerability occurs in Mesop deployments that run the AI testing/sandbox infrastructure, specifically the lightweight Flask debug server defined in ai/sandbox/wsgi_app.py.
The affected context is the /exec-py HTTP route, which is reachable whenever this sandbox server is started as part of development, testing, or misconfigured production deployments.
The issue is present when:
- The debug server is exposed on a network interface reachable by untrusted users, and
- The route remains enabled without any authentication or access control checks.
Exploit preconditions
- Attack surface: HTTP endpoint (
POST /exec-py) exposed by the Mesop AI sandbox Flask application. - Required access: Network ability to send HTTP requests to the server (no authentication or session required).
- Trigger point: A POST request with a
codeparameter containing base64-encoded Python source code. - Why exploitation is possible: The endpoint:
- Accepts untrusted Python code payloads,
- Decodes and writes them into a file on disk,
- Dynamically loads and executes them via
execute_module(module_path...)
with no input validation, sandboxing, or authorization checks.
Why this happens
The core issue is an intentionally permissive debugging endpoint that directly interprets user-controlled input as executable Python code.
This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where untrusted input is fed into code execution mechanisms without restriction.
The design couples remote HTTP input with dynamic module loading (execute_module) and filesystem writes, effectively turning the route into a remote shell.
Missing authentication, environment gating (e.g., dev-only safeguards), and execution sandboxing convert what might be acceptable in a tightly controlled local debug context into a critical RCE vulnerability when exposed on any shared or production network.
Potential impact
- Full remote execution of arbitrary OS commands on the host running the Mesop debug server
- Reading, modifying, or deleting application data and local files accessible to the Mesop process
- Deployment of backdoors, web shells, or persistence mechanisms on the host
- Lateral movement within the network using the compromised host as a foothold
- Abuse of host resources for cryptomining, spam campaigns, or other illicit workloads
- Complete takeover of the affected Mesop environment and potential compromise of connected systems
General mitigation guidance
Mitigation centers on eliminating direct execution of untrusted code and hardening debug infrastructure:
- Remove or disable HTTP endpoints that execute arbitrary code; avoid exposing such routes in any non-isolated environment.
- If dynamic code evaluation is absolutely required for internal tooling, enforce strict authentication, authorization, and network isolation, and prefer non-production environments only.
- Replace arbitrary code execution with constrained, parameterized APIs that expose only specific, vetted operations instead of raw Python execution.
- Gate debug/test servers behind environment checks so they cannot run unintentionally in production.
- Run application components with least-privilege OS accounts and minimal filesystem access to reduce blast radius if a similar issue occurs.
- Segment networks so that debug or test services are not reachable from the public internet or from untrusted internal segments.
How teams detect issues like this
Detection typically combines code-level review and operational monitoring:
- Static analysis & code review:
- Flag any use of dynamic code execution mechanisms (e.g.,
exec,eval, dynamic module loading) wired directly to HTTP request parameters. - Identify Flask or web routing definitions that call into sandbox or "exec" style utilities without authentication checks.
- Enforce internal policies that prohibit unauthenticated debug endpoints in shipped artifacts.
- Configuration & deployment checks:
- Scan container images and deployment manifests for inclusion of debug server modules (
ai/sandbox/wsgi_app.py) in production configurations. - Use CI/CD checks to block deployments when debug-only services or routes are enabled.
- Runtime monitoring:
- Monitor web access logs for unusual traffic to endpoints with names like
/exec-py,/sandbox, or/debug. - Watch for suspicious child processes, file writes to temporary modules, or spikes in CPU usage on hosts running Mesop.
- Automated security testing tools and web scanners can help surface exposed debug endpoints and verify that sensitive routes require authentication.

