Disable libvips unfuzzed operations - #460
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Active Storage image processing by restricting libvips operations/loaders and ensures the UI gracefully handles images that cannot be resized (by serving the original instead of raising on variant generation).
Changes:
- Add a
Picture#large_imagehelper that returns a resized variant for variable images, otherwise returns the original attachment. - Block untrusted libvips operations (and OpenSlide explicitly) and remove unsupported image types from
active_storage.variable_content_types. - Add tests covering loader selection/denial policy and the “cannot be resized” rendering path.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/models/picture_test.rb | Verifies large_image returns a variant for variable images and the original for non-variable types (e.g., BMP). |
| test/lib/vips_loader_policy_test.rb | Pins which loaders are allowed/denied under the configured libvips blocking policy. |
| test/controllers/leafables_controller_test.rb | Ensures a picture with a non-resizable image still renders successfully in the show view. |
| config/initializers/vips.rb | Blocks untrusted libvips operations and removes BMP/ICO/PSD from variable content types. |
| app/views/pictures/_form.html.erb | Uses large_image for the preview image to avoid invariable variant errors. |
| app/views/leaves/_leaf.html.erb | Uses large_image for picture leaves to avoid failing when variants can’t be generated. |
| app/views/leaves/_edit.html.erb | Uses large_image for the thumbnail rendering path when an image is attached. |
| app/views/leafables/show.html.erb | Uses large_image for the main picture rendering path (lazy-loaded). |
| app/models/picture.rb | Introduces large_image helper to centralize “variant-or-original” behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
and add test coverage for (un)supported file types. BMP, ICO, and PSD attachments are no longer variable, and the picture views call `variant(:large)` unconditionally, which raises `ActiveStorage::InvariableError`. `Picture#large_image` will fall back to the original attachment.
flavorjones
force-pushed
the
block-unfuzzed-operations
branch
from
July 28, 2026 14:58
bea7100 to
614a1d5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Harden image processing, and add test coverage for (un)supported file types.
BMP, ICO, and PSD attachments are no longer variable, and the picture views call
variant(:large)unconditionally, which raisesActiveStorage::InvariableError. IntroducePicture#large_imageto fall back to the original attachment.