Skip to content

fix: add ctypes, signal, http to unsafe_globals blocklist#339

Open
scruge1 wants to merge 1 commit intoprotectai:mainfrom
scruge1:fix/add-ctypes-signal-http-to-blocklist
Open

fix: add ctypes, signal, http to unsafe_globals blocklist#339
scruge1 wants to merge 1 commit intoprotectai:mainfrom
scruge1:fix/add-ctypes-signal-http-to-blocklist

Conversation

@scruge1
Copy link

@scruge1 scruge1 commented Mar 23, 2026

Summary

Add ctypes, signal, http, http.client, urllib, and urllib.request to the unsafe_globals CRITICAL blocklist in settings.py.

Problem

ctypes.CDLL is not in the current blocklist. A malicious pickle/joblib/numpy file using ctypes.CDLL in __reduce__ passes modelscan with "No issues found" and achieves:

  • DLL loading with DllMain execution (single-stage RCE)
  • C runtime access via ctypes.CDLL("msvcrt").system(b"cmd") (two-stage RCE)

Confirmed end-to-end RCE:

import pickle, ctypes
class E:
    def __reduce__(self):
        return (ctypes.CDLL, ("msvcrt",))
with open("model.pkl","wb") as f: pickle.dump(E(), f)
# modelscan -p model.pkl → "No issues found!"
result = pickle.loads(open("model.pkl","rb").read())
result.system(b"echo PWNED > pwned.txt")  # File created

Also confirmed bypassing on: signal.raise_signal (DoS), http.client.HTTPConnection (network exfil).

Fix

Add these modules to the CRITICAL blocklist alongside existing entries like os, subprocess, sys.

Affected Formats

Confirmed on: Pickle (.pkl), Joblib (.pkl), NumPy (.npy). Likely affects all pickle-based formats.

Related Huntr reports submitted for Pickle, Joblib, and NPY formats.

ctypes.CDLL bypasses the current blocklist and enables:
- Arbitrary DLL/SO loading with DllMain execution (single-stage RCE)
- Direct C runtime access (system(), exec())
- Confirmed end-to-end RCE on pickle, joblib, and numpy formats

Also adds signal (process crash), http.client (network exfiltration),
and urllib (data exfiltration) which also bypass the current blocklist.

All confirmed passing modelscan 0.8.8 with 'No issues found'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant