The vulnerability is a trust_remote_code bypass in the diffusers library, allowing for remote code execution. The root cause was that the security check for trust_remote_code was implemented in DiffusionPipeline.download(), which was not always executed, especially when loading models from a local path or using the custom_pipeline feature. This allowed an attacker to execute arbitrary code by crafting a malicious model or pipeline.
The patch addresses this by moving the trust_remote_code check to a lower-level, centralized function, get_cached_module_file, which is always called when a dynamic module is loaded. The patch also updates the user-facing API functions like DiffusionPipeline.from_pretrained, AutoModel.from_pretrained, and ModularPipeline.from_pretrained to accept the trust_remote_code parameter and pass it down the call stack.
Therefore, the key vulnerable functions are the entry points that users call (*.from_pretrained) and the functions involved in the flawed security check (DiffusionPipeline.download) and the actual code loading (get_cached_module_file). Exploitation would involve a call to one of the from_pretrained methods, which would then trigger the vulnerable code path that loads and executes untrusted Python code.