Search code examples
securityruby-on-rails-4carrierwavepundit

Security when uploading images with Carrierwave


I'm using carrierwave for upload images. And I saw how to configuring file permissions like this:

CarrierWave.configure do |config|
  config.permissions = 0666
  config.directory_permissions = 0777
  config.storage = :file
end

But I don't understand what is this permissions. Can anybody help me with this question? And I'm doing a post with an attachment for an image. So is a problem of security to upload the images on the public folder? Because i'm using restrictions with the gem Pundit for restrict the access to the Posts. But I notice who anyone with the link can see the image(post.attachment). What I need to do for restrict completely the access? Can anyone help me with this? I will appreciate!


Solution

  • 0777 is UNIX shorthand for something with read/write/execute turned on, something that means the directory is public.

    0666 is shorthand for read/write, meaning the files are able to be read and modified by anyone.

    These values are in octal because of the leading 0, something that makes it easier to express specific bit patterns.