Top 10 Defenses for Website Security Jim Manico VP of Security Architecture July 2012.

Slides:



Advertisements
Similar presentations
February 2012 Top Ten Controls v1 Eoin Keary and Jim Manico Page 1 OWASP Foundation – Los Angeles Chapter
Advertisements

Nick Feamster CS 6262 Spring 2009
Webgoat.
Past, Present and Future By Eoin Keary and Jim Manico
Past, Present and Future
March 2012 Top Ten Controls v4.2 Jim Manico and Eoin Keary Page 1 Top 10 Web Security Controls.
SEC835 OWASP Top Ten Project.
0 The Past, Present and Future of XSS Defense Jim Manico 2011 OWASP Brussels.
APPLICATION DEVELOPMENT SECURE CODING WORKSHOP JIM MANICO VP, Security Architecture MARCH 2013.
Top 10 Defenses for Website Security Jim Manico VP Security Architecture.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
1 Page © 2012 WhiteHat Security, Inc. 1 Top 10 Defenses for Website Security Jim Manico VP of Security Architecture June 2012.
The XSS Files Find, Exploit, and Eliminate. Josh Little Security Engineer at global vertical market business intelligence company. 9 years in application.
COMP 321 Week 12. Overview Web Application Security  Authentication  Authorization  Confidentiality Cross-Site Scripting Lab 12-1 Introduction.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
Web App Access Control Design
Introduction to the OWASP Top 10. Cross Site Scripting (XSS)  Comes in several flavors:  Stored  Reflective  DOM-Based.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
The OWASP Foundation Cross Site Scripting JavaScript Injection Contextual Output Encoding.
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
Top Ten Proactive Web Application Defenses Top Five Proactive Mobile Controls.
The OWASP Foundation Injection Flaws.
Top Ten Proactive Web Application Controls. Jim OWASP Volunteer - Global OWASP Board Member - OWASP Cheat-Sheet Series Project Manager.
Workshop 3 Web Application Security Li Weichao March
OWASP Zed Attack Proxy Project Lead
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Cross-Site Scripting Vulnerabilities Adam Doupé 11/24/2014.
Origins, Cookies and Security – Oh My! John Kemp, Nokia Mobile Solutions.
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
+ Websites Vulnerabilities. + Content Expand of The Internet Use of the Internet Examples Importance of the Internet How to find Security Vulnerabilities.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
Ladd Van Tol Senior Software Engineer Security on the Web Part One - Vulnerabilities.
© All rights reserved. Zend Technologies, Inc. PHP Security Kevin Schroeder Zend Technologies.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 1 Top 10 Web Security Controls.
Oracle Application Express Security. © 2009 Oracle Corporation Authentication Out-of-the-Box Pre-Configured Schemes LDAP Directory credentials Oracle.
Secure Credential Manager Claes Nilsson - Sony Ericsson
Feedback #2 (under assignments) Lecture Code:
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Srikar Nadipally. Outline Finding and Exploiting XSS Vulnerabilities Standard Reflected XSS Stored XSS DOM based XSS Prevention of XSS attack Reflect.
Cross-Site Attacks James Walden Northern Kentucky University.
OWASP Top 10 from a developer’s perspective John Wilander, OWASP/Omegapoint, IBWAS’10.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
SEC835 Runtime authentication Secure session management Secure use of cryptomaterials.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Web Applications Testing By Jamie Rougvie Supported by.
Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking SoftUni Team Technical Trainers Software University
University of Central Florida The Postman Always Rings Twice: Attacking & Defending postMessage in HTML5 Websites Ankur Verma University of Central Florida,
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
OWASP Building Secure Web Applications And the OWASP top 10 vulnerabilities.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Securing Angular Apps Brian Noyes
Copyright © The OWASP Foundation This work is available under the Creative Commons SA 2.5 license The OWASP Foundation OWASP Denver February 2012.
Intro to Web Application Security. iHostCodex Web Services - CEO Project-AG – CoFounder OWASP Panay -Chapter Leader -Web Application Pentester -Ethical.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
ASP.NET 2.0 Security Alex Mackman CM Group Ltd
Do not try any of the techniques discussed in this presentation on a system you do not own. It is illegal and you will get caught.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Building Secure ColdFusion Applications
Web Application Vulnerabilities
An Introduction to Web Application Security
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
TOPIC: Web Security (Part-4)
WWW安全 國立暨南國際大學 資訊管理學系 陳彥錚.
Presentation transcript:

Top 10 Defenses for Website Security Jim Manico VP of Security Architecture July 2012

Jim VP of Security Architecture, WhiteHat Security 15 years of web-based, database-driven software development and analysis experience Over 7 years as a provider of secure developer training courses for SANS, Aspect Security and others Running for the OWASP Board 2013Running for the OWASP Board 2013 OWASP Connections Committee ChairOWASP Connections Committee Chair - - OWASP Podcast Series Producer/Host - OWASP Cheat-Sheet Series Manager

Query Parameterization (PHP PDO) $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)"); $stmt->bindParam(':name', $name); $stmt->bindParam(':value', $value); [1][1]

Query Parameterization (.NET) SqlConnection objConnection = new SqlConnection(_ConnectionString); objConnection.Open(); SqlCommand objCommand = new SqlCommand( "SELECT * FROM User WHERE Name AND Password objConnection); NameTextBox.Text); PassTextBox.Text); SqlDataReader objReader = objCommand.ExecuteReader();

Query Parameterization (Java) String newName = request.getParameter("newName") ; String id = request.getParameter("id"); //SQL PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET NAME = ? WHERE ID = ?"); pstmt.setString(1, newName); pstmt.setString(2, id); //HQL Query safeHQLQuery = session.createQuery("from Employees where id=:empId"); safeHQLQuery.setParameter("empId", id);

Query Parameterization (Ruby) # Create Project.create!(:name => 'owasp') # Read Project.all(:conditions => "name = ?", name) Project.all(:conditions => { :name => name }) Project.where("name = :name", :name => name) Project.where(:id=> params[:id]).all # Update project.update_attributes(:name => 'owasp')

Query Parameterization Fail (Ruby) # Create Project.create!(:name => 'owasp') # Read Project.all(:conditions => "name = ?", name) Project.all(:conditions => { :name => name }) Project.where("name = :name", :name => name) Project.where(:id=> params[:id]).all # Update project.update_attributes(:name => 'owasp')

Query Parameterization (Cold Fusion) SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID =

Query Parameterization (PERL) my $sql = "INSERT INTO foo (bar, baz) VALUES ( ?, ? )"; my $sth = $dbh->prepare( $sql ); $sth->execute( $bar, $baz );

Query Parameterization (.NET LINQ) public bool login(string loginId, string shrPass) { DataClassesDataContext db = new DataClassesDataContext(); var validUsers = from user in db.USER_PROFILE where user.LOGIN_ID == loginId && user.PASSWORDH == shrPass select user; if (validUsers.Count() > 0) return true; return false; } ;

OWASP Query Parameterization Cheat Sheet

Secure Password Storage public String hash(String password, String userSalt, int iterations) throws EncryptionException { byte[] bytes = null; try { MessageDigest digest = MessageDigest.getInstance(hashAlgorithm); digest.reset(); digest.update(ESAPI.securityConfiguration().getMasterSalt()); digest.update(userSalt.getBytes(encoding)); digest.update(password.getBytes(encoding)); // rehash a number of times to help strengthen weak passwords bytes = digest.digest(); for (int i = 0; i < iterations; i++) { digest.reset(); bytes = digest.digest(bytes); } String encoded = ESAPI.encoder().encodeForBase64(bytes,false); return encoded; } catch (Exception ex) { throw new EncryptionException("Internal error", "Error"); }} [2][2]

Secure Password Storage public String hash(String password, String userSalt, int iterations) throws EncryptionException { byte[] bytes = null; try { MessageDigest digest = MessageDigest.getInstance(hashAlgorithm); digest.reset(); digest.update(ESAPI.securityConfiguration().getMasterSalt()); digest.update(userSalt.getBytes(encoding)); digest.update(password.getBytes(encoding)); // rehash a number of times to help strengthen weak passwords bytes = digest.digest(); for (int i = 0; i < iterations; i++) { digest.reset(); bytes = digest.digest(bytes); } String encoded = ESAPI.encoder().encodeForBase64(bytes,false); return encoded; } catch (Exception ex) { throw new EncryptionException("Internal error", "Error"); }}

Secure Password Storage public String hash(String password, String userSalt, int iterations) throws EncryptionException { byte[] bytes = null; try { MessageDigest digest = MessageDigest.getInstance(hashAlgorithm); digest.reset(); digest.update(ESAPI.securityConfiguration().getMasterSalt()); digest.update(userSalt.getBytes(encoding)); digest.update(password.getBytes(encoding)); // rehash a number of times to help strengthen weak passwords bytes = digest.digest(); for (int i = 0; i < iterations; i++) { digest.reset(); bytes = digest.digest(salts + bytes + hash(i)); } String encoded = ESAPI.encoder().encodeForBase64(bytes,false); return encoded; } catch (Exception ex) { throw new EncryptionException("Internal error", "Error"); }}

Secure Password Storage BCRYPT -Really slow on purpose -Blowfish derived -Suppose you are supporting millions on concurrent logins… -Takes about 10 concurrent runs of BCRYPT to pin a high performance CPU PBKDF2 -Takes up a lot of memory -Suppose you are supporting millions on concurrent logins…

OWASP Password Storage Cheat Sheet

Data Sanitization (Stop XSS) Session Hijacking Site Defacement Network Scanning Undermining CSRF Defenses Site Redirection/Phishing Load of Remotely Hosted Scripts Data Theft Keystroke Logging Attackers using XSS more frequently [3][3]

XSS Defense by Data Type and Context Data TypeContextDefense StringHTML BodyHTML Entity Encode StringHTML AttributeMinimal Attribute Encoding StringGET ParameterURL Encoding StringUntrusted URLURL Validation, avoid javascript: URLs, Attribute encoding, safe URL verification StringCSSStrict structural validation, CSS Hex encoding, good design HTMLHTML BodyHTML Validation (JSoup, AntiSamy, HTML Sanitizer) AnyDOMDOM XSS Cheat Sheet Untrusted JavaScriptAnySandboxing JSONClient Parse TimeJSON.parse() or json2.js Safe HTML Attributes include: align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width

HTML Body Context UNTRUSTED DATA

HTML Attribute Context

HTTP GET Parameter Context clickme

URL Context clickme

CSS Value Context Selection

JavaScript Variable Context var currentValue='UNTRUSTED DATA'; someFunction('UNTRUSTED DATA');

JSON Parsing Context JSON.parse(UNTRUSTED JSON DATA)

26 jQuery methods that directly update DOM or can execute JavaScript $() or jQuery().attr().add().css().after().html().animate().insertAfter().append().insertBefore().appendTo()Note:.text() updates DOM, but is safe. Dangerous jQuery Data Types CSSSome Attribute Settings HTMLURL (Potential Redirect) jQuery methods that accept URLs to potentially unsafe content jQuery.ajax()jQuery.post() jQuery.get()load() jQuery.getScript()

Contextual encoding is a crucial technique needed to stop all types of XSS jqencoder is a jQuery plugin that allows developers to do contextual encoding in JavaScript to stop DOM-based XSS   $('#element').encode('html', cdata); JQuery Encoding with JQencoder

Best Practice: DOM-Based XSS Defense Untrusted data should only be treated as displayable text JavaScript encode and delimit untrusted data as quoted strings Use document.createElement("…"), element.setAttribute("…","value"), element.appendChild(…), etc. to build dynamic interfaces (safe attributes only) Avoid use of HTML rendering methods Make sure that any untrusted data passed to eval() methods is delimited with string delimiters and enclosed within a closure such as eval(someFunction(‘UNTRUSTED DATA’));

OWASP Abridged XSS Prevention Cheat Sheet

Permission Based Access Control Code to the permission, not the role Centralize access control logic Design access control as a filter Fail securely (deny-by-default) Apply same core logic to presentation and server-side access control decisions Server-side trusted data should drive access control Provide privilege and user grouping for better management Isolate administrative features and access [4][4]

Best Practice: Code to the Permission if (AC.hasAccess(ARTICLE_EDIT, NUM)) { //execute activity } Code it once, and it never needs to change again Implies policy is persisted in some way Requires more design/work up front to get right

OWASP Access Control Cheat Sheet

Cross-Site Request Forgery Tokens and Re-authentication Cryptographic Tokens -Primary and most powerful defense. Randomness is your friend Require users to re-authenticate -Amazon.com does this *really* well Double-cookie submit defense -Decent defense, but not based on randomness; based on SOP [5][5]

OWASP Cross-Site Request Forgery Cheat Sheet

Multi Factor Authentication Passwords as a single AuthN factor are DEAD! Mobile devices are quickly becoming the “what you have” factor SMS and native apps for MFA are not perfect but heavily reduce risk vs. passwords only Password strength and password policy can be MUCH WEAKER in the face of MFA If you are protecting your magic user and fireball wand with MFA (Blizzard.net) you may also wish to consider protecting your multi-billion dollar enterprise with MFA [6][6]

OWASP Authentication Sheet Cheat Sheet

Forgot Password Secure Design Require identity and security questions -Last name, account number, , DOB -Enforce lockout policy -Ask one or more good security questions - Send the user a randomly generated token via out-of- band method - , SMS or token Verify code in same Web session -Enforce lockout policy Change password -Enforce password policy [7][7]

OWASP Forgot Password Cheat Sheet

Ensure secure session IDs bytes, cryptographically random - Stored in HTTP Cookies - Cookies: Secure, HTTP Only, limited path Generate new session ID at login time - To avoid session fixation Session Timeout - Idle Timeout - Absolute Timeout - Logout Functionality Session Defenses [8][8]

OWASP Session Management Cheat Sheet

X-Frame-Options // to prevent all framing of this content response.addHeader( "X-FRAME-OPTIONS", "DENY" ); // to allow framing of this content only by this site response.addHeader( "X-FRAME-OPTIONS", "SAMEORIGIN" ); [9][9]

OWASP Clickjacking Cheat Sheet

Encryption in Transit (TLS) Authentication credentials and session identifiers must be encrypted in transit via HTTPS/SSL - Starting when the login form is rendered - Until logout is complete - All other sensitive data should be protected via HTTPS! free online assessment of public-facing server HTTPS configuration heat_Sheet for HTTPS best practices heat_Sheet [10][10]

OWASP Transport Layer Protection Cheat Sheet

Thank You