Monday, December 27, 2010

Securing the Redmine_S3 plugin

We run redmine internally here at Fuery Solutions. Redmine is a fantastic tool for managing software development projects.

One of the unfortunate "features" redmine has is the habit of storing uploaded files without any security, regardless of whether the system itself is password protected or not. The redmine s3 plugin echoes this habit, setting all uploaded documents to readable by the entire internet. Obviously, the URLs are somewhat obscure, but as the cliche goes, obscurity is not security.

Here are instructions for altering the plugin to use temporary authorized URLs. This effectively offloads the security requirements to Amazon's formidable infrastructure.

These instructions apply to:

  • Redmine 1.0.x
  • Redmine_S3 v 0.03
Files you'll be editing (where "redmine" is your rails application root):
  1. redmine/vendor/plugins/redmine_s3/lib/redmine_s3/attachment_patch.rb
  2. redmine/vendor/plugins/redmine_s3/lib/redmine_s3/attachments_controller_patch.rb
  3. redmine/vendor/plugins/redmine_s3/lib/redmine_s3/connection.rb
First, we need to disable the "set newly uploaded files to be readable" command. This entails commenting a single line in attachment_patch.rb, on line 24:

#Private (not readable by everyone) is the default.
#RedmineS3::Connection.publicly_readable!(path_to_file)

This handles newly created files. Next, we need to add the capability to retrieve a URI with the AWS temporary authorization keys. The S3 lib the plugin uses actually contains theses goodies already, so we just need a wrapper function in connection.rb that uses the QueryStringAuthGenerator class. This function isn't as clean as it could be, but we threw this together in an hour. Add this function to the Connection class in connection.rb:


def self.private_uri(filepath)
 load_options unless @@access_key_id && @@secret_acces_key
 @@qs_conn = S3::QueryStringAuthGenerator.new(@@access_key_id, @@secret_acces_key, false) unless @@qs_conn
 @@qs_conn.get(bucket, filepath)
end


I added this on line 37, between the bucket and uri functions. You'll also, of course, need to initialize @@qs_conn by adding this at the beginning of the file (line 7 or so):


@@qs_conn = nil

Finally, we need to adjust the controller function that handles the response to the attachment GET requests themselves. Adjust attachments_controller_path.rb on line 23:

#Comment the current line 23.
#redirect_to("#{RedmineS3::Connection.uri/#{@attachment.path_to_file}") 
#New code
redirect_to("#{RedmineS3::Connection.private_uri(@attachment.path_to_file)}") 


Don't forget to restart your application after performing these changes. You'll also, of course, need to adjust the file settings in AWS for previously uploaded files. Although this new code works for viewing those files, the security settings ("visible to everyone") need to be reset manually.


51 comments:

  1. Thanks for the post!! that really helped me out.
    ReplyDelete
  2. inspiring information! I am looking forward to reading more from you!
    ReplyDelete
  3. Really its very good post.knowledge sharing is the optimum result of knowledge gaining.
    ReplyDelete
  4. Hey that post is really very helpful,
    Thanks alot...
    ReplyDelete
  5. conference call

    This has been a very significant blog indeed. I’ve acquired a lot of helpful information from your article. Thank you for sharing such relevant topic with us.
    ReplyDelete
  6. very helpful article..continue posting!
    ReplyDelete
  7. great post,S3 can be a real nightmare at times and this can things significantly easier
    ReplyDelete
  8. This is valuable information. Thanks for sharing.
    organic baby

    http://www.purelybaby.com.au
    ReplyDelete
  9. Thanks for writing such an in-depth review! I was really glad to have such an experienced set of eyes as yours review it.
    ______________
    Paul
    Payroll Services
    ReplyDelete
  10. That is some awesome coding right there. I don't think I am at that level yet.

    Brady
    Zeiss scopes
    ReplyDelete
  11. Nice Post! I am quite sure they will study lots of new stuff here than anybody else! I like your writing. I just passed this onto a colleague and friends.

    ww.entertainment-pictures.blogspot.com
    ReplyDelete
  12. Thank you really for helping make the post give light to many problems we have had before now.
    ReplyDelete
  13. Redmine_S3 plugin - what is it? I working with WP - needed?
    ReplyDelete
  14. Thanks for sharing nice article, i like it so much
    ReplyDelete
  15. nice post, looks really good!
    ReplyDelete
  16. Wow!! i am very impressed with your lovely post.. i am so glad to left comment on this..
    http://worldstudentloans.blogspot.com/
    ReplyDelete
  17. Great share, looking forward for more!
    ReplyDelete
  18. Inspiring information! I am looking forward to reading more from you!
    ReplyDelete
  19. I admire the valuable information you offered in your article. Excellent submission very good post.

    GED Schools
    ReplyDelete
  20. Cialis..........


    Dopo le droghe come Viagra e Cialis ha rivoluzionato il trattamento di disfunzione sessuale maschio verso la fine degli anni 90, un turbine di neve dei test clinici sono stati condotti in donne nelle speranze che le droghe potrebbero fare lo stessi per fare rivivere l'azionamento di sesso diminuente della donna.................



    http://www.medicinaligenerici.com/
    ReplyDelete
  21. The article is excellent, I read it deep and has interesting information. Viewed and very well-organized.
    ReplyDelete
  22. Your post really helped me to understand about this. It has great details and yet it is easy to understand.That's what i was looking for. I will definitely share it with others.Thanks for sharing.
    Customized Essay
    ReplyDelete
  23. Thank you for sharing with useful, good tips. It must to know that outsourced software development services could help in your business by installing customized software solutions.
    ReplyDelete
  24. Great, nice post, I was wondering the same thing and found your site by Google, learned a lot and now I have got some idea. I’ve bookmark your site. Keep us updated.

    online ged programs
    ReplyDelete
  25. Really its very good post.knowledge sharing is the optimum result of knowledge gaining.
    ReplyDelete
  26. I always like to see your blog.And obviously this is a cool one.I’ll be back for sure.
    College Papers
    ReplyDelete
  27. Your post is very interesting information about related topic is awesome. I was finding this type of information from long time. I think you should going on to make this type of blog.
    Escorts in Delhi
    ReplyDelete
  28. Thank you for the article and beautiful it contains useful information and rare
    ReplyDelete
  29. Absolutely wonderful article. I wonder what will ever become of mankind. Seems like that quick and resourceful will outlive all of our smart people :)
    ReplyDelete
  30. Repo RV
    It ends up in auto auctions sometimes as Repo cars for sale. The best part about such cars is that they are almost always in a good condition.
    ReplyDelete
  31. Thanks for a great blog with many interesting posts!
    ReplyDelete
  32. Thank you for the article and beautiful it contains useful information and rare
    ReplyDelete
  33. wow!great full information thanks to shere with me......
    regards,
    online shopping india
    ReplyDelete
  34. Photo Recovery, Media Recovery Software-Image Recovery Software to Recover Deleted Photos By Freshcrop
    ReplyDelete
  35. A lot of thanks for your fresh review. Casino webmasters always look for best casino affiliate programs to increase their revenue income from best casinos or poker rooms.
    ReplyDelete
  36. We appreciate your help. Let me tell you something about cheap home insurance to save your money on house policy.
    ReplyDelete
  37. Thank you for sharing with us online great review. For auto owners who is searching for new cars, compare autoquotes from top car insurance companie
    ReplyDelete
  38. Great work..
    thanks for the useful information...
    ReplyDelete
  39. I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get bought an impatience over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.


    Computer
    ReplyDelete
  40. Open application programming interfaces (APIs) provide a standard interface, allowing third parties to create plug-ins that interact with the host application. A stable API allows third-party plug-ins to continue to function as the original version changes and to extend the life-cycle of obsolete applications.

    Thanks
    Michael
    windows95 computer
    ReplyDelete
  41. Hiya, I’m really glad I have found this information. Nowadays bloggers publish just about gossips and web and this is really frustrating. A good blog with exciting content, that is what I need. Thank you for keeping this site, I will be visiting it. Do you do newsletters? Can’t find it.

    Brand Desktop Computers
    ReplyDelete
  42. It’s a saving you don’t a utilize money add! I’d definitely resign money for this rattling webpage! That i assume for the second being i’ll be mitigated bookmarking with including an individual’s Cater that faculty my soul Msn carry. That i quality impertinent that gift messages and definitely will the web tract utilizing my finest Facebook or cheep team: )


    Computer Store
    ReplyDelete
  43. OK.brilliant.its true..http://howtocarpets.com/
    ReplyDelete
  44. Thank you for this wonderful and beautiful Added
    ReplyDelete
  45. plz check out for online shopping...http://www.yumedeals.com
    ReplyDelete
  46. "We run redmine internally here at Fuery Solutions. Redmine is a fantastic tool for managing software development projects."

    Yeah right. We also use this software and gives us a lot of positive outputs. Great!

    Teressa James
    B12
    ReplyDelete