SlideShare a Scribd company logo
Secure your Drupal
site by first
hacking into it
Think like a hacker


http://www.flickr.com/photos/31246066@N04/4252587897/
How sites get hacked

XSS

Insecure environment

Stolen access

Outdated code, known vulnerabilities
XSS Demo

           • Malicious Javascript is entered
           • Admin unknowingly executes
           • Javascript alters admin-only settings
            • Changes admin password
            • Puts site offline
http://www.flickr.com/photos/paolo_rosa/5088971947/
https://vimeo.com/15447718
Ben Jeavons
Drupaler for 5 years




Member of Drupal Security Team
@benswords
Drupal vulnerabilities by popularity

                                  12%



                           7%


                      4%

                      3%                                        48%



                       10%




                                   16%




XSS                                 Access Bypass                               CSRF
Authentication/Session              Arbitrary Code Execution                    SQL Injection
Others
             reported in core and contrib SAs from 6/1/2005 through 3/24/2010
Cross Site Scripting
Cross Site Scripting

XSS
Javascript
      Performing actions without your intent
Everything you can do XSS can do faster
Stored XSS Step 1

           Request

Attacker             Drupal   DB
             JS
                              JS
Stored XSS Step 2
         Request



Victim              Drupal   DB
         Response

           JS                JS
Stored XSS Step 3

Victim   Request
                   Drupal   DB

  JS                        JS
$node = node_load($nid);
$title = $node->title;
drupal_set_title($title);
...
(later, in page.tpl.php)
...
<h1><?php print $title; ?></h1>
Fixing XSS


Identify where the data came from
     User input!
user agent
language
time zone
referrer
& more HTTP request headers


Lots of tools/ways to modify
these for requests
Fixing XSS


Identify where the data came from
Is that data being filtered or escaped before
output?
Raw
  Input




Filtered
Output
$node = node_load($nid);
$title = $node->title;
$safe = check_plain($title);
drupal_set_title($safe);
...
(later, in page.tpl.php)
...
<h1><?php print $title; ?></h1>
XSS in Themes

<div class=”stuff”>
<?php
   print $node->field_stuff[0][‘value’];
?>
<div class=”stuff”>
<?php
print $node->field_stuff[0][‘safe’];
// OR
$stuff = $node->field_stuff[0];
print content_format(‘field_stuff’, $stuff);

?>
Sanitize user input for output




$msg = variable_get(‘my_msg’,‘’);

print check_plain($msg);
Test for XSS vulnerability



<script>alert(‘xss yo’)</script>

github.com / unn / vuln
Insecure Environment
Insecure Environment

Lock down your stack
      Admin tools and access to them
Principle of least privilege
      Give out only necessary permissions
Insecure Environment

/devel/variable
/phpMyAdmin
Insecure Environment

Make backups
Test that they work
Secure access to backups
Center for Health
                                                                                        Transformation’s
                                                                                        records were
                                                                                        “found by The New
                                                                                        York Times in an
                                                                                        unsecured archived
                                                                                        version of the site”




http://www.nytimes.com/2011/11/30/us/politics/gingrich-gave-push-to-clients-not-just-ideas.html
http://www.flickr.com/photos/mjb/208218519/
Insecure Environment


/sites/default/files/backup_migrate/
Stolen Access
SSL

Run Drupal on full TLS/SSL

securepages & securepages_prevent_hijack

http://drupalscout.com/node/17

Use a valid certificate
SFTP

“Secure” FTP

Your host should provide it

If not, consider a new one
Stay up-to-date
Stay up-to-date
Know and apply security updates

       Security Advisories

Not just Drupal

       third-party libraries (TinyMCE)

       PHP, operating system
/CHANGELOG.txt
Automation



http://www.flickr.com/photos/hubmedia/2141860216/
Steps to a mostly automated review
   Security Review: drupal.org/project/security_review
   Hacked: drupal.org/project/hacked
   Coder: drupal.org/project/coder
   Secure Code Review
       drupal.org/project/secure_code_review
   Vuln: github.com/unn/vuln
   More: http://drupalscout.com/node/11
in-depth, hands-on security training
            drupalcon.org
      bit.ly/drupalcon-security
Read

  drupal.org/security/writing-secure-code

  drupalscout.com

  crackingdrupal.com

Converse

  groups.drupal.org/best-practices-drupal-security

  ben.jeavons@acquia.com

  @benswords

More Related Content

What's hot

Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13
drewz lin
 
Security Testing - Zap It
Security Testing - Zap ItSecurity Testing - Zap It
Security Testing - Zap It
Manjyot Singh
 

What's hot (20)

Advanced Client Side Exploitation Using BeEF
Advanced Client Side Exploitation Using BeEFAdvanced Client Side Exploitation Using BeEF
Advanced Client Side Exploitation Using BeEF
 
Big problems with big data – Hadoop interfaces security
Big problems with big data – Hadoop interfaces securityBig problems with big data – Hadoop interfaces security
Big problems with big data – Hadoop interfaces security
 
DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)
 
I got 99 trends and a # is all of them
I got 99 trends and a # is all of themI got 99 trends and a # is all of them
I got 99 trends and a # is all of them
 
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
How to Shot Web - Jason Haddix at DEFCON 23 - See it Live: Details in Descrip...
 
Ten Commandments of Secure Coding
Ten Commandments of Secure CodingTen Commandments of Secure Coding
Ten Commandments of Secure Coding
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13
 
Nessus and Reporting Karma
Nessus and Reporting KarmaNessus and Reporting Karma
Nessus and Reporting Karma
 
Devouring Security XML Attack surface and Defences
Devouring Security XML Attack surface and DefencesDevouring Security XML Attack surface and Defences
Devouring Security XML Attack surface and Defences
 
Web security for developers
Web security for developersWeb security for developers
Web security for developers
 
Security Testing - Zap It
Security Testing - Zap ItSecurity Testing - Zap It
Security Testing - Zap It
 
Drupal Security Intro
Drupal Security IntroDrupal Security Intro
Drupal Security Intro
 
Html5 hacking
Html5 hackingHtml5 hacking
Html5 hacking
 
Entity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applicationsEntity provider selection confusion attacks in JAX-RS applications
Entity provider selection confusion attacks in JAX-RS applications
 
Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12Top Ten Web Application Defenses v12
Top Ten Web Application Defenses v12
 
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017 OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017
 
Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017Browser Serving Your Web Application Security - NorthEast PHP 2017
Browser Serving Your Web Application Security - NorthEast PHP 2017
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 
Cross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaCross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with Java
 

Similar to Hack Into Drupal Sites (or, How to Secure Your Drupal Site)

Owasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet OverviewOwasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet Overview
owaspindy
 
Slides
SlidesSlides
Slides
vti
 

Similar to Hack Into Drupal Sites (or, How to Secure Your Drupal Site) (20)

(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon
(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon
(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon
 
Romulus OWASP
Romulus OWASPRomulus OWASP
Romulus OWASP
 
Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014
 
Xebia Knowledge Exchange - Owasp Top Ten
Xebia Knowledge Exchange - Owasp Top TenXebia Knowledge Exchange - Owasp Top Ten
Xebia Knowledge Exchange - Owasp Top Ten
 
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More SecureLow Hanging Fruit, Making Your Basic MongoDB Installation More Secure
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
 
End to end web security
End to end web securityEnd to end web security
End to end web security
 
Information Security Engineering
Information Security EngineeringInformation Security Engineering
Information Security Engineering
 
Owasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet OverviewOwasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet Overview
 
Outlook and Exchange for the bad guys
Outlook and Exchange for the bad guysOutlook and Exchange for the bad guys
Outlook and Exchange for the bad guys
 
RSA APJ Velociraptor Lab
RSA APJ Velociraptor LabRSA APJ Velociraptor Lab
RSA APJ Velociraptor Lab
 
Toni de la Fuente - Automate or die! How to survive to an attack in the Cloud...
Toni de la Fuente - Automate or die! How to survive to an attack in the Cloud...Toni de la Fuente - Automate or die! How to survive to an attack in the Cloud...
Toni de la Fuente - Automate or die! How to survive to an attack in the Cloud...
 
Automate or die! Rootedcon 2017
Automate or die! Rootedcon 2017Automate or die! Rootedcon 2017
Automate or die! Rootedcon 2017
 
Slides
SlidesSlides
Slides
 
WebApps_Lecture_15.ppt
WebApps_Lecture_15.pptWebApps_Lecture_15.ppt
WebApps_Lecture_15.ppt
 
It's a Dangerous World
It's a Dangerous World It's a Dangerous World
It's a Dangerous World
 
HTML5 Security
HTML5 SecurityHTML5 Security
HTML5 Security
 
CRESTCon Asia 2018 - Config Password Encryption Gone Wrong
CRESTCon Asia 2018 - Config Password Encryption Gone WrongCRESTCon Asia 2018 - Config Password Encryption Gone Wrong
CRESTCon Asia 2018 - Config Password Encryption Gone Wrong
 
Do you lose sleep at night?
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?
 
Building Client-Side Attacks with HTML5 Features
Building Client-Side Attacks with HTML5 FeaturesBuilding Client-Side Attacks with HTML5 Features
Building Client-Side Attacks with HTML5 Features
 
The DNSSEC KSK of the root rolls
The DNSSEC KSK of the root rollsThe DNSSEC KSK of the root rolls
The DNSSEC KSK of the root rolls
 

More from nyccamp

Drupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better ThemesDrupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better Themes
nyccamp
 
Building Social Networks
Building Social NetworksBuilding Social Networks
Building Social Networks
nyccamp
 
Building Social Networks
Building Social NetworksBuilding Social Networks
Building Social Networks
nyccamp
 
Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)
nyccamp
 

More from nyccamp (19)

Drupal As A Jigsaw
Drupal As A JigsawDrupal As A Jigsaw
Drupal As A Jigsaw
 
A/B Testing and Optimizely Module
A/B Testing and Optimizely ModuleA/B Testing and Optimizely Module
A/B Testing and Optimizely Module
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testing
 
ALL YOUR BASE (THEMES) ARE BELONG TO US
ALL YOUR BASE (THEMES) ARE BELONG TO USALL YOUR BASE (THEMES) ARE BELONG TO US
ALL YOUR BASE (THEMES) ARE BELONG TO US
 
Drupal Commerce - The Product vs Display Conundrum and How to Explain it to a...
Drupal Commerce - The Product vs Display Conundrum and How to Explain it to a...Drupal Commerce - The Product vs Display Conundrum and How to Explain it to a...
Drupal Commerce - The Product vs Display Conundrum and How to Explain it to a...
 
Promotions Vouchers and Offers in Drupal Commerce
Promotions Vouchers and Offers in Drupal CommercePromotions Vouchers and Offers in Drupal Commerce
Promotions Vouchers and Offers in Drupal Commerce
 
Workbench: Managing Content Management
Workbench: Managing Content ManagementWorkbench: Managing Content Management
Workbench: Managing Content Management
 
Deployment Strategies: Managing Code, Content, and Configurations
Deployment Strategies: Managing Code, Content, and ConfigurationsDeployment Strategies: Managing Code, Content, and Configurations
Deployment Strategies: Managing Code, Content, and Configurations
 
Drupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better ThemesDrupal Aware Design: Good Techniques for Better Themes
Drupal Aware Design: Good Techniques for Better Themes
 
Drupal and Higher Education
Drupal and Higher EducationDrupal and Higher Education
Drupal and Higher Education
 
A New Theme Layer for Drupal 8
A New Theme Layer for Drupal 8A New Theme Layer for Drupal 8
A New Theme Layer for Drupal 8
 
Mobile and Responsive Design with Sass
Mobile and Responsive Design with SassMobile and Responsive Design with Sass
Mobile and Responsive Design with Sass
 
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your SiteDrupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
 
Building Social Networks
Building Social NetworksBuilding Social Networks
Building Social Networks
 
The State of Drupal 8
The State of Drupal 8The State of Drupal 8
The State of Drupal 8
 
Building Social Networks
Building Social NetworksBuilding Social Networks
Building Social Networks
 
Move Into Drupal Using The Migrate Module
Move Into Drupal Using The Migrate ModuleMove Into Drupal Using The Migrate Module
Move Into Drupal Using The Migrate Module
 
Drulenium - Testing Made Easy
Drulenium - Testing Made EasyDrulenium - Testing Made Easy
Drulenium - Testing Made Easy
 
Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)Node Access in Drupal 7 (and Drupal 8)
Node Access in Drupal 7 (and Drupal 8)
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 

Hack Into Drupal Sites (or, How to Secure Your Drupal Site)