Skip to content

Static Analysis Bypass via Incomplete Dangerous Module Blocklist

High
thomas-chauchefoin-tob published GHSA-q5qq-mvfm-j35x Jan 9, 2026

Package

pip fickling (pip)

Affected versions

<= v0.1.6

Patched versions

>= v0.1.7

Description

Our assessment

We added ctypes, importlib, runpy, code and multiprocessing to our list of unsafe imports (9a2b3f8, eb299b4, 29d5545, b793563, b793563).

Original report

Summary

The unsafe_imports() method in Fickling's static analyzer fails to flag several high-risk Python modules that can be used for arbitrary code execution. Malicious pickles importing these modules will not be detected as unsafe, allowing attackers to bypass Fickling's primary static safety checks.

Details

In fickling/fickle.py lines 866-884, the unsafe_imports() method checks imported modules against a hardcoded tuple:

def unsafe_imports(self) -> Iterator[ast.Import | ast.ImportFrom]:
    for node in self.properties.imports:
        if node.module in (
            "__builtin__", "__builtins__", "builtins", "os", "posix", "nt",
            "subprocess", "sys", "builtins", "socket", "pty", "marshal", "types",
        ):
            yield node

This list is incomplete. The following dangerous modules are NOT detected:

  • ctypes: Allows arbitrary memory access, calling C functions, and bypassing Python restrictions entirely
  • importlib: Can dynamically import any module at runtime
  • runpy: Can execute Python modules as scripts
  • code: Can compile and execute arbitrary Python code
  • multiprocessing: Can spawn processes with arbitrary code

Since ctypes is part of the Python standard library, it also bypasses the NonStandardImports analysis.

PoC

from fickling.fickle import Pickled
from fickling.analysis import check_safety, Severity

# Pickle that imports ctypes.pythonapi (allows arbitrary code execution)
# PROTO 4, GLOBAL 'ctypes pythonapi', STOP
payload = b'\x80\x04cctypes\npythonapi\n.'

pickled = Pickled.load(payload)
results = check_safety(pickled)

print(f"Severity: {results.severity.name}")
print(f"Is safe: {results.severity == Severity.LIKELY_SAFE}")

# Output: Severity is LIKELY_SAFE or low - the ctypes import is not flagged
# A truly malicious pickle using ctypes could execute arbitrary code

Impact

Security Bypass (Confidentiality, Integrity, Availability)

An attacker can craft a malicious pickle that:

  1. Imports ctypes to gain arbitrary memory access
  2. Uses ctypes.pythonapi or ctypes.CDLL to execute arbitrary code
  3. Passes Fickling's safety analysis as "likely safe"
  4. Executes malicious code when the victim loads the pickle after trusting Fickling's verdict

This undermines the core purpose of Fickling as a pickle safety scanner.

Severity

High

CVE ID

CVE-2026-22609

Weaknesses

Incomplete List of Disallowed Inputs

The product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete. Learn more on MITRE.

Deserialization of Untrusted Data

The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. Learn more on MITRE.

Credits