Security considerations for trust_remote_code=True #12033
Replies: 2 comments 1 reply
-
This is an interesting discussion, first I must clarify that this is my own personal opinion but I'm intrigued why do you refer as a "soft" consent to add a specific argument with the value I understand your concerns about copy & paste some code from the tutorials, but my piece of advice here is that you should never copy & paste any code on production without understanding fully what you're doing and reviewing the code your using. For example, the link you posted is for a section that has this The About this part:
This feature is so people can just use their custom code directly as blocks with modular diffusers, this doesn't mean you should use public anonymous code, you can just use your own code and be able to reuse it with multiple pipelines and scripts, you're not forced to:
Also you would be surprised on how people view this, we promote a lot the use of the But as you can see, even Just so you know, I'm just discussing this and giving my point of view, I would love to read more opinions about this matter, so feel free to discuss further what I'm saying if there's something wrong with it. |
Beta Was this translation helpful? Give feedback.
-
Hey @asomoza I agree that setting trust_remote_code=True is an explicit action, but I still see it as a soft form of consent when it means running remote code. The problem is this flag can be hidden inside wrapper libraries or copied without users realizing it will execute code from external sources. Especially as this is pulling down live code from the web. This kind of issue has come up before in ecosystems like NPM and PyPI, where people have exploited similar risks around executing hidden or remote code. I’m just flagging this for discussion because, while it might not be a big risk for me or most people right now, it could become a problem as the ecosystem and number of repos keep growing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Diffusers team,
I’m reaching out with a question and some concerns about the security implications of allowing
trust_remote_code=True
when loading pipelines viaModularPipeline.from_pretrained()
. As recently noticed this being used in PR descriptions.https://huggingface.co/docs/diffusers/main/en/modular_diffusers/modular_pipeline#creating-a-modularpipeline-with-frompretrained
From what I understand, enabling this option allows execution of arbitrary Python code from remote, which seems similar in risk to running
exec()
on unvetted code fetched from the internet. This raises potential security concerns around malicious code injection or data leaks.I’m curious if the team has considered these risks, and whether there are safeguards in place to prevent accidental or silent execution of potentially harmful code. For example:
I appreciate the flexibility this feature provides, but want to better understand the trade-offs and any best practices recommended to keep users safe.
Thanks for your time and insights. Please feel free to correct me if I’m mistaken about any of this.
Beta Was this translation helpful? Give feedback.
All reactions