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

Prevent reading or writing OpenEXR images with no channels #911

Conversation

peterhillman
Copy link
Contributor

Address https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30115

OpenEXR images were always supposed to have at least one channel. This change adds the missing sanity check to prevent reading or writing files with no channel list, or with an empty channel list.

It is theoretically possible to create a file with an empty channel list, but it will always be flagged as incomplete.
Since such files are non-standard and unexpected, software reading such files may misbehave in ways that could be exploited.
For safety, it seems safer to add the explicit check to prevent handling such files.

For future-proofing, this test only runs on known types. In the future a new OpenEXR library may add a new 'part type' that does not contain a channel list attribute. Files with such parts would pass this sanity check so they could be (partially) loaded by existing versions of the library.

Signed-off-by: Peter Hillman peterh@wetafx.co.nz

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
Copy link
Member

@cary-ilm cary-ilm left a comment

Choose a reason for hiding this comment

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

We discussed this a while back in the TSC and concluded this is indeed the proper behavior: an exr file should not be allowed to have no channels. Software that processes exr images should not be expected to properly handle a file with no channels. Any use case that calls for an exr with no channels should be reconsidered, as that's not the proper use of the format.

@cary-ilm
Copy link
Member

On second thought, the tests are now failing.

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
@peterhillman
Copy link
Contributor Author

On second thought, the tests are now failing.

yes, embarrassingly our own tests were being lazy and attempting to create files with no channels. These tests largely were there to test the sanityCheck, so adding the channel list sanity check caused a different exception to be thrown than the one the test expected. Adding a dummy channel to the header fixed those tests.

The test file /src/test/OpenEXRTest/invalid_shared_attrs_multipart.exr contained a part with an empty channel list. Since I'm not sure how to recreate that file, I directly edited the EXR to add the missing channel.

@cary-ilm cary-ilm merged commit dbcae60 into AcademySoftwareFoundation:master Feb 1, 2021
@peterhillman peterhillman deleted the openexr_images_must_have_channels branch February 9, 2021 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants