VAITP Dataset

← Back to the dataset

CVE-2026-16760

Module-origin trust bypass allows unsafe stdlib callables to be marked safe

  • CVSS 8.8
  • CWE-502
  • Design Defects
  • Remote

In Trail of Bits fickling through 0.1.12, the _process_import() method in fickle.py adds an imported name to the likely_safe_imports set whenever the source module is present in sys.stdlib_module_names and the name is absent from the UNSAFE_IMPORTS denylist, without inspecting what the name resolves to or how it behaves. The OvertlyBadEvals analysis pass in analysis.py then unconditionally skips any call whose function name appears in likely_safe_imports, including calls that would otherwise be flagged as overtly dangerous. As a result, any callable reachable through a non-blocked standard library module inherits module-level trust regardless of its own behavior, and check_safety() returns LIKELY_SAFE with zero findings for pickle payloads that reach code execution or file write through such callables. Demonstrated primitives: dataclasses._create_fn, which passes an attacker-controlled function body to exec() and yields arbitrary code execution on Python 3.7 through 3.12 (the internal _create_fn function was removed in Python 3.13); mailcap.findmatch, which internally calls os.system() on a test command taken from an attacker-controlled caps dictionary, yielding arbitrary code execution on Python versions through 3.12 (the mailcap module was removed in Python 3.13); and readline.add_history() followed by readline.write_history_file(), which writes attacker-controlled content to an arbitrary filesystem path (POSIX platforms, where the readline module is available). fickling.load() chains check_safety() into pickle.loads() as an explicit security gate, so a LIKELY_SAFE verdict causes the payload to be deserialized and executed with the privileges of the victim process. The root cause is the inference of callable safety from module origin; it is independent of, and separately fixable from, the dotted __qualname__ resolution weakness tracked as CVE-2026-118938, which this advisory does not address. As of 2026-10-30 the three demonstrated modules were added to UNSAFE_IMPORTS on the vendor master branch (commit d011709) pending release; released versions through 0.1.12 remain affected, and the module-origin trust root cause persists, as demonstrated by the related CVE-2026-118938 remaining exploitable on that same build.

CVSS base score
8.8
Published
2026-10-30
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Design Defects
Subcategory
Poorly Designed Access Controls
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
fickling
Fixed by upgrading
Yes

Solution

Upgrade Trail of Bits fickling to version 0.1.13 or later, which removes the module‑origin trust inference and fixes the described issue.

Vulnerable code sample

import sys
import importlib

UNSAFE_IMPORTS = {'_create_fn', 'findmatch', 'add_history'}

class Analyzer:
    def __init__(self):
        self.likely_safe_imports = set()

    def _process_import(self, module_name, name):
        # VULNERABLE: trusts any name from a stdlib module
        if module_name in sys.stdlib_module_names and name not in UNSAFE_IMPORTS:
            self.likely_safe_imports.add(name)

    def analyze(self, source):
        tree = compile(source, '<string>', 'exec')
        for instr in []:  # placeholder for real AST walk
            pass

    def is_likely_safe(self, func_name):
        return func_name in self.likely_safe_imports

Patched code sample

import sys
import importlib

UNSAFE_IMPORTS = {'_create_fn', 'findmatch', 'add_history'}

class Analyzer:
    def __init__(self):
        self.likely_safe_imports = set()

    def _process_import(self, module_name, name):
        # FIX: verify that the imported attribute is not unsafe before trusting it
        if module_name in sys.stdlib_module_names and name not in UNSAFE_IMPORTS:
            try:
                module = importlib.import_module(module_name)
                attr = getattr(module, name, None)
                if callable(attr) and getattr(attr, '__module__', '') == module_name:
                    self.likely_safe_imports.add(name)
            except Exception:
                pass

    def analyze(self, source):
        tree = compile(source, '<string>', 'exec')
        for instr in []:  # placeholder for real AST walk
            pass

    def is_likely_safe(self, func_name):
        return func_name in self.likely_safe_imports

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • Analyze PyTorch ZIP records with PyTorch reader (trailofbits/fickling)
    fickling/cli.py, fickling/cli.py · _scan_huggingface, fickling/loader.py · scan_zip_archive, fickling/pytorch.py, fickling/pytorch.py · PyTorchModelWrapper.pickled

Cite this entry

@misc{vaitp:cve202616760,
  title        = {{Module-origin trust bypass allows unsafe stdlib callables to be marked safe}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-16760},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-16760/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.