📚 Encyclopedia

Games & Graphics · updated 2026-11-30

Blender Python scripting, safety audit and gotchas

blenderbpypythonsecurityrigging

.blend files can carry embedded Python (text datablocks registered as modules, plus driver expressions) that runs when the file opens with auto-run enabled. Commercial or community character rigs almost always ship such scripts for their UI panels. This article covers how to audit them without running them, how to open a file trusted on a per-file basis, and API traps met in Blender 5.x while scripting a purchased character rig (the Pharah v5.3 model, August 2026).

Auditing embedded scripts without executing them

Run Blender headless, with factory settings and auto-exec disabled, and a dump script that writes out every text block and driver expression:

blender --background --factory-startup --disable-autoexec model.blend --python dump.py

dump.py iterates bpy.data.texts (write t.as_string() to files) and every obj.animation_data.drivers / shape_keys.animation_data.drivers expression. Then grep the dump for socket, urllib, requests, subprocess, os.system, eval, exec, open( with write modes, and wm.url_open. In the Pharah case the 5,000-line rig script was benign: UI panels, a driver helper, and user-clicked links to the author's site.

Opening a file trusted, per file

Do not turn on global "Auto Run Python Scripts". Instead open the vetted file with:

bpy.ops.wm.open_mainfile(filepath=path, use_scripts=True)

Hot-reloading a rig's UI script

A data-driven rig panel can be extended by editing its text datablock (for example adding entries to an outfit dictionary) and re-registering it in place:

txt = bpy.data.texts["PBGv5.py"]
ns = {"__name__": "reload"}
exec(compile(txt.as_string(), "PBGv5.py", "exec"), ns)
ns["register"]()

Blender tolerates re-registering classes with the same bl_idname, but app handlers (such as load_post) get added twice; remove the duplicate afterward.

API gotchas (Blender 5)

Headless modeling for 3D printing

See also

Linked from

Sources: blend project memory