/

CVE-2026-31235

Severity:

CRITICAL RISK

(9.8)

Unsafe Deserialization in imgaug BackgroundAugmenter

CVE-2026-31235

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.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

imgaug's BackgroundAugmenter class trusts data received over a multiprocessing queue and deserializes it using Python's pickle module without validation.

If an attacker can influence the data sent to this queue, they can supply a malicious pickle payload that executes arbitrary code in the context of the worker process, resulting in local or remote code execution depending on how imgaug is deployed.

Affected context

This vulnerability affects applications that use imgaug's BackgroundAugmenter (in multicore.py) with multiprocessing enabled to augment images in background worker processes.

It becomes relevant when the data placed on the internal multiprocessing queue can be influenced—directly or indirectly—by untrusted or semi-trusted sources, shared infrastructure, or user-supplied scripts that control the augmentation pipeline.

Exploit preconditions

  • Attack surface: The multiprocessing queue used by BackgroundAugmenter to exchange augmentation tasks and data.
  • Required access: Ability to inject or manipulate items placed onto this queue (e.g., via a malicious script in a shared environment, compromised job orchestration, or any code path that forwards untrusted data into the augmentation pipeline).
  • Trigger point: The _augment_images_worker() method in multicore.py calls pickle.loads() (directly or indirectly) on queued data during normal processing.
  • Why exploitation is possible: Python's pickle format is code-capable; deserializing attacker-controlled pickle data lets an attacker define arbitrary object graphs whose construction can run attacker-chosen code, and the implementation does not apply any safety checks, type validation, or trust boundary enforcement before deserialization.

Why this happens

The core issue is the use of Python's general-purpose pickle deserialization on data whose authenticity and integrity are not guaranteed.

BackgroundAugmenter relies on a multiprocessing queue and uses pickle to transfer arbitrary Python objects between processes.

This pattern assumes the queue contents are fully trusted, but when that assumption is violated, it maps directly to CWE-502: Deserialization of Untrusted Data.

Pickle is inherently unsafe for untrusted input because object reconstruction can invoke arbitrary callables; without strict trust boundaries or format restrictions, any attacker-controllable data reaching pickle.loads() becomes an execution vector.

Potential impact

  • Execution of arbitrary code in the worker process context
  • Compromise of the application using imgaug (e.g., image processing service, ML training pipeline)
  • Unauthorized access to local files, environment variables, or credentials available to the worker
  • Use of the compromised process as a pivot for lateral movement within the hosting environment
  • Data tampering or poisoning of image datasets or model training inputs

General mitigation guidance

Effective mitigation focuses on removing or strictly constraining unsafe deserialization and tightening trust boundaries around inter-process communication:

  • Prefer serialization formats that are data-only and not code-capable (e.g., JSON, MessagePack, or protocol buffers) for transferring information between processes.
  • If pickling cannot be avoided, ensure the queue is only ever fed by strongly trusted code paths, under the same administrative control boundary as the worker processes.
  • Constrain the types of objects that can traverse the queue by using simple, well-defined data structures (e.g., primitive types, dicts, lists) and validate structure and types before processing.
  • Isolate augmentation workers using least-privilege principles (reduced OS permissions, minimal filesystem access, no unnecessary network connectivity) so that an exploited worker has limited impact.
  • Apply defense-in-depth controls such as process-level sandboxing, containerization, or mandatory access controls to reduce damage if deserialization is abused.

How teams detect issues like this

Detecting this class of vulnerability typically involves a combination of code-centric and operational techniques:

  • Static analysis: Flag usage of pickle.loads, pickle.load, or similar serialization APIs when the input source is not clearly constrained to trusted in-memory objects or private channels.
  • Code review: Look for multiprocessing or IPC patterns where complex objects are sent over queues or pipes, especially in libraries like imgaug, and verify that only trusted producers can write to those channels.
  • Security policy enforcement: Establish coding guidelines that prohibit pickle for untrusted data and require safer serialization formats; enforce these via pre-commit hooks or CI checks.
  • Runtime monitoring: Where feasible, monitor for unexpected child processes, abnormal file access, or network connections from augmentation workers that could indicate code execution beyond intended behavior.

Sources

SourceLink
github.comgithub.com/aleju/imgaug
notion.sonotion.so/CVE-2026-31235-35d1e139318881efb701d814228424a9

Frequently asked

questions

It can be, depending on architecture. If untrusted users can indirectly control data that is enqueued for BackgroundAugmenter (for example, in a remote image processing or ML service), the issue may be remotely exploitable. In more constrained setups, it may be limited to local or intra-tenant abuse.

The attacker needs a way to influence or inject objects into the multiprocessing queue used by BackgroundAugmenter. This could be through providing scripts or configuration in a shared environment, compromising upstream components that prepare augmentation tasks, or abusing any path that forwards user-controlled data into that queue.

The safest pattern is to avoid using pickle for data that may cross trust boundaries and instead adopt a data-only serialization format with explicit schemas or strict type constraints. Redesign the augmentation pipeline so that only simple, validated data structures are passed between processes.

Establish a rule that code-capable serialization formats like pickle are never used with data that could be influenced outside a strictly controlled, single-administrator boundary. Combine this with automated checks for unsafe deserialization APIs, architecture reviews of IPC mechanisms, and consistent use of least-privilege and sandboxing for worker components.

Find out what's already
exploitable in your codebase.