Cracking Drupal - ssl http://crackingdrupal.com/taxonomy/term/12/0 en Drupal Security webinar with Acquia roundup http://crackingdrupal.com/blog/greggles/drupal-security-webinar-acquia-roundup <p>This past Thursday several hundred folks joined me for a webinar about security in Drupal as part of the <a href="http://acquia.com/community/resources/webinars/">Acquia webinar</a> series.</p> <p>You can now download the <a href="http://crackingdrupal.com/sites/crackingdrupal.com/files/Acquia_Cracking_Drupal_Webinar.pdf">Security in Drupal introduction slides</a> which include the speaker's notes and watch the screencast itself:</p> <p><embed src="http://blip.tv/play/AYGmjEkC" type="application/x-shockwave-flash" width="480" height="330" allowscriptaccess="always" allowfullscreen="true"></embed></p> <p>I also wanted to answer some questions that were posed in Twitter and in the GoToWebinar chat room. I didn't get to answer all of them in the presentation, so, I'm going to try to answer them all here.</p> <h3>Would you consider something as common as RSS publishing as a potential method for people to steal content?</h3> <p>Not in general. Sure, it makes it easier to copy your content but a determined scraper will always get your data. Now, an rss feed can be an access bypass vulnerability if it doesn't respect Drupal core's node access mechanisms, I have seen that.</p> <h3>What do you tell a client who doesn't want to pay you for your time to perform security updates?</h3> <p>We try to insist on it at the contract stage that as long as they are a development or maintenance client we will do site security upgrades ASAP.</p> <h3>Lots of good information in this presentation. Will you share slides? The zero day attack slide could be really useful.</h3> <p>Yes. The <a href="http://crackingdrupal.com/sites/crackingdrupal.com/files/Acquia_Cracking_Drupal_Webinar.pdf">slides</a> are attached.</p> <h3>It seems like Wysiwyg editors open a lot of vulnerabilties. Are there any modules you feel are more or less vulnerable</h3> <p>WYSIWYG editors don't open the vulnerabilities - bad configuration of input formats does. It's true that many sites will install a WYSIWYG and open up their input formats inappropriately and that's the real problem.</p> <h3>Can you talk a little bit about how his firm performs a site security audit? How long does it take and what is the cost range?</h3> <p>We have some details on our <a href="http://growingventuresolutions.com/services/security-review-service-drupal-sites">security review service</a>. As far as pricing, we'd love to hear your feedback on what kind of price seems good. Please <a href="http://growingventuresolutions.com/contact">contact us</a> to let us know what you think.</p> <h3>In a preprocess function setting up our variables for our designer, do we need to sanitize content in $vars before passing to tpl?</h3> <p>This isn't a simple yes/no kind of question. The answer depends on a lot of factors. While it's not a complete answer either, the <a href="http://crackingdrupal.com/blog/greggles/drupal-text-filtering-decision-cheat-sheet">Text filtering cheat sheet for Drupal</a> is intended to make it easier for an educated developer to decide which function to use.</p> <h3>Forms input filtering is not recommended - that is the problem with Webform Report - why is maintainer unable to fix it?</h3> <p>This has more to do with them having the time/motivation/understanding and nothing to do with how technically feasible it is to fix the problem. It's actually another new service that we're offering is that we will take a module which has been abandoned for security reasons and fix it. If you'd be interested in sponsoring the work to fix that or any other module please let us know.</p> <h3>Can a lot of this security be built into a theme?? Will any of this be corrected in Drupal 7?</h3> <p>The theme layer is not an appropriate place for security protection. Themes can be switched quite easily, by admins and sometimes by end users, so if you put the protection in the theme then it's easy to mistakenly create a vulnerability.</p> <p>Security related code belongs at the module or core layer. Now, Drupal 7 does have a much better rendering system (<a href="http://paris2009.drupalcon.org/session/explore-glory-drupal-7s-improved-render-and-theming-systems">great presentation on render</a> by <a href="http://www.cyrve.com/">Moshe Weitzman</a>) which will hopefully make it easier for themers to not have to think text filtering.</p> <h3>I've read your book (good job, by the way) but it's not for beginners. Are you planning an seochecklist sort of module for security auditing drupal?</h3> <p>Well, I have to disagree ;) I think many parts of it are for beginners. But yes, as part of our security offering we do plan to create many new tools and enhancements to core that will be helpful to site builders.</p> <h3>What are some bad practices for theamers? Are there things that themers can do to make the site more secure?</h3> <p>This is not easy to answer. It's basically the fundamental question that the book answers. However, we do plan another webinar for the spring so perhaps that can be the focus.</p> <h3>Is that a FireFox addon that allows you to change your user agent? What is it called?</h3> <p>Yes, I use the <a href="https://addons.mozilla.org/en-US/firefox/addon/59">User Agent Switcher</a> by <a href="http://chrispederick.com/">Chris Pederick</a>.</p> <h3>Can t() be considered a substitute for check_plain()?</h3> <p>Yes, if you use the @ or % placeholders then t will automatically include check_plain style filtering as the text is substitutde.</p> <h3>How much scrubbing is necessary for FormAPI based forms? Do you risk XSS type attacks without checkplain, for example?</h3> <p>First, all forms should be Form API based (unless they post to an external site, which is very rare). Second, yes, if you use user modifiable text for labels or titles then you will need to do filtering. The exact nature of the filtering depends on a lot of factors</p> <h3>How can we do SSL or HTTPS with Drupal</h3> <p>I just blogged about this recently: <a href="http://crackingdrupal.com/blog/greggles/drupal-and-ssl-multiple-recipes-possible-solutions">Recipes for SSL / HTTPS in Drupal</a>.</p> <p>That's it!</p> http://crackingdrupal.com/blog/greggles/drupal-security-webinar-acquia-roundup#comments https Planet Drupal security ssl Mon, 12 Oct 2009 18:01:12 +0000 greggles 35 at http://crackingdrupal.com Drupal and SSL - Multiple Recipes to Possible Solutions for HTTPS http://crackingdrupal.com/blog/greggles/drupal-and-ssl-multiple-recipes-possible-solutions-https <p>As <a href="http://drupal.org/user/58600">Matt Cheney</a> likes to say "Much like Scrabble, the <em>S</em> is an important letter on the internet." If you really care about the data you are sending across the internet you want to make sure you are using SFTP instead of FTP, SSH instead of Telnet, and HTTPS instead of HTTP. So, within a Drupal site how can you use HTTPS to secure the data sent to and from your site and prevent sessions from being hijacked?</p> <p>There are four basic solutions, though each has its benefits and drawbacks. I'll try to describe each one and give some guidance on the problems. They are covered from what seem to be the most common to the most secure. Note that the third technique is somewhat novel.</p> <p><em>Note: All of these assume that you have configured your webserver to use SSL which is well documented elsewhere - I don't think that's useful to try to cover here.</em></p> <h3>Use the Securepages Module to Encrypt Login and Admin Pages</h3> <p>The <a href="http://drupal.org/project/securepages">Secure Pages</a> module is a relatively old module and quite popular. It's goal is to only make certain pages of the site use HTTPS by using two lists of urls which should either by HTTPS or not. The benefit of this module is that you can use regular old HTTP for most of the site and only encrypt the traffic where you really need it. By default it will encrypt traffic for adding content, editing content, anything related to users, and for the admin area.</p> <p>SSL processing is taxing on a server. Using SSL on just the most important pages helps make sure that the data sent back and forth on those pages is encrypted. However, the session cookie is still unencrypted so a user who authenticates over HTTPS and then visits a non secure page sends their sesssion identifier in the clear which allows for an attacker to steal their session and login to the site which gives them the access to the very data that was supposed to be protected. This is largely "security theater" but it sure makes people feel good.</p> <p><strong>Pro:</strong> Reduces load on server compared to a full SSL solution while encrypting important data transmission.<br /> <strong>Con:</strong> Doesn't protect against session hijacking so data can still be compromised.</p> <h3>Using Securepages and Securepages Prevent Hijack</h3> <p>Noticing this weakness, the user grendzy created the <a href="http://drupal.org/project/securepages_prevent_hijack">Secure Pages Hijack Prevention</a>. This module creates and sends along a second cookie that is marked as "secure" so that the browser will only send it over HTTPS. The module then tracks access to the site and logs out any user who attemps to visit an "important" page without sending along that second cookie.</p> <p><strong>Pro:</strong> Still reduced load on server with reduced damage from hijacking.<br /> <strong>Con:</strong> Session hijack still possible, but limited in what damage can be done and data is still sent in the clear sometimes (may be an acceptable risk).</p> <h3>Use HTTPS for a session after login</h3> <p>This is a solution that one of my clients created to provide HTTPS pages for all logged in users, and keep all anonymous users on HTTP, but could be extended for other rules as well.</p> <p>The major piece of the idea is in settings.php:</p> <p><code><br /> if (!empty($_SERVER['HTTPS'])) {<br /> &nbsp;&nbsp;ini_set('session.cookie_secure', 1);<br /> &nbsp;&nbsp;$base_url = 'https://example.com';<br /> }<br /> else {<br /> &nbsp;&nbsp;$base_url = 'http://example.com';<br /> }<br /> </code></p> <p>This little bit of code says "if the user is requesting a secure page, make sure that their cookie is marked as secure and that the base_url variable (used in many parts of Drupal) includes https - otherwise, use the regular http values." The use of the secure cookie flag prevents hijacking but does have one drawback: If the user has a bookmark for the homepage that is not https then their cookie won't be sent along to the site and they will appear to be logged out.</p> <p>Combine that with a redirect from the regular "user/" pages to the https version and you should be all set.</p> <p><strong>Pro:</strong> Still simple, more complete than a "per path" SSL system, limited possibility to hijack a session.<br /> <strong>Con:</strong> Potentially confusing to users under certain conditions.</p> <h3>Just Make All Drupal Pages SSL</h3> <p>This is the most secure solution, but also the most resource intensive on the server. If you just make all traffic to the site over HTTPS then it will all be encrypted - problem solved!</p> <p>You can use Apache's mod_rewrite to achieve this:</p> <p><code><br /> RewriteCond %{SERVER_PORT} 80<br /> RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]</code></p> <p>php_value session.cookie_secure 1<br /> </p> <p><strong>Pro:</strong> Complete solution. Simple - no extra modules required.<br /> <strong>Con:</strong> May require more expensive servers, or additional servers.</p> <h3>Which Secure Page Solution Is the Best?</h3> <p>The best solution depends on your specific site, end-users, and privacy needs. Many sites don't need to worry about HTTPS at all. Some want to keep performance up as much as possible and only care about the security of the data en-route, but aren't concerned about session-hijacking (e-commerce where the credit card is not stored). As is often the case, you must balance multiple facets when considering the right solution for your site.</p> <p>Got any other solutions? See any other pros or cons with the ideas presented here? Please let me know.</p> http://crackingdrupal.com/blog/greggles/drupal-and-ssl-multiple-recipes-possible-solutions-https#comments https Planet Drupal security theater ssl Mon, 03 Aug 2009 22:35:02 +0000 greggles 25 at http://crackingdrupal.com