Skip to content
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

remove trusted=True from skops.io.load(s) #422

Merged
merged 9 commits into from
Jun 13, 2024

Conversation

adrinjalali
Copy link
Member

@adrinjalali adrinjalali commented Jun 6, 2024

We got a CVE report where an attacker can execute arbitrary code with trusted=True. While one can argue this is a feature and not a bug, it does pose the issue that people might be overly optimistic about the security of the format.

Therefore removing it might be a better idea. This doesn't change any functionality since users can still trust the file by blindly passing trusted=get_untrusted_types(...)

cc @BenjaminBossan

I also have to say, having typehints made the process a LOT easier here.

CVE:https://www.recordedfuture.com/vulnerability-database/CVE-2024-37065

@BenjaminBossan
Copy link
Collaborator

We got a CVE report where an attacker can execute arbitrary code with trusted=True. While one can argue this is a feature and not a bug, it does pose the issue that people might be overly optimistic about the security of the format.

IMO this is a bit silly, with the same logic the whole pickle module would need to be removed. But I guess since there is a simple (albeit not really safer) solution, I'd be okay with the change. I'm wondering, however, if this should be deprecated?

This doesn't change any functionality since users can still trust the file by blindly passing trusted=get_untrusted_types(...)

We could add a check that __repr__ has been called at least once on the output of get_untrusted_types and at least 1 second per item has passed since. Just kidding of course, but yeah...

I also have to say, having typehints made the process a LOT easier here.

Nice!

@adrinjalali
Copy link
Member Author

I'm wondering, however, if this should be deprecated?

We used to have the hint that the API is really subject to change though. That's why I didn't deprecate. However, this has been used now for a while and pretty stable. So I removed the comment here and from now we can be even more conservative in changes.

Copy link
Collaborator

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM (though I still don't think they're really necessary).

I think mypy should pretty much make sure that the change was propagated completely through the code base. I still grepped through the code and found some instances that may need updates (see comments).

Apart from that, how about adding a paragraph to the docs that explicitly mentions that the trusted=True option was removed (and why using it was a bad idea anyway). Since this is a breaking change, making sure that users can quickly find a reference to this would be beneficial.

skops/io/tests/test_visualize.py Show resolved Hide resolved
skops/io/_audit.py Show resolved Hide resolved
@@ -14,6 +14,8 @@ v0.10
- Removes Pythn 3.8 support and adds Python 3.12 Support :pr:`418` by :user:`Thomas Lazarus <lazarust>`.
- Removes a shortcut to add `sklearn-intelex` as a not dependency.
:pr:`420` by :user:`Thomas Lazarus < lazarust > `.
- ``trusted=True`` is now removed from ``skops.io.load`` and ``skops.io.loads``.
:pr:`422` by `Adrin Jalali`_.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an explanation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member Author

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I addressed the comments @BenjaminBossan

@@ -14,6 +14,8 @@ v0.10
- Removes Pythn 3.8 support and adds Python 3.12 Support :pr:`418` by :user:`Thomas Lazarus <lazarust>`.
- Removes a shortcut to add `sklearn-intelex` as a not dependency.
:pr:`420` by :user:`Thomas Lazarus < lazarust > `.
- ``trusted=True`` is now removed from ``skops.io.load`` and ``skops.io.loads``.
:pr:`422` by `Adrin Jalali`_.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@adrinjalali
Copy link
Member Author

@BenjaminBossan you okay with this now?

Copy link
Collaborator

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the adjustments, this LGTM.

I have a nit about a type check, please take a look and decide if you want to fix it (you can merge no matter what).

While reviewing, I also stumbled upon the fact that from typing import Sequence is apparently deprecated:

https://docs.python.org/3/library/typing.html#typing.Sequence

Not sure if the tests should have caught that. Anyway, this can be addressed in a separate PR.

skops/io/_persist.py Outdated Show resolved Hide resolved
skops/io/_persist.py Outdated Show resolved Hide resolved
@adrinjalali
Copy link
Member Author

While reviewing, I also stumbled upon the fact that from typing import Sequence is apparently deprecated:

Cool, I'll open a separate PR for that.

@adrinjalali adrinjalali merged commit 25a9d99 into skops-dev:main Jun 13, 2024
14 of 15 checks passed
@adrinjalali adrinjalali deleted the trusted branch June 13, 2024 10:49
@judahrand
Copy link

judahrand commented Jun 27, 2024

Could a release with this change be put out so that we can silence our CVE warning? 😅

@adrinjalali
Copy link
Member Author

@judahrand yes, working on a numpy2 compatibility PR and will release with that one.

@adrinjalali
Copy link
Member Author

Release is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants