-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting the pickle analysis data from within Python #1212
Comments
it is not currently supported, but cc'ing @McPatate (and @krampstudio for visibility) thanks for the feature request! |
Hey @JohnnyRacer, we are finally getting back to you about your feature request... and with good news! The security scan details are now returned by the server on the Results are paginated (50 files per page) which mean you need to iterate over the "next" An implementation is in progress in |
@Wauplin Thanks a lot for adding it as a new feature, just tested out the new API and it works very well! I was wondering if in the future a user downloading a potential malicious Pickle file would raise a confirmation warning to make it clear to them the risks before allowing the model to load? This seems like a good addition now that the scan data is available via the API. |
That's actually a pretty good idea! I'll keep it in mind to do it properly. I think that if we do something like that, it will be a warning but without asking confirmation from the user (or at least not by default). Always a balance to find between usability and security :) |
I think having an extra option |
Yes, I was thinking about an environment variable directly so that users can be sure to disable them globally. |
@McPatate before implementing this, what's your take on how to consider a file as "unsafe". I saw that the security scan has 3 levels: I see four options here:
For me it really depends on what Also cc @JohnnyRacer if you are opinionated on this topic. |
I think it would be a good idea to prevent downloads of dangerous Pickle checkpoints by default, with a warning message that can be disabled via an environment variable like you had mentioned above or by calling a function like |
I think the future-proof way is to emit a warning on any model loading from Pickle, as we default more and more to the safetensors format (and its usage is growing rapidly) |
Does it cost a lot to send a request to the hub to check before starting a download if there are dangerous imports? It could also be done asynchronously, as in no changes in the download logic, except you add a cancellation token to the download job and if the file contains a dangerous import, the asynchronous job cancels the download, wdyt @julien-c? EDIT: nvm my comment, the solution I'm proposing doesn't change much to the additional load issue |
That would definitely close this issue without additional load indeed. But that should rather live in libraries like |
Yes, correct |
or even in torch |
Hello, I am trying to obtain the pickle analysis data that is associated with pickled model checkpoints from Python programmatically but is unable to find anything in the docs on how to do this. Is there a clear way to do this?
A screenshot of the example of the analysis information is attached below.

The text was updated successfully, but these errors were encountered: