Shelve uses pickle, which executes untrusted code without asking.
These types of serialisation are a technical debt from day one. There are countless stories of ecosystems doing a very painful migration to get away from it. See java, or recently the ML model files trying to go to safetensors etc.