SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
Drupal security
             Gábor Hojtsy , Acquia




   February 27. 2010, Drupalcamp Bratislava
With special thanks to Four Kitchens, Greg Knaddison and Jakub Suchy
Why I’m here?

• Stepping in for Jakub Suchy
• Co-maintainer to Drupal 6
• De-facto member of the security team
Are you affected?
With relatively simple holes,
your administrator user can
be taken over.
Open Web Application
           Security Project’s
              Top 10 risks
http://www.owasp.org/images/0/0f/OWASP_T10_-_2010_rc1.pdf
Security misconfiguration
Secure server

• Avoid using FTP at all cost (Total
  Commander is the enemy)
• Who do you share your server with? Are
  you confident?
• Keep your OS, PHP, SQL server, etc. up
  to date
Secure Drupal

• Is your admin password “admin”?
• Look at all “administer *” permissions
• “administer filters” can take over a site
• Use update.module, watch the security
  news (Wednesdays)
Secure Drupal

• Avoid any kind of PHP input, write your
  own modules instead
• Watch your input formats (you can be
  googled)
Injection
index.php?id=12


mysql_query(“UPDATE mytable
SET value = ‘”. $value .”’
WHERE id = ”. $_GET[‘id’]);
Drupal approach

• db_query(“UPDATE {mytable} SET
  value = ‘%s’ WHERE id = %d”, $value,
  $id);
• If you need to include dynamic table or
  column names in your query, see
  db_escape_table()
Cross Site Scripting (XSS)
index.php?id=12
print $_GET[‘id’];


$output .= $node->title;
Giving full HTML access.
66%
  likeliness a website has
 Cross site scripting issues
http://www.whitehatsec.com/home/assets/presentations/09PPT/PPT_statsfall09_8th.pdf
jQuery.get('/user/1/edit',
   function (data, status) {
     if (status == 'success') {
       var p = /id="edit-user-edit-form-token"
value="([a-z0-9]*)"/;
       var matches = data.match(p);
       var token = matches[1];
       var payload = {
          "form_id": 'user_edit',
          "form_token": token,
          "pass[pass1]": 'hacked',
          "pass[pass2]": 'hacked'
       };
       jQuery.post('/user/1/edit', payload);
     }
   }
);

                 Example from Heine Deelstra, Drupal Security team lead
                  http://heine.familiedeelstra.com/change-password-xss
Drupal approach

• check_plain() to escape text to HTML
• check_markup() to format text to HTML
• filter_xss() to filter text to HTML
• filter_xss_admin() to filter admin text to HTML
• node_view($node) instead of $node->body
Drupal approach
• t(), format_plural() placeholders:
  %name, @url, !insecure

  t(‘%name has a blog at <a
  href=”@url”>@url</a>’, array(‘@url’ =>
  valid_url($user->profile_blog), ‘%name’
  => $user->name));
• Use Drupal.t(), Drupal.formatPlural() in JS.
Authentication
 & sessions
• Weak password storage and
 account management
• Session hijacking / fixation
• Lack of session timeout /
 logout
Drupal approach

• Passwords are stored encrypted
• Session IDs changed when permissions
  change
• Drupal works with Apache’s SSL transport
• Modules to set certain URLs to use SSL
Common problem

global $user;
// ....
$user = user_load($uid);
Proper solution

global $user;
// ....
$account = user_load($uid);
Insecure direct object references
index.php?id=12


db_query(“SELECT * FROM {user}
WHERE id = %d”, $_GET[‘id’]);
Drupal approach
• Menu system handles permission checking
• user_access(‘administer nodes’, $account)
• node_access(‘edit’, $node, $account);
• db_query(db_rewrite_sql(‘SELECT title
  FROM {node} n’));
• Form API checks for data validity
Cross Site Request
 Forgery (CSRF)
http://example.com/index.php?
delete=12


<img src=”http://example.com/
index.php?delete=12” />
Drupal approach
• Form API works with POST submissions
  by default (makes it harder)
• Form API includes form tokens, requires
  form retrieval before submission, checks
  valid values
• drupal_valid_token() provided to
  generate/validate tokens for GET requests
Failure to restrict
   URL access
Drupal approach


• Menu system uses access callback and
  access arguments
• Continually review permissions
Common problem
$items[‘myitem’] = array(
     ‘page callback’ => ‘myfunc’,
  ‘access callback’ =>
user_access(‘access content’),
);
Proper solution
$items[‘myitem’] = array(
     ‘page callback’ => ‘myfunc’,
  ‘access callback’ =>
‘user_access’,
  ‘access arguments’ => array
(‘access content’),
);
Unvalidated
redirections
http://example.com/index.php?
target=evil.com
Drupal approach

• Drupal has various internal
  redirections, which use local paths and
  generate URLs based on them
• Look for use of drupal_goto() and Form
  API #redirect instances in your
  modules to validate their compliance
Insecure cryptographic storage
Drupal approach
• Drupal stores user passwords encrypted
  with a one-way hash
• Different randomly generated private
  key is provided on each site, which can
  be used to do reversible encryption
• Up to you to ensure backups are
  properly protected
Insufficient transport protection
Drupal approach
• Run Drupal on top of full SSL
• Use securepages and
  securepages_prevent_hijack to wall
  your important pages
• http://crackingdrupal.com/blog/
  greggles/drupal-and-ssl-multiple-
  recipes-possible-solutions
• Use a valid certificate
Is Open Source
    secure?
“Open Source is
       secure”

• Open Source makes people look at it
• Popularity gets more eyes
• There are always more smart people to
  find and fix problems
“Open Source is
       insecure”
• People can equally find holes
• Some people (inadvertently) disclose
  issues in the public
• Fix becomes public and can / will be
  reviewed
Is Drupal secure?
Developers and users
• Drupal APIs are designed to be secure
• It is eventually up to programmers to
  use them that way
• http://drupal.org/writing-secure-code
• Tools designed for security can still be
  misconfigured
Drupal security team


A team of volunteers working to ensure
best security of Drupal and thousands of
contributed modules
Design. Educate. Fix.
What’s supported?
• Drupal core and all(!) contributed
  project on drupal.org
• Not actively looking for vulnerabilities
  in contributed modules
• Stable releases and development
  versions (for very popular modules)
• Only current and one earlier versions
  are supported: now 6.x, 5.x
Points of contact

• Releases at http://drupal.org/security
• Reporting issues: http://drupal.org/
  node/101494
• Reporting cracked sites: http://
  drupal.org/node/213320
These slides are (CC)
                       Images used:
       http://www.flickr.com/photos/rtv/2398561954/
       http://www.flickr.com/photos/jonk/19422564/
     http://www.flickr.com/photos/duncan/2693141693/
     http://www.flickr.com/photos/duncan/2742371814
 http://www.flickr.com/photos/jontintinjordan/3736095793/
    http://www.flickr.com/photos/djbrady/2304740173/
    http://www.flickr.com/photos/inkytwist/2654071573/
     http://www.flickr.com/photos/duncan/2741594585/
  http://www.flickr.com/photos/shellysblogger/2924699161/
  http://www.flickr.com/photos/blogumentary/434097609/
    http://www.flickr.com/photos/glamhag/2214986176/
     http://www.flickr.com/photos/duncan/2693140217/




This presentation is © Gábor Hojtsy
Licensed: Licensed: http://creativecommons.org/licenses/by-nc-sa/2.0/
Questions?
Thank you!
 Gábor Hojtsy, Acquia
http://twitter.com/gaborhojtsy

Más contenido relacionado

La actualidad más candente

Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
kevinvw
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
jeresig
 
HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010
alanburke
 
Real World REST with Atom/AtomPub
Real World REST with Atom/AtomPubReal World REST with Atom/AtomPub
Real World REST with Atom/AtomPub
Peter Keane
 
Fronttechnieken met HTML5 en de Slice-template
Fronttechnieken met HTML5 en de Slice-templateFronttechnieken met HTML5 en de Slice-template
Fronttechnieken met HTML5 en de Slice-template
Inventis Web Architects
 
WordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practices
ryanduff
 

La actualidad más candente (20)

Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Front End Web Development Basics
Front End Web Development BasicsFront End Web Development Basics
Front End Web Development Basics
 
Web Ninja
Web NinjaWeb Ninja
Web Ninja
 
Css
CssCss
Css
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
Html5 Brown Bag
Html5 Brown BagHtml5 Brown Bag
Html5 Brown Bag
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
 
SilverStripe From a Developer's Perspective
SilverStripe From a Developer's PerspectiveSilverStripe From a Developer's Perspective
SilverStripe From a Developer's Perspective
 
Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016Tech Gupshup Meetup On MongoDB - 24/06/2016
Tech Gupshup Meetup On MongoDB - 24/06/2016
 
doing_it_right() with WordPress
doing_it_right() with WordPressdoing_it_right() with WordPress
doing_it_right() with WordPress
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
 
HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010HTML 5 Drupalcamp Ireland Dublin 2010
HTML 5 Drupalcamp Ireland Dublin 2010
 
Real World REST with Atom/AtomPub
Real World REST with Atom/AtomPubReal World REST with Atom/AtomPub
Real World REST with Atom/AtomPub
 
Fronttechnieken met HTML5 en de Slice-template
Fronttechnieken met HTML5 en de Slice-templateFronttechnieken met HTML5 en de Slice-template
Fronttechnieken met HTML5 en de Slice-template
 
iOS & Drupal
iOS & DrupaliOS & Drupal
iOS & Drupal
 
Building Web Sites that Work Everywhere
Building Web Sites that Work EverywhereBuilding Web Sites that Work Everywhere
Building Web Sites that Work Everywhere
 
Extending Stash - Jason Hinch
Extending Stash - Jason HinchExtending Stash - Jason Hinch
Extending Stash - Jason Hinch
 
WordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practices
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 

Similar a Drupal Security from Drupalcamp Bratislava

Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
Drupalcon Paris
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 

Similar a Drupal Security from Drupalcamp Bratislava (20)

Drupal security
Drupal securityDrupal security
Drupal security
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
Drupal Security Hardening
Drupal Security HardeningDrupal Security Hardening
Drupal Security Hardening
 
Drupal Security Hardening
Drupal Security HardeningDrupal Security Hardening
Drupal Security Hardening
 
Drupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentDrupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal Development
 
OWASP Top 10 vs Drupal - OWASP Benelux 2012
OWASP Top 10 vs Drupal - OWASP Benelux 2012OWASP Top 10 vs Drupal - OWASP Benelux 2012
OWASP Top 10 vs Drupal - OWASP Benelux 2012
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
Drupal security
Drupal securityDrupal security
Drupal security
 
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICESONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Rails Security
Rails SecurityRails Security
Rails Security
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
Django Overview
Django OverviewDjango Overview
Django Overview
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Making Joomla Insecure - Explaining security by breaking it
Making Joomla Insecure - Explaining security by breaking itMaking Joomla Insecure - Explaining security by breaking it
Making Joomla Insecure - Explaining security by breaking it
 

Más de Gábor Hojtsy

Más de Gábor Hojtsy (17)

Open source project management at scale
 Open source project management at scale Open source project management at scale
Open source project management at scale
 
Drupal 8.3.0: the features are ready, are you?
Drupal 8.3.0: the features are ready, are you?Drupal 8.3.0: the features are ready, are you?
Drupal 8.3.0: the features are ready, are you?
 
Drupal 8 multilingual APIs
Drupal 8 multilingual APIsDrupal 8 multilingual APIs
Drupal 8 multilingual APIs
 
A Drupal 8 jövője és az oda vezető út
A Drupal 8 jövője és az oda vezető útA Drupal 8 jövője és az oda vezető út
A Drupal 8 jövője és az oda vezető út
 
Everything multilingual in Drupal 8
Everything multilingual in Drupal 8Everything multilingual in Drupal 8
Everything multilingual in Drupal 8
 
Everything multilingual in Drupal 8 (2015 November)
Everything multilingual in Drupal 8 (2015 November)Everything multilingual in Drupal 8 (2015 November)
Everything multilingual in Drupal 8 (2015 November)
 
All the language support in Drupal 8 - At Drupalaton 2014
All the language support in Drupal 8 - At Drupalaton 2014All the language support in Drupal 8 - At Drupalaton 2014
All the language support in Drupal 8 - At Drupalaton 2014
 
Drupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward toDrupal 8 Multilingual - what to look forward to
Drupal 8 Multilingual - what to look forward to
 
Multilingual Drupal
Multilingual DrupalMultilingual Drupal
Multilingual Drupal
 
Drupal security - Configuration and process
Drupal security - Configuration and processDrupal security - Configuration and process
Drupal security - Configuration and process
 
Backstage with Drupal localization - Part 1
Backstage with Drupal localization - Part 1Backstage with Drupal localization - Part 1
Backstage with Drupal localization - Part 1
 
Come for the software, stay for the community
Come for the software, stay for the communityCome for the software, stay for the community
Come for the software, stay for the community
 
Come for the software, stay for the community - How Drupal improves and evolves
Come for the software, stay for the community - How Drupal improves and evolvesCome for the software, stay for the community - How Drupal improves and evolves
Come for the software, stay for the community - How Drupal improves and evolves
 
Here comes localize.drupal.org!
Here comes localize.drupal.org!Here comes localize.drupal.org!
Here comes localize.drupal.org!
 
Translate Drupal from Drupalcamp Vienna
Translate Drupal from Drupalcamp ViennaTranslate Drupal from Drupalcamp Vienna
Translate Drupal from Drupalcamp Vienna
 
Translate Drupal from Drupalcamp Prague
Translate Drupal from Drupalcamp PragueTranslate Drupal from Drupalcamp Prague
Translate Drupal from Drupalcamp Prague
 
Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"Multilingual Drupal presentation from "Do it With Drupal"
Multilingual Drupal presentation from "Do it With Drupal"
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Drupal Security from Drupalcamp Bratislava

  • 1. Drupal security Gábor Hojtsy , Acquia February 27. 2010, Drupalcamp Bratislava With special thanks to Four Kitchens, Greg Knaddison and Jakub Suchy
  • 2. Why I’m here? • Stepping in for Jakub Suchy • Co-maintainer to Drupal 6 • De-facto member of the security team
  • 4. With relatively simple holes, your administrator user can be taken over.
  • 5. Open Web Application Security Project’s Top 10 risks http://www.owasp.org/images/0/0f/OWASP_T10_-_2010_rc1.pdf
  • 7. Secure server • Avoid using FTP at all cost (Total Commander is the enemy) • Who do you share your server with? Are you confident? • Keep your OS, PHP, SQL server, etc. up to date
  • 8. Secure Drupal • Is your admin password “admin”? • Look at all “administer *” permissions • “administer filters” can take over a site • Use update.module, watch the security news (Wednesdays)
  • 9. Secure Drupal • Avoid any kind of PHP input, write your own modules instead • Watch your input formats (you can be googled)
  • 11. index.php?id=12 mysql_query(“UPDATE mytable SET value = ‘”. $value .”’ WHERE id = ”. $_GET[‘id’]);
  • 12. Drupal approach • db_query(“UPDATE {mytable} SET value = ‘%s’ WHERE id = %d”, $value, $id); • If you need to include dynamic table or column names in your query, see db_escape_table()
  • 14. index.php?id=12 print $_GET[‘id’]; $output .= $node->title; Giving full HTML access.
  • 15. 66% likeliness a website has Cross site scripting issues http://www.whitehatsec.com/home/assets/presentations/09PPT/PPT_statsfall09_8th.pdf
  • 16. jQuery.get('/user/1/edit', function (data, status) { if (status == 'success') { var p = /id="edit-user-edit-form-token" value="([a-z0-9]*)"/; var matches = data.match(p); var token = matches[1]; var payload = { "form_id": 'user_edit', "form_token": token, "pass[pass1]": 'hacked', "pass[pass2]": 'hacked' }; jQuery.post('/user/1/edit', payload); } } ); Example from Heine Deelstra, Drupal Security team lead http://heine.familiedeelstra.com/change-password-xss
  • 17. Drupal approach • check_plain() to escape text to HTML • check_markup() to format text to HTML • filter_xss() to filter text to HTML • filter_xss_admin() to filter admin text to HTML • node_view($node) instead of $node->body
  • 18. Drupal approach • t(), format_plural() placeholders: %name, @url, !insecure t(‘%name has a blog at <a href=”@url”>@url</a>’, array(‘@url’ => valid_url($user->profile_blog), ‘%name’ => $user->name)); • Use Drupal.t(), Drupal.formatPlural() in JS.
  • 20. • Weak password storage and account management • Session hijacking / fixation • Lack of session timeout / logout
  • 21. Drupal approach • Passwords are stored encrypted • Session IDs changed when permissions change • Drupal works with Apache’s SSL transport • Modules to set certain URLs to use SSL
  • 22. Common problem global $user; // .... $user = user_load($uid);
  • 23. Proper solution global $user; // .... $account = user_load($uid);
  • 25. index.php?id=12 db_query(“SELECT * FROM {user} WHERE id = %d”, $_GET[‘id’]);
  • 26. Drupal approach • Menu system handles permission checking • user_access(‘administer nodes’, $account) • node_access(‘edit’, $node, $account); • db_query(db_rewrite_sql(‘SELECT title FROM {node} n’)); • Form API checks for data validity
  • 27. Cross Site Request Forgery (CSRF)
  • 29. Drupal approach • Form API works with POST submissions by default (makes it harder) • Form API includes form tokens, requires form retrieval before submission, checks valid values • drupal_valid_token() provided to generate/validate tokens for GET requests
  • 30. Failure to restrict URL access
  • 31. Drupal approach • Menu system uses access callback and access arguments • Continually review permissions
  • 32. Common problem $items[‘myitem’] = array( ‘page callback’ => ‘myfunc’, ‘access callback’ => user_access(‘access content’), );
  • 33. Proper solution $items[‘myitem’] = array( ‘page callback’ => ‘myfunc’, ‘access callback’ => ‘user_access’, ‘access arguments’ => array (‘access content’), );
  • 36. Drupal approach • Drupal has various internal redirections, which use local paths and generate URLs based on them • Look for use of drupal_goto() and Form API #redirect instances in your modules to validate their compliance
  • 38. Drupal approach • Drupal stores user passwords encrypted with a one-way hash • Different randomly generated private key is provided on each site, which can be used to do reversible encryption • Up to you to ensure backups are properly protected
  • 40. Drupal approach • Run Drupal on top of full SSL • Use securepages and securepages_prevent_hijack to wall your important pages • http://crackingdrupal.com/blog/ greggles/drupal-and-ssl-multiple- recipes-possible-solutions • Use a valid certificate
  • 41. Is Open Source secure?
  • 42. “Open Source is secure” • Open Source makes people look at it • Popularity gets more eyes • There are always more smart people to find and fix problems
  • 43. “Open Source is insecure” • People can equally find holes • Some people (inadvertently) disclose issues in the public • Fix becomes public and can / will be reviewed
  • 45. Developers and users • Drupal APIs are designed to be secure • It is eventually up to programmers to use them that way • http://drupal.org/writing-secure-code • Tools designed for security can still be misconfigured
  • 46. Drupal security team A team of volunteers working to ensure best security of Drupal and thousands of contributed modules
  • 48. What’s supported? • Drupal core and all(!) contributed project on drupal.org • Not actively looking for vulnerabilities in contributed modules • Stable releases and development versions (for very popular modules) • Only current and one earlier versions are supported: now 6.x, 5.x
  • 49. Points of contact • Releases at http://drupal.org/security • Reporting issues: http://drupal.org/ node/101494 • Reporting cracked sites: http:// drupal.org/node/213320
  • 50.
  • 51. These slides are (CC) Images used: http://www.flickr.com/photos/rtv/2398561954/ http://www.flickr.com/photos/jonk/19422564/ http://www.flickr.com/photos/duncan/2693141693/ http://www.flickr.com/photos/duncan/2742371814 http://www.flickr.com/photos/jontintinjordan/3736095793/ http://www.flickr.com/photos/djbrady/2304740173/ http://www.flickr.com/photos/inkytwist/2654071573/ http://www.flickr.com/photos/duncan/2741594585/ http://www.flickr.com/photos/shellysblogger/2924699161/ http://www.flickr.com/photos/blogumentary/434097609/ http://www.flickr.com/photos/glamhag/2214986176/ http://www.flickr.com/photos/duncan/2693140217/ This presentation is © Gábor Hojtsy Licensed: Licensed: http://creativecommons.org/licenses/by-nc-sa/2.0/
  • 53. Thank you! Gábor Hojtsy, Acquia http://twitter.com/gaborhojtsy