Severity:

HIGH RISK

(7.3)

Code Injection in db-gpt Flow Import Endpoint

CVE-2026-3409

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-74, CWE-94

Impact:

Remote Code Execution on the Application Server

Severity:

HIGH RISK

(7.3)

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

The Flow Import endpoint in eosphoros-ai db-gpt 0.7.5 unsafely loads user-supplied files using Python's dynamic import machinery, enabling arbitrary code execution.

When an attacker can remotely supply or influence a flow file that is imported through importlib.machinery.SourceFileLoader.exec_module, they may inject and run arbitrary code on the server.

Affected context

This vulnerability occurs in the Flow Import endpoint of db-gpt 0.7.5, where "flow" definitions are uploaded or referenced and then imported as executable Python modules.

It is relevant in deployments where:

  • Users can upload or provide paths/URLs to flow files, and
  • Those files are loaded via SourceFileLoader.exec_module without strict validation or isolation.

The risk is highest when the server is internet-accessible or exposed to untrusted or semi-trusted users.

Exploit preconditions

  • Attack surface: HTTP(S) API exposed by the Flow Import endpoint (/api/v1/serve/awel/flow/import).
  • Required access: Ability to invoke the flow import functionality and supply or control the imported file (e.g., uploaded file, file path, or repository content).
  • Trigger point: The server calls importlib.machinery.SourceFileLoader.exec_module on attacker-controlled source content.
  • Why exploitation is possible: The application treats flow files as trusted Python source, performing dynamic execution without robust validation, sandboxing, or strict separation between configuration and code.

Why this happens

The flaw stems from treating user-supplied or externally controlled flow definitions as executable Python modules.

By calling SourceFileLoader.exec_module on files derived from untrusted input, the application directly evaluates attacker-controlled code within the server's process.

This maps to:

  • CWE-94: Improper Control of Generation of Code, because user-controllable input is incorporated into executable code without sufficient constraints.
  • CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, as the downstream component (Python interpreter/import system) executes content that was not neutralized or constrained to a safe subset.

Conceptually, the design conflates data (flow description) with code (Python source), leading to an unsafe dynamic execution pattern.

Potential impact

  • Execution of arbitrary Python code with the privileges of the db-gpt service account.
  • Reading or modification of application data, model configurations, and flow definitions.
  • Lateral movement to other internal systems reachable from the compromised server.
  • Deployment of backdoors, cryptominers, or additional malicious services on the host.
  • Full compromise of the underlying OS account and potential privilege escalation depending on local configuration.

General mitigation guidance

Effective mitigation focuses on eliminating or strictly controlling dynamic execution of user-influenced code and separating configuration from executable logic:

  • Prefer a declarative flow format (e.g., structured YAML/JSON schemas) instead of importing arbitrary Python files.
  • If dynamic behavior is needed, restrict it to a curated set of safe operations or plugins loaded from a trusted, administrator-managed directory only.
  • Enforce strict validation and schema checking on imported flow definitions so only data structures (not raw code) are processed.
  • Use sandboxing or process isolation (e.g., separate, locked-down worker processes or containers) for any unavoidable execution of potentially unsafe logic, with minimal filesystem and network privileges.
  • Apply principle of least privilege to the db-gpt runtime account, limiting file system access, environment secrets, and outbound network capabilities to reduce blast radius.
  • Introduce approval workflows or restricted roles for flow import operations so that untrusted users cannot directly provide executable content.

How teams detect issues like this

Organizations can identify and monitor this pattern using a combination of static and operational techniques:

  • Static analysis and SAST rules to flag uses of importlib.machinery.SourceFileLoader, exec_module, exec, eval, or similar dynamic-import patterns where inputs can be traced to HTTP request parameters or user-uploaded files.
  • Code review checklists that explicitly ask reviewers to locate any dynamic code loading or execution and verify that only trusted, controlled inputs are used.
  • Configuration and policy enforcement that disallows runtime imports from user-writable directories or paths influenced by client data.
  • Runtime monitoring and logging of flow imports, including file origin, caller identity, and anomalies such as imports from unexpected locations.
  • Optional use of automated code review tools or custom linters to detect and gate unsafe dynamic execution patterns in CI/CD pipelines before deployment.

Sources

SourceLink
gist.github.comgist.github.com/YLChen-007/d2799d8b2077e50658f12a45bcae9b70
vuldb.comvuldb.com/?ctiid.348304
vuldb.comvuldb.com/?id.348304
vuldb.comvuldb.com/?submit.763745

Frequently asked

questions

Yes, it can be exploited remotely if the Flow Import endpoint is network-accessible and an attacker can provide or control the imported file. The attack surface is exposed via the HTTP API rather than direct filesystem access.

The attacker needs the ability to trigger the flow import functionality and influence the content or location of the imported file (for example, uploading a flow file or pointing to a file they control). No local shell access is required if the API is exposed.

The most robust fix is to stop treating flow definitions as executable Python code. Replace direct module imports with a declarative, data-only representation and process it using strict schema validation. If dynamic behavior must be supported, only load from a trusted, administrator-managed plugin set.

Adopt architectural patterns that clearly separate data from code, avoid dynamic execution of user-influenced content, and require security review for any use of dynamic imports, exec, or eval. Enforce these patterns using code review, static analysis rules, and CI policies that flag unsafe execution constructs early in development.

Find out what's already
exploitable in your codebase.