Summary
AgentFlow exposes an arbitrary code execution vulnerability where a user-controlled pipeline_path parameter is passed directly to API endpoints that load and execute local Python pipeline files.
If an attacker can induce or send requests to the local AgentFlow API, they may trigger execution of any accessible Python pipeline file on disk in the context of the user running AgentFlow.
Affected context
The vulnerability manifests in AgentFlow deployments where the API server:
- Exposes the
POST /api/runsandPOST /api/runs/validateendpoints - Accepts a
pipeline_pathparameter from user input or indirectly controlled data - Dynamically loads and executes Python pipeline files located on the local filesystem
It is most relevant in setups where untrusted users, proxied clients, or integrated services can influence requests to these endpoints, either directly or via SSRF, misconfigured reverse proxies, or exposed local interfaces.
Exploit preconditions
- Attack surface: HTTP API endpoints:
POST /api/runsPOST /api/runs/validate- Required access:
- Ability to send requests to the AgentFlow API (e.g., local network access, localhost access via browser or other service), or
- Ability to cause another component (e.g., a web panel, reverse proxy, or plugin) to send crafted requests including a controlled
pipeline_path. - Trigger point:
- Submission of a request where
pipeline_pathreferences an existing Python pipeline file on disk that AgentFlow will load and execute. - Why exploitation is possible:
- The API trusts the caller-supplied
pipeline_pathvalue without adequate validation or restriction and then uses it to locate and execute Python code, enabling arbitrary selection and execution of local pipeline modules.
Why this happens
The core issue aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'). AgentFlow uses user-controlled input (pipeline_path) to determine what Python pipeline code to load and run. This pattern effectively binds untrusted data directly to a code-loading/execution mechanism.
Instead of restricting execution to a predetermined, vetted pipeline registry or enforcing strict allow-listing and non-bypassable validation, the implementation relies on file paths provided via the API. This grants the caller influence over which code is executed, turning what should be a configuration-like parameter into a code execution primitive.
Potential impact
- Execution of arbitrary Python pipeline logic already present on the server filesystem
- Escalation from limited API access to full code execution in the context of the AgentFlow user
- Access to local data, configuration files, and environment secrets accessible to the AgentFlow process
- Lateral movement within the host environment using the privileges of the AgentFlow runtime
- Abuse of AgentFlow pipelines to exfiltrate data or tamper with downstream systems and integrations
General mitigation guidance
Effective mitigation focuses on constraining code execution and de-coupling it from user-controlled paths:
- Replace free-form
pipeline_pathhandling with an allow-listed registry of pipelines, where clients reference immutable IDs or names rather than filesystem paths. - Enforce strict validation that only permits execution of pipelines from a controlled directory with no user-write access, preventing selection of arbitrary local files.
- Treat pipeline definitions as data, not code, where possible—e.g., declarative pipeline descriptions interpreted by a constrained runtime instead of arbitrary Python modules.
- Run the AgentFlow service under a least-privilege account with minimized filesystem access and restricted ability to reach sensitive directories or system utilities.
- Introduce secure defaults: disable or limit dynamic pipeline loading unless explicitly enabled in trusted, administrative configurations.
How teams detect issues like this
Detection should aim to identify unsafe code-loading paths and anomalous pipeline execution:
- Static analysis / code scanning:
- Flag use of user-input parameters (like
pipeline_path) that flow into file loading or code execution APIs. - Identify patterns where filesystem paths from HTTP request bodies are used to import or execute Python modules.
- Code review signals:
- Endpoints that accept filenames or paths and then call import, dynamic loading, or execution functions without a strong allow-list.
- Lack of central authorization checks or capability-based controls on which pipelines can be invoked.
- Runtime and logging strategies:
- Log all pipeline executions including the resolved pipeline identifier and physical path, then monitor for unusual or previously unseen paths.
- Use host-based monitoring to detect unexpected Python module loads from uncommon directories or spike in executions triggered via the API.
- Policy enforcement:
- CI/CD checks to ensure that only declarative pipeline definitions are exposed to users, and that pipeline registries are immutable from user space.

