Severity:

HIGH RISK

(8.8)

Arbitrary Code Execution in AgentFlow API

CVE-2026-7466

Deferred

Vulnerability type

Category:

Arbitrary Code Execution

CWE:

CWE-94

Impact:

Remote Code Execution (within local AgentFlow runtime)

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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/runs and POST /api/runs/validate endpoints
  • Accepts a pipeline_path parameter 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/runs
  • POST /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_path references an existing Python pipeline file on disk that AgentFlow will load and execute.
  • Why exploitation is possible:
  • The API trusts the caller-supplied pipeline_path value 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_path handling 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.

Sources

SourceLink
github.comgithub.com/berabuddies/agentflow/pull/18
github.comgithub.com/berabuddies/agentflow/pull/18/changes/7e61b6ce846b3d700456e4874394dc868905a9f2
vulncheck.comvulncheck.com/advisories/agentflow-arbitrary-python-pipeline-execution-via-pipeline-path

Frequently asked

questions

It can be, depending on deployment. If the AgentFlow API is exposed beyond the local host or reachable through a reverse proxy, a remote attacker could submit crafted requests to exploit the issue. In setups where the API listens only on localhost, exploitation typically requires local access or an intermediary that can reach the service.

An attacker needs the ability to send or induce HTTP requests to the AgentFlow POST /api/runs or POST /api/runs/validate endpoints with control over the pipeline_path field. No direct shell access is required; the API itself becomes the execution vector.

The safest pattern is to remove direct path-based execution from the API entirely and replace it with a controlled pipeline registry or catalog. Clients should reference pipelines by stable identifiers, with the server resolving those IDs to vetted pipeline implementations stored in a non-user-writable location, enforced by strict validation and authorization.

Avoid coupling user input to code-loading or execution mechanisms. Treat all code as pre-deployed, vetted artifacts referenced indirectly (e.g., by ID) rather than by filesystem path. Apply least privilege to service accounts, enforce allow-lists for executable content, and ensure security reviews specifically look for dynamic code loading tied to external input.

Find out what's already
exploitable in your codebase.