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

Upgrading min Pillow requirement version to 6.1.0 #5358

Merged
merged 5 commits into from
Apr 30, 2021

Conversation

alexdesiqueira
Copy link
Member

Description

Dependabot is showing some issues on Pillow < 8.1.1. Maybe upgrading won't hurt?

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.

@alexdesiqueira alexdesiqueira added the 🔧 type: Maintenance Refactoring and maintenance of internals label Apr 26, 2021
@alexdesiqueira
Copy link
Member Author

According to the discussion in #5340, where @jni says:

... we use NEP-29 as a guide for how long to keep our minimal dependencies.

This way, we have:

❯ nep29 pillow
| version |    date    |
|---------|------------|
|  8.2.0  | 2021-04-01 |
|  8.1.0  | 2021-01-02 |
|  8.0.0  | 2020-10-14 |
|  7.2.0  | 2020-06-30 |
|  7.1.0  | 2020-04-01 |
|  7.0.0  | 2020-01-02 |
|  6.2.0  | 2019-10-01 |
|  6.1.0  | 2019-07-03 |

So we could update Pillow to 6.1.0 in July. On the other hand, Dependabot says:

Pillow before 8.1.1 allows attackers to cause a denial of service (memory consumption) because the reported size of a contained image is not properly checked for a BLP container, and thus an attempted memory allocation can be very large.

... and other scary warnings. For now, I'll leave this open for discussion, if you'd like. Else, please close it 🙂

@alexdesiqueira alexdesiqueira changed the title Upgrading Pillow version Upgrading Pillow version to 8.1.2 Apr 26, 2021
@sciunto
Copy link
Member

sciunto commented Apr 27, 2021

we mainly have PIL as a direct dependency for io collections, and indirectly from imageio. A way to attack this issue is to remove direct PIL imports. THis is something I investigated, with the help of @jni. It appears that we have a piece of code to load series of tiff images and series of animated gif images. Afaik, the main stopper is that imageio doesn't have the capability to read animated gif and we delegate this to PIL. I don't know how much reading animated gif is important.

I believe this point of view can help in the debate as well.

@jni
Copy link
Member

jni commented Apr 27, 2021

Yeah, I've always considered security "above my pay grade". This all just makes me think I was right. 😂 And also about delegating all io to imageio.

At any rate: I think the NEP-29 guideline is just that — a guideline, and it can be overridden in cases where it makes sense. If pillow 8.1.2 is available on conda-forge, Anaconda defaults, etc, I'm happy to bump up the dependency.

Another alternative is to defer our imports of pillow and raise a warning when it is imported if the version predates 8.1.2.

I'm ok with either option, so I'm going to approve this and let the next person decide. ;)

@sciunto
Copy link
Member

sciunto commented Apr 27, 2021

In the past, we decided to set a warning.

@alexdesiqueira
Copy link
Member Author

Another alternative is to defer our imports of pillow and raise a warning when it is imported if the version predates 8.1.2.

@sciunto:

In the past, we decided to set a warning.

How would be that warning?

@sciunto
Copy link
Member

sciunto commented Apr 27, 2021

See #4861 ;)

@alexdesiqueira
Copy link
Member Author

I did some research today on this:

Afaik, the main stopper is that imageio doesn't have the capability to read animated gif and we delegate this to PIL.

It seems that imageio does this now — through PIL.

A way to attack this issue is to remove direct PIL imports. THis is something I investigated, with the help of @jni. It appears that we have a piece of code to load series of tiff images and series of animated gif images.

Maybe we could use imageio's alternative; they would deal with Pillow, then. How does that sound?

@@ -2,7 +2,7 @@ numpy>=1.16.5
scipy>=1.2.3
matplotlib>=3.0.3
networkx>=2.2
pillow>=5.4.0,!=7.1.0,!=7.1.1
pillow>=8.1.2
Copy link
Member

Choose a reason for hiding this comment

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

THen, I guess you want to relax the min version

Copy link
Member Author

Choose a reason for hiding this comment

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

see above for the min req
THen, I guess you want to relax the min version

Sorry @sciunto, I didn't get it 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to set >=6.1.0 or so? otherwise, the warning doesn't make sense anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

I expect it to be >=8.1.2, but I updated the CVE numbers on the warning to reflect the latest issues. Isn't it the way to do here?
What would you prefer? To set up >=6.1.0?

Copy link
Member

Choose a reason for hiding this comment

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

If you choose > 8.1.2, no need to have the warning, because the users will be forced to upgrade. If we do not want to force the upgrade, then warning and >6.1.0. THat's my understanding.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sciunto got it. I thought the warning would check if the machine has that version, and would ask to update based on that.
Warning off, then? 🙂

@sciunto
Copy link
Member

sciunto commented Apr 28, 2021

Maybe we could use imageio's alternative; they would deal with Pillow, then. How does that sound?

Yes, I was reading imageio's doc and didn't see that support. But, if it works, then definitely yes.

Copy link
Member

@sciunto sciunto left a comment

Choose a reason for hiding this comment

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

see above for the min req

@sciunto
Copy link
Member

sciunto commented Apr 28, 2021

Maybe we could use imageio's alternative; they would deal with Pillow, then. How does that sound?

Yes, I was reading imageio's doc and didn't see that support. But, if it works, then definitely yes.

We can try this in a different PR.

@hmaarrfk
Copy link
Member

I feel like security issues are for system integrators to worry about. Problems and bugs come and go (well they come and they come).

security issues would bump us to bleeding edge.

@alexdesiqueira
Copy link
Member Author

@hmaarrfk you have a point. I'll put 6.1.0 in this one, then, and leave the latest warnings; this way we'll get a full version up, at least

@alexdesiqueira alexdesiqueira changed the title Upgrading Pillow version to 8.1.2 Upgrading Pillow version to 6.1.0 Apr 30, 2021
@sciunto sciunto merged commit 59b78d8 into scikit-image:main Apr 30, 2021
@sciunto
Copy link
Member

sciunto commented Apr 30, 2021

Thank you @alexdesiqueira

@sciunto sciunto changed the title Upgrading Pillow version to 6.1.0 Upgrading min Pillow requirement version to 6.1.0 Apr 30, 2021
@alexdesiqueira alexdesiqueira deleted the upgrade_pillow branch April 30, 2021 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💬 Discussion 🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants