/

CVE-2026-25632

Severity:

CRITICAL RISK

(10.0)

Unsafe Deserialization in EPyT-Flow Custom Loader

CVE-2026-25632

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(10.0)

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

EPyT-Flow's REST API and JSON file loader use a custom deserializer that dynamically imports and instantiates classes based on attacker-controlled JSON fields.

If an attacker can send crafted JSON requests or supply malicious JSON files, they may trigger arbitrary class instantiation (e.g., subprocess.Popen) and achieve OS command execution during JSON parsing.

Affected context

This vulnerability occurs in EPyT-Flow deployments that:

  • Expose the EPyT-Flow REST API to network clients, or
  • Load scenario or configuration data from JSON files that may be influenced by external parties

The risk is present when:

  • JSON request bodies or files are parsed using the custom my_load_from_json deserializer, and
  • The JSON includes a type field that the application does not strictly constrain to a safe allowlist.

Exploit preconditions

  • Attack surface: EPyT-Flow REST API endpoints and any code paths that load JSON files via my_load_from_json.
  • Required access: Ability to send HTTP requests with crafted JSON bodies, or to provide JSON files that the application will load.
  • Trigger point: Invocation of my_load_from_json on attacker-controlled JSON containing a type field referencing a dangerous or unexpected class.
  • Why exploitation is possible: The deserializer trusts the type field, dynamically imports modules/classes based on attacker input, and instantiates them with attacker-controlled arguments, enabling execution of side-effectful constructors such as subprocess.Popen.

Why this happens

The core issue is EPyT-Flow's use of a custom JSON deserializer that treats untrusted input as instructions for object construction.

The my_load_from_json function interprets a user-controlled type field as a directive to dynamically import and instantiate arbitrary classes, effectively turning data into code.

This maps directly to CWE-502: Unsafe Deserialization, where serialized data is deserialized into live objects without sufficient validation, allowing attackers to trigger code execution via constructors or special methods during the deserialization process.

Potential impact

  • Execution of arbitrary OS commands under the privileges of the EPyT-Flow process
  • Full compromise of the host running EPyT-Flow, depending on its permissions and environment
  • Manipulation or destruction of hydraulic and water quality scenario data
  • Unauthorized access to sensitive configuration, credentials, or datasets used by EPyT-Flow
  • Use of the compromised server as a pivot point for further attacks within the network

General mitigation guidance

Effective mitigation centers on eliminating data-driven object construction and tightening trust boundaries around JSON input.

Common defensive patterns include:

  • Treating JSON strictly as data: parse into primitive types and explicit data-transfer objects rather than arbitrary classes.
  • Removing or disabling any generic type-based instantiation logic for untrusted input.
  • If polymorphic behavior is required, using a strict allowlist of known-safe types and mapping them explicitly rather than via dynamic imports.
  • Separating configuration and runtime code so that configuration files cannot cause code execution when loaded.
  • Running EPyT-Flow with least-privilege OS accounts and, where possible, within sandboxed or containerized environments to limit blast radius.

How teams detect issues like this

Organizations can detect similar unsafe deserialization patterns by:

  • Static analysis rules that flag:
  • Dynamic imports based on user-controlled strings
  • Constructors or factory functions invoked with unvalidated data
  • Custom deserialization functions that interpret type or similar fields to select classes
  • Code review checklists that call out:
  • Any custom JSON/YAML/XML loader functions
  • Use of reflection or importlib in request/JSON parsing code paths
  • Security linters or automated review tools configured to:
  • Identify usages of dangerous APIs (e.g., subprocess.Popen, OS command execution) reachable from input-handling code
  • Enforce policies that forbid data-driven class loading from external inputs

Sources

SourceLink
github.comgithub.com/WaterFutures/EPyT-Flow/commit/3fff9151494c7dbc72073830b734f0a7e550e385
github.comgithub.com/WaterFutures/EPyT-Flow/releases/tag/v0.16.1
github.comgithub.com/WaterFutures/EPyT-Flow/security/advisories/GHSA-74vm-8frp-7w68

Frequently asked

questions

Yes. When the EPyT-Flow REST API is network-accessible, an attacker can exploit this issue remotely by sending specially crafted JSON requests that trigger unsafe deserialization and command execution.

The attacker needs the ability to supply JSON input that EPyT-Flow will parse—typically HTTP access to the vulnerable REST endpoints or control over JSON files that the application loads. No local shell access is required.

Replace the custom my_load_from_json deserializer with a data-only parsing approach that maps JSON into predefined, simple data structures. Avoid interpreting fields like type as instructions to import or instantiate arbitrary classes, and if polymorphism is required, use an explicit allowlist of safe types.

Design serialization formats to carry data, not behavior: do not allow untrusted inputs to influence which classes or modules are loaded. Enforce strict schemas for incoming JSON, avoid reflection in input-handling code, and add static analysis and code review checks specifically targeting unsafe deserialization and dynamic imports.

Find out what's already
exploitable in your codebase.