4 ms·
Insecurity and Python Pickles
- westurner 3y agoThere should be a data-only pickle serialization protocol (that won't serialize or deserialize code). How much work would it be to create a pickle protocol that does not exec or eval code? python/cpython//Lib/pickle.py: https://github.com/python/cpython/blob/main/Lib/pickle.py https://github.com/python/cpython/blob/main/Lib/pickle.py python/cpython//Lib/pickletools.py: https://github.com/python/cpython/blob/main/Lib/pickletools.py https://github.com/python/cpython/blob/main/Lib/pickletools....
- westurner 3y agoA data-only pickle serialization protocol implementation would need to skip calls to self.save_global() in pickle._Pickler.save() if condition(pickle_protocol) here https://github.com/python/cpython/blob/main/Lib/pickle.py#L568 https://github.com/python/cpython/blob/main/Lib/pickle.py#L5... and #L585 , and also in the save_type() dispatch table at #L1123 .
- westurner 3y agoHere's that: https://discuss.python.org/t/create-a-new-pickle-protocol-version-to-add-skipcode/48880/ https://discuss.python.org/t/create-a-new-pickle-protocol-ve...