Hack-proof Your Drupal App. Key Habits of Secure Drupal Coding



Similar documents
Hack-proof Your Drupal App. Key Habits of Secure Drupal Coding

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

(WAPT) Web Application Penetration Testing

Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH January 17, Mega Conference

Web Application Security

Magento Security and Vulnerabilities. Roman Stepanov

Check list for web developers

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

Adobe Systems Incorporated

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

Sitefinity Security and Best Practices

Security Testing with Selenium

WebCruiser Web Vulnerability Scanner User Guide

DIPLOMA IN WEBDEVELOPMENT

Columbia University Web Security Standards and Practices. Objective and Scope

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

Webapps Vulnerability Report

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Drupal Security. A High-Level Perspective on Web Vulnerabilities, Solutions and Tips for Securing Your Drupal Website

Testing the OWASP Top 10 Security Issues

REDCap General Security Overview

Strategic Information Security. Attacking and Defending Web Services

Top Ten Web Application Vulnerabilities in J2EE. Vincent Partington and Eelco Klaver Xebia

OWASP Top Ten Tools and Tactics

Web Application Penetration Testing

OWASP TOP 10 ILIA

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Hacking de aplicaciones Web

Drupal 8. Core and API Changes Shabir Ahmad MS Software Engg. NUST Principal Software Engineser PHP/Drupal

Advanced Web Technology 10) XSS, CSRF and SQL Injection 2

Web Application Security

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

Penetration Testing with Kali Linux

Implementation of Web Application Security Solution using Open Source Gaurav Gupta 1, B. K. Murthy 2, P. N. Barwal 3

Criteria for web application security check. Version

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Columbia University Web Application Security Standards and Practices. Objective and Scope

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

How To Fix A Web Application Security Vulnerability

Relax Everybody: HTML5 Is Securer Than You Think

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Security Research Advisory IBM inotes 9 Active Content Filtering Bypass

NO SQL! NO INJECTION?

Web application security

REDCap Technical Overview

The Top Web Application Attacks: Are you vulnerable?

Where every interaction matters.

Ruby on Rails Secure Coding Recommendations

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Introduction:... 1 Security in SDLC:... 2 Penetration Testing Methodology: Case Study... 3

SQuAD: Application Security Testing

5 Mistakes to Avoid on Your Drupal Website

Hack Yourself First. Troy troyhunt.com

What is Web Security? Motivation

Project 2: Web Security Pitfalls

Nuclear Regulatory Commission Computer Security Office Computer Security Standard

External Network & Web Application Assessment. For The XXX Group LLC October 2012

Development. Resilient Software. Secure and. Mark S. Merkow Lakshmikanth Raghavan. CRC Press. Taylor& Francis Croup. Taylor St Francis Group,

Still Aren't Doing. Frank Kim

WHITE PAPER FORTIWEB WEB APPLICATION FIREWALL. Ensuring Compliance for PCI DSS 6.5 and 6.6

Integrated Network Vulnerability Scanning & Penetration Testing SAINTcorporation.com

No SQL! no injection? A talk on the state of NoSQL security

Architectural Design Patterns. Design and Use Cases for OWASP. Wei Zhang & Marco Morana OWASP Cincinnati, U.S.A.

SECURE APPLICATION DEVELOPMENT CODING POLICY OCIO TABLE OF CONTENTS

Bank Hacking Live! Ofer Maor CTO, Hacktics Ltd. ATC-4, 12 Jun 2006, 4:30PM

Intrusion detection for web applications

Cross Site Scripting Prevention

Web Application Security

Web Application Guidelines

Blackbox Reversing of XSS Filters

Implementation of Web Application Firewall

Web Application Attacks And WAF Evasion

Passing PCI Compliance How to Address the Application Security Mandates

DFW INTERNATIONAL AIRPORT STANDARD OPERATING PROCEDURE (SOP)

Application Security Vulnerabilities, Mitigation, and Consequences

Pentests more than just using the proper tools

Last update: February 23, 2004

Client vs. Server Implementations of Mitigating XSS Security Threats on Web Applications

Hack Proof Your Webapps

Cross Site Scripting in Joomla Acajoom Component

Carlos Muñoz Application Security Engineer WhiteHat

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

FormAPI, AJAX and Node.js

MatriXay WEB Application Vulnerability Scanner V Overview. (DAS- WEBScan ) The best WEB application assessment tool

Cloud Security Framework (CSF): Gap Analysis & Roadmap

ETHICAL HACKING APPLICATIO WIRELESS110 00NETWORK APPLICATION MOBILE MOBILE0001

Transcription:

Hack-proof Your Drupal App Key Habits of Secure Drupal Coding DrupalCamp CT 2010

My Modules Introductions Erich Beyrent http://twitter.com/ebeyrent http://drupal.org/user/23897 Permissions API Search Lucene Biblio Crowd SSO Search Lucene Attachments LDAP Extended Groups Search Lucene OG Visual Search API

Hack-proof Your Drupal App DrupalCamp CT 2010 Agenda Secrets to Securing a Social Network Key Habits of Secure Drupal Coding Vulnerability Detection to Remediation Security Resources for Drupal Applications See For Yourself - demonstrations of application attacks Discussions

Have you ever...

In 2008, I started work on Greenopolis.com It was my first big Drupal project Lots of custom modules Custom theme Prior to launch, a security scan was performed

HILARITY DID NOT ENSUE

The Results 120 vulnerabilities were discovered XSS CSRF SQL Injection Insufficient Authorization

What Was Learned 90% of the vulnerabilities existed in the theme Untrusted data from the query string was used Custom search forms were insecure crossdomain.xml caused vulnerabilities

Fixing The Problems Complete review of the theme, implementing Drupal output filters Code was audited to ensure sanitization of all user data Rewrite of the search forms to sanitize user data Implemented web services proxy

June 2005 March 2010 Source: Drupal Security Report http://drupalsecurityreport.org/

Key Habits of Secure Drupal Coding Wrap your output

Key Habits of Secure Drupal Coding Wrap your output Protect your database

Key Habits of Secure Drupal Coding Wrap your output Protect your database Beware user input

Key Habits of Secure Drupal Coding Wrap your output Protect your database Beware user input AJAX risks

Reality Security experts estimate that 66% of websites are vulnerable to XSS attacks (Jeremiah Grossman, WhiteHat Security)

Reality YouTube (July 2010)

Wrap Your Output check_plain()

check_plain() This is for simple text without any markup. Encodes special characters in a plain-text string for display as HTML. Uses drupal_validate_utf8 to prevent cross site scripting attacks on Internet Explorer 6. Don't use this when using the t(), l(), theme('placeholder')

Wrap Your Output check_plain() check_markup()

check_markup() This is for text which contains markup in some language Runs all the enabled filters on a piece of text.

Wrap Your Output check_plain() check_markup() filter_xss()

filter_xss() Filters an HTML string to prevent cross-site-scripting (XSS) vulnerabilities. Removes characters and constructs that can trick browsers. Makes sure all HTML entities are well-formed. Makes sure all HTML tags and attributes are wellformed. Makes sure no HTML tags contain URLs with a disallowed protocol (e.g. javascript:). Source: http://api.drupal.org/api/function/filter_xss

Wrap Your Output check_plain() check_markup() filter_xss() filter_xss_admin()

filter_xss_admin() Filters an HTML string to prevent cross-site-scripting (XSS) vulnerabilities. Removes characters and constructs that can trick browsers. Makes sure all HTML entities are well-formed. Makes sure all HTML tags and attributes are wellformed. Makes sure no HTML tags contain URLs with a disallowed protocol (e.g. javascript:). Source: http://api.drupal.org/api/function/filter_xss

Protect Your Database db_query()

db_query() Runs a query in the database with arguments to the query, passed in as separate parameters, which are escaped to prevent SQL injection attacks.

db_query() CORRECT: db_query( INSERT INTO {table} VALUES (%d, '%s'), $node- >profile_age, $node- >profile_firstname); WRONG: db_query( SELECT * FROM table WHERE field = $node->profile_age );

Protect Your Database db_query() db_rewrite_sql()

db_rewrite_sql() Rewrites node, taxonomy and comment queries to respect Drupal's node access mechanism. Protects against unauthorized access to content.

db_rewrite_sql() CORRECT: db_query(db_rewrite_sql( SELECT * FROM {node} WHERE uid = %d, $uid)); INCORRECT: db_query( SELECT * FROM {node} WHERE uid = %d, $uid);

Beware User Input Sources of user input: Form fields Uploaded files Query string Other sites

AJAX Risks AJAX transactions are not private Eval() is not 100% safe; use JSONP

Things Good Drupalers Do Sanitize output Use the Form API Use parameterized queries Leave core intact

Things That Will Bite You Printing raw values Modifying data with $_GET Parameterized queries? WTF? Hacking core and killing kittens

Other Common Mistakes <?php global $user; // Bad this will escalate the privileges $user = user_load(array('uid' => $uid));?> <?php global $user; // SAFE do this instead $account = user_load(array('uid' => $uid));?>

Other Common Mistakes Improper URL access Incorrect usage of 'access callback' in hook_menu() Lack of security settings on views Writing forms in HTML Use the Form API to provide automatic CSRF protection

Other Common Mistakes Unvalidated and open redirects Iframes, drupal_goto, location.href Promiscuous crossdomain.xml files

Don't Trust User Input!

Drupal Security Resources http://drupal.org Writing Secure Code (http://drupal.org/writingsecure-code) Handle Text in a Secure Fashion ( http://drupal.org/node/28984) Drupal Security Team

Modules Coder (http://drupal.org/project/coder) Security Review ( http://drupal.org/project/security_review) Secure Code Review ( http://drupal.org/project/secure_code_review) Secure Permissions ( http://drupal.org/project/secure_permissions)

Books Pro Drupal Development book (VanDyk) Cracking Drupal: A Drop in the Bucket (Knaddison) XSS Scripting Attacks (Grossman)

Questions?