I would say that a safe way to use a brine to handle unreliable data does not exist.
Even with limited global dynamics, the dynamic nature of Python is such that a certain hacker still has a chance to find a way to display __builtins__ and from there to Jewel Crown.
See the Ned Batchelder blog post for restrictions on eval() that apply equally to pickle .
Remember that pickle is still the language of the stack, and you cannot foresee all possible objects created by allowing arbitrary calls even to a limited set of global variables. The pickle documentation also does not mention EXT* opcodes, which allow you to call copyreg extensions; You will also have to consider everything that is installed in this registry. All that is required is a single vector, allowing you to turn the call of the object into the equivalent of getattr for your protection to crash.
At the very least, use a cryptographic signature for your data so you can verify integrity. You will limit the risks, but if an attacker manages to steal your subscription secrets (keys), then they can again dump you with hacked pickling.
Instead, I would use an existing harmless format, such as JSON, and add type annotations; for example, store data in dictionaries using a type key and convert it when loading data.
source share