ModelScan PyDLL PyRun_SimpleString Bypass

Uses ctypes.PyDLL(None).PyRun_SimpleString(arbitrary_python_code) to execute any Python code directly through CPython's C API.

Bypass GLOBALs (what modelscan sees)

  • importlib.import_module โ€” NOT in unsafe_globals
  • ctypes.PyDLL โ€” NOT in unsafe_globals
  • operator.methodcaller โ€” NOT in unsafe_globals

Mechanism

  1. Import ctypes via importlib.import_module('ctypes')
  2. Create ctypes.PyDLL(None) (Python DLL handle)
  3. Call operator.methodcaller('PyRun_SimpleString', code)(pydll)
  4. โ†’ PyDLL(None).PyRun_SimpleString(code) โ†’ executes Python code via CPython C API

Why This Is Different

manja316 has modelscan-ctypes-rce-bypass using CDLL(None).system(). This approach uses PyDLL(None).PyRun_SimpleString() โ€” a completely different function that executes arbitrary PYTHON code, not just shell commands.

Impact

Full RCE with arbitrary Python code. No blocked modules involved.

Verification

modelscan -p exploit_pydll.joblib
# -> "No issues found!"
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support