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

Wiki advice doesn't seem to work (lottapixels) #1711

Closed
trinode opened this Issue Aug 1, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@trinode

trinode commented Aug 1, 2015

https://github.com/carrierwaveuploader/carrierwave/wiki/Denial-of-service-vulnerability-with-maliciously-crafted-JPEGs--(pixel-flood-attack)

says that we can add this:-

def validate_dimensions
      manipulate! do |img|
        if img.dimensions.any?{|i| i > 8000 }
          raise CarrierWave::ProcessingError, "dimensions too large"
       end
     img
   end
end

however from running it my understanding is that img will be an instance of command builder, which is used for building commands to run against the image. which makes sense, but it does mean .dimentions is unavailable resulting in the following when used:-

I, [2015-08-01T18:26:52.829111 #22384] INFO -- : Completed 500 Internal Server Error in 357ms (ActiveRecord: 10.9ms)
F, [2015-08-01T18:26:52.829897 #22384] FATAL -- :
NoMethodError (undefined method dimensions' for #<MiniMagick::CommandBuilder:0x00000006b2a038>): app/uploaders/profile_picture_uploader.rb:165:inblock in validate_dimensions'
app/uploaders/profile_picture_uploader.rb:164:in validate_dimensions' app/controllers/profile_pictures_controller.rb:73:inupload'

is there a working method for achieving the above (preventing images above a certain dimention being processed at all - making sure they don't murder the memory on the server when processed)?

@bensie

This comment has been minimized.

Show comment
Hide comment
@bensie

bensie Aug 18, 2015

Member

Please post usage questions to Stack Overflow. The wiki is provided by the community, so if you get an answer that works better than the current wiki page indicates, feel free to update it!

Member

bensie commented Aug 18, 2015

Please post usage questions to Stack Overflow. The wiki is provided by the community, so if you get an answer that works better than the current wiki page indicates, feel free to update it!

@bensie bensie closed this Aug 18, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment