SlideShare une entreprise Scribd logo
1  sur  31
Top 10 Web Security Controls




March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 1
(1) Query Parameterization (PHP PDO)


$stmt = $dbh->prepare("INSERT INTO
REGISTRY (name, value) VALUES
(:name, :value)");

$stmt->bindParam(':name', $name);
$stmt->bindParam(':value', $value);




   March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 2
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",
PasswordTextBox.Text);
SqlDataReader objReader =
objCommand.ExecuteReader();
if (objReader.Read()) { ...

    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 3
Query Parameterization (Java)
double newSalary =
request.getParameter(“newSalary”) ;
int id = request.getParameter(“id”);
PreparedStatement pstmt =
con.prepareStatement("UPDATE EMPLOYEES SET SALARY
= ? WHERE ID = ?");
pstmt.setDouble(1, newSalary);
pstmt.setInt(2, id);

Query safeHQLQuery = session.createQuery("from
Inventory where productID=:productid");
safeHQLQuery.setParameter("productid",
userSuppliedParameter);


    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 4
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)
# Update
project.update_attributes(:name => 'owasp')
# Delete
Project.delete(:name => 'name')



     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 5
Query Parameterization (Cold Fusion)


<cfquery name="getFirst" dataSource="cfsnippets">
    SELECT * FROM #strDatabasePrefix#_courses WHERE
intCourseID =
    <cfqueryparam value=#intCourseID#
CFSQLType="CF_SQL_INTEGER">
</cfquery>




    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 6
Query Parameterization (PERL)



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




    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 7
XSS: Why so Serious?

Session hijacking
Site defacement
Network scanning
Undermining CSRF defenses
Site redirection/phishing
Load of remotely hosted scripts
Data theft
Keystroke logging

      March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 8
Danger: Multiple Contexts

Browsers have multiple contexts that must be considered!




    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 9
XSS in HTML Attributes
< i n p u t typ e = "te x t" n am e = "c o m m e n ts ”
                           valu e = "U N T R U S T E D D AT A">


< i n p u t typ e = "te x t" n am e = "c o m m e n ts "
           valu e = "h e llo " o n m o u s e o ve r= "/* fi re attac k * /">

    Attackers can add event handlers:
    
        onMouseOver
    
        onLoad
    
        onUnLoad
    
        etc…

        March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 10
XSS in Source Attribute

    User input often winds up in src attribute

    Tags such as
    < i m g s rc = "">
    < i fram e s rc = "">

    Example Request:
                                 h ttp ://e x am p le .c o m /vi e w I m ag e ?
                                            i m ag e n am e = m ym ap .jp g

    Attackers can use javascript:/*attack*/ in src
    attributes


      March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 11
URL Parameter Escaping

    Escape all non alpha-num characters with the
    %HH format
< a h re f= “/s e arc h ?d ata= U N T R U S T E D D AT A”>

    Be careful not to allow untrusted data to drive
    entire URL’s or URL fragments

    This encoding only protects you from XSS at the
    time of rendering the link

    Treat DATA as untrusted after submitted




     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 12
XSS in the Style Tag

    Applications sometimes take user data and use it
    to generate presentation style




                                        U R L p aram e te r w ri tte n w i th i n s tyle
                                        tag


    Consider this example:
h ttp ://e x am p le .c o m /vi e w D o c u m e n t?b ac k g ro u n d = w h i te


     March 2012 Top Ten Controls v4.1     Jim Manico and Eoin Keary          Page 13
CSS Pwnage Test Case
< d i v s tyle = "w i d th : < % = te m p 3% > ;"> M o u s e o ve r < /
  d i v>
temp3 =
  ESAPI.encoder().encodeForCSS("expression(alert
  (String.fromCharCode (88,88,88)))");
< d i v s tyle = "w i d th : e x p re s s i o n 2 8 ale rt2 8
  S tri n g 2 e fro m C h arC o d e 2 0 2 8 882 c 882 c 882 9
  2 9 2 9 ;"> M o u s e o ve r < /d i v>

    Pops in at least IE6 and IE7.
li s ts .o w as p .o rg /p i p e rm ai l/o w as p -e s ap i /2 009-
    F e b ru ary/000405 .h tm l

     March 2012 Top Ten Controls v4.1      Jim Manico and Eoin Keary   Page 14
Javascript Context

    Escape all non alpha-num characters with the
    xHH format
<script>var x='U N T R U S T E D D AT A';</script>

    You're now protected from XSS at the time data
    is assigned

    What happens to x after you assign it?




     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 15
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
 Avoid use of HTML rendering methods
 Understand the dataflow of untrusted data through your
  JavaScript code. If you do have to use the methods above
  remember to HTML and then JavaScript encode the
  untrusted data
 Avoid passing untrusted data to eval(), setTimeout() etc.
 Don’t eval() JSON to convert it to native JavaScript objects.
  Instead use JSON.toJSON() and JSON.parse()
 Run untrusted scripts in a sandbox (ECMAScript canopy, HTML
  5 frame sandbox, etc)
     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 16
(2) 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:
                                                            URL’s, 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

         March 2012 Top Ten Controls v4.1       Jim Manico and Eoin Keary      Page 17
Attacks on Access Control

Vertical Access Control Attacks
    A standard user accessing administration functionality
    “Privilege Escalation”

Horizontal Access Control attacks
    Same role, but accessing another user's private data

Business Logic Access Control Attacks
    Abuse of workflow



  March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 18
Best Practice: Code to the Activity


if (AC.hasAccess(ARTICLE_EDIT, NUM)) {
   //execute activity
}

Code it once, never needs to change again
Implies policy is persisted/centralized in some
 way
Requires more design/work up front to get right


   March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 19
Best Practice: Use a Centralized Access Controller

          In Presentation Layer

          if (ACL.isAuthorized(VIEW_LOG_PANEL))
          {
                <h2>Here are the logs</h2>
                <%=getLogs();%/>
          }

          In Controller

          try (ACL.assertAuthorized(DELETE_USER))
          {
                deleteUser();
          }

     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 20
(3) Access Control Positive Patterns
Code to the activity, 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
    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 21
Anatomy of an CSRF Attack

Consider a consumer banking application that
 contains the following form

  <form action=“https://bank.com/Transfer.asp” method=“POST” id=“form1”>
  <p>Account Num: <input type=“text” name=“acct” value=“13243”/></p>
  <p>Transfer Amt: <input type=“text” name=“amount” value=“1000” /></p>
  </form>
  <script>document.getElementById(‘form1’).submit(); </script>




    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 22
(4) Cross Site Request Forgery Defenses
Cryptographic Tokens
  Primary and most powerful defense. Randomness is
   your friend.
Request that cause side effects should use (and
 require) the POST method
  Alone, this is not sufficient
Require users to re-authenticate
  Amazon.com does this *really* well
Double-cookie submit
  Decent defense, but no based on randomness, based on
   SOP

    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 23
Authentication Dangers
Weak password
Login Brute Force
Username Harvesting
Session Fixation
Weak or Predictable Session
Plaintext or poor password storage
Weak "Forgot Password” feature
Weak "Change Password” feature
Credential or session exposure in transit via
 network sniffing
Session Hijacking via XSS
  March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 24
(5) Authentication Defenses
 2FA
 Develop generic failed login messages that do not
  indicate whether the user-id or password was incorrect
 Enforce account lockout after a pre-determined number
  of failed login attempts
 Force re-authentication at critical application
  boundaries
   edit email, edit profile, edit finance info, ship to new
     address, change password, etc.
 Implement server-side enforcement of credential
  syntax and strength


     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 25
(6) 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

      March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 26
(7) Session Defenses
 Ensure secure session ID’s
   20+ 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
    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 27
(8) Clickjacking Defense
 Standard Option: X-FRAME-OPTIONS Header
  // 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" );

 Frame-breaking Script defense:

   <style id="antiClickjack">body{display:none}</style>
   <script type="text/javascript">
   if (self == top) {
      var antiClickjack =
      document.getElementByID("antiClickjack");
      antiClickjack.parentNode.removeChild(antiClickjack)
   } else {
     top.location = self.location;
   }
   </script>
     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 28
(9a) Secure Password Storage
public String hash(String plaintext, String salt, int iterations)
      throws EncryptionException {
byte[] bytes = null;
try {
  MessageDigest digest = MessageDigest.getInstance(hashAlgorithm);
  digest.reset();
  digest.update(ESAPI.securityConfiguration().getMasterSalt());
  digest.update(salt.getBytes(encoding));
  digest.update(plaintext.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");
}}
    March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 29
(9b) Password Security Defenses

                                              Disab
le Browser Autocomplete
   <form AUTOCOMPLETE="off”>
   <input AUTOCOMPLETE="off”>


                                              Pass
word and form fields
   Input type=password


                                              Additi
onal password securityManico and Eoin Keary
  March 2012 Top Ten Controls v4.1 Jim         Page 30
(10) Encryption in Transit (TLS)
 Authentication credentials and session identifiers must me
  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!

 https://www.ssllabs.com free online assessment of public
  facing server HTTPS configuration

 https://www.owasp.org/index.php/Transport_Layer_Protection_
   for HTTPS best practices


     March 2012 Top Ten Controls v4.1   Jim Manico and Eoin Keary   Page 31

Contenu connexe

Tendances

The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting GuideDaisuke_Dan
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?Yurii Bilyk
 
Encrypt your volumes with barbican open stack 2018
Encrypt your volumes with barbican open stack 2018Encrypt your volumes with barbican open stack 2018
Encrypt your volumes with barbican open stack 2018Duncan Wannamaker
 
In the Wake of Kerberoast
In the Wake of KerberoastIn the Wake of Kerberoast
In the Wake of Kerberoastken_kitahara
 
Attacking and defending GraphQL applications: a hands-on approach
 Attacking and defending GraphQL applications: a hands-on approach Attacking and defending GraphQL applications: a hands-on approach
Attacking and defending GraphQL applications: a hands-on approachDavide Cioccia
 
VTU Network management -15cs833 Notes by Nithin, VVCE, Mysuru
VTU Network management -15cs833 Notes by Nithin, VVCE, MysuruVTU Network management -15cs833 Notes by Nithin, VVCE, Mysuru
VTU Network management -15cs833 Notes by Nithin, VVCE, MysuruNithin Kumar,VVCE, Mysuru
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingRana Khalil
 
Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析
Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析
Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析Amazon Web Services Japan
 
아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS 사업개발 담당/ 김성락, LG 인화원 책...
아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS  사업개발 담당/ 김성락, LG 인화원 책...아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS  사업개발 담당/ 김성락, LG 인화원 책...
아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS 사업개발 담당/ 김성락, LG 인화원 책...Amazon Web Services Korea
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Aman Singh
 
Data Structures module 1 notes
Data Structures module 1  notesData Structures module 1  notes
Data Structures module 1 notesPoornima N
 
Let the alpakka pull your stream
Let the alpakka pull your streamLet the alpakka pull your stream
Let the alpakka pull your streamEnno Runne
 
Accessibility Testing using Axe
Accessibility Testing using AxeAccessibility Testing using Axe
Accessibility Testing using AxeRapidValue
 
Naked Performance With Clojure
Naked Performance With ClojureNaked Performance With Clojure
Naked Performance With ClojureMetosin Oy
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Ikhade Maro Igbape
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaJorge Vásquez
 

Tendances (20)

The Cross Site Scripting Guide
The Cross Site Scripting GuideThe Cross Site Scripting Guide
The Cross Site Scripting Guide
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
Encrypt your volumes with barbican open stack 2018
Encrypt your volumes with barbican open stack 2018Encrypt your volumes with barbican open stack 2018
Encrypt your volumes with barbican open stack 2018
 
Core JAVA Notes
Core JAVA NotesCore JAVA Notes
Core JAVA Notes
 
In the Wake of Kerberoast
In the Wake of KerberoastIn the Wake of Kerberoast
In the Wake of Kerberoast
 
Security Testing for Web Application
Security Testing for Web ApplicationSecurity Testing for Web Application
Security Testing for Web Application
 
Attacking and defending GraphQL applications: a hands-on approach
 Attacking and defending GraphQL applications: a hands-on approach Attacking and defending GraphQL applications: a hands-on approach
Attacking and defending GraphQL applications: a hands-on approach
 
VTU Network management -15cs833 Notes by Nithin, VVCE, Mysuru
VTU Network management -15cs833 Notes by Nithin, VVCE, MysuruVTU Network management -15cs833 Notes by Nithin, VVCE, Mysuru
VTU Network management -15cs833 Notes by Nithin, VVCE, Mysuru
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Amazon Simple Workflow Service (SWF)
Amazon Simple Workflow Service (SWF)Amazon Simple Workflow Service (SWF)
Amazon Simple Workflow Service (SWF)
 
Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析
Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析
Amazon Kinesis Analytics によるストリーミングデータのリアルタイム分析
 
아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS 사업개발 담당/ 김성락, LG 인화원 책...
아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS  사업개발 담당/ 김성락, LG 인화원 책...아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS  사업개발 담당/ 김성락, LG 인화원 책...
아마존 혁신의 배경 및 Digital Innovation Program 소개 – 김중수, AWS 사업개발 담당/ 김성락, LG 인화원 책...
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)
 
Data Structures module 1 notes
Data Structures module 1  notesData Structures module 1  notes
Data Structures module 1 notes
 
XSS
XSSXSS
XSS
 
Let the alpakka pull your stream
Let the alpakka pull your streamLet the alpakka pull your stream
Let the alpakka pull your stream
 
Accessibility Testing using Axe
Accessibility Testing using AxeAccessibility Testing using Axe
Accessibility Testing using Axe
 
Naked Performance With Clojure
Naked Performance With ClojureNaked Performance With Clojure
Naked Performance With Clojure
 
Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation Cross Site Scripting Defense Presentation
Cross Site Scripting Defense Presentation
 
Exploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in ScalaExploring ZIO Prelude: The game changer for typeclasses in Scala
Exploring ZIO Prelude: The game changer for typeclasses in Scala
 

Similaire à Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP Göteborg

Top Ten Web Defenses - DefCamp 2012
Top Ten Web Defenses  - DefCamp 2012Top Ten Web Defenses  - DefCamp 2012
Top Ten Web Defenses - DefCamp 2012DefCamp
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesCarol McDonald
 
XSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hourXSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hoursnoopythesecuritydog
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encodingEoin Keary
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web AppsFrank Kim
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityCoverity
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0Mario Heiderich
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure codingHaitham Raik
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
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
 
Positive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-raysPositive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-raysqqlan
 
Waf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptWaf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptDenis Kolegov
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...CODE BLUE
 
The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010Mario Heiderich
 

Similaire à Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP Göteborg (20)

Cross site scripting
Cross site scriptingCross site scripting
Cross site scripting
 
Top Ten Web Defenses - DefCamp 2012
Top Ten Web Defenses  - DefCamp 2012Top Ten Web Defenses  - DefCamp 2012
Top Ten Web Defenses - DefCamp 2012
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
XSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hourXSS Primer - Noob to Pro in 1 hour
XSS Primer - Noob to Pro in 1 hour
 
04. xss and encoding
04.  xss and encoding04.  xss and encoding
04. xss and encoding
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
Securing Java EE Web Apps
Securing Java EE Web AppsSecuring Java EE Web Apps
Securing Java EE Web Apps
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first Security
 
Locking the Throneroom 2.0
Locking the Throneroom 2.0Locking the Throneroom 2.0
Locking the Throneroom 2.0
 
PCI Security Requirements - secure coding
PCI Security Requirements - secure codingPCI Security Requirements - secure coding
PCI Security Requirements - secure coding
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
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 Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-raysPositive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-rays
 
Waf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScriptWaf.js: How to Protect Web Applications using JavaScript
Waf.js: How to Protect Web Applications using JavaScript
 
前端概述
前端概述前端概述
前端概述
 
Complete xss walkthrough
Complete xss walkthroughComplete xss walkthrough
Complete xss walkthrough
 
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
[CB16] Electron - Build cross platform desktop XSS, it’s easier than you thin...
 
Rails and security
Rails and securityRails and security
Rails and security
 
The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010The Future of Web Attacks - CONFidence 2010
The Future of Web Attacks - CONFidence 2010
 
ASP.NET Web Security
ASP.NET Web SecurityASP.NET Web Security
ASP.NET Web Security
 

Dernier

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Dernier (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Jim Manico: Developer Top 10 Core Controls, web application security @ OWASP Göteborg

  • 1. Top 10 Web Security Controls March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 1
  • 2. (1) Query Parameterization (PHP PDO) $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)"); $stmt->bindParam(':name', $name); $stmt->bindParam(':value', $value); March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 2
  • 3. 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", PasswordTextBox.Text); SqlDataReader objReader = objCommand.ExecuteReader(); if (objReader.Read()) { ... March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 3
  • 4. Query Parameterization (Java) double newSalary = request.getParameter(“newSalary”) ; int id = request.getParameter(“id”); PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?"); pstmt.setDouble(1, newSalary); pstmt.setInt(2, id); Query safeHQLQuery = session.createQuery("from Inventory where productID=:productid"); safeHQLQuery.setParameter("productid", userSuppliedParameter); March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 4
  • 5. 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) # Update project.update_attributes(:name => 'owasp') # Delete Project.delete(:name => 'name') March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 5
  • 6. Query Parameterization (Cold Fusion) <cfquery name="getFirst" dataSource="cfsnippets"> SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID = <cfqueryparam value=#intCourseID# CFSQLType="CF_SQL_INTEGER"> </cfquery> March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 6
  • 7. Query Parameterization (PERL) my $sql = "INSERT INTO foo (bar, baz) VALUES ( ?, ? )”; my $sth = $dbh->prepare( $sql ); $sth->execute( $bar, $baz ); March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 7
  • 8. XSS: Why so Serious? Session hijacking Site defacement Network scanning Undermining CSRF defenses Site redirection/phishing Load of remotely hosted scripts Data theft Keystroke logging March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 8
  • 9. Danger: Multiple Contexts Browsers have multiple contexts that must be considered! March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 9
  • 10. XSS in HTML Attributes < i n p u t typ e = "te x t" n am e = "c o m m e n ts ” valu e = "U N T R U S T E D D AT A"> < i n p u t typ e = "te x t" n am e = "c o m m e n ts " valu e = "h e llo " o n m o u s e o ve r= "/* fi re attac k * /">  Attackers can add event handlers:  onMouseOver  onLoad  onUnLoad  etc… March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 10
  • 11. XSS in Source Attribute  User input often winds up in src attribute  Tags such as < i m g s rc = ""> < i fram e s rc = "">  Example Request: h ttp ://e x am p le .c o m /vi e w I m ag e ? i m ag e n am e = m ym ap .jp g  Attackers can use javascript:/*attack*/ in src attributes March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 11
  • 12. URL Parameter Escaping  Escape all non alpha-num characters with the %HH format < a h re f= “/s e arc h ?d ata= U N T R U S T E D D AT A”>  Be careful not to allow untrusted data to drive entire URL’s or URL fragments  This encoding only protects you from XSS at the time of rendering the link  Treat DATA as untrusted after submitted March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 12
  • 13. XSS in the Style Tag  Applications sometimes take user data and use it to generate presentation style U R L p aram e te r w ri tte n w i th i n s tyle tag  Consider this example: h ttp ://e x am p le .c o m /vi e w D o c u m e n t?b ac k g ro u n d = w h i te March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 13
  • 14. CSS Pwnage Test Case < d i v s tyle = "w i d th : < % = te m p 3% > ;"> M o u s e o ve r < / d i v> temp3 = ESAPI.encoder().encodeForCSS("expression(alert (String.fromCharCode (88,88,88)))"); < d i v s tyle = "w i d th : e x p re s s i o n 2 8 ale rt2 8 S tri n g 2 e fro m C h arC o d e 2 0 2 8 882 c 882 c 882 9 2 9 2 9 ;"> M o u s e o ve r < /d i v>  Pops in at least IE6 and IE7. li s ts .o w as p .o rg /p i p e rm ai l/o w as p -e s ap i /2 009- F e b ru ary/000405 .h tm l March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 14
  • 15. Javascript Context  Escape all non alpha-num characters with the xHH format <script>var x='U N T R U S T E D D AT A';</script>  You're now protected from XSS at the time data is assigned  What happens to x after you assign it? March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 15
  • 16. 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  Avoid use of HTML rendering methods  Understand the dataflow of untrusted data through your JavaScript code. If you do have to use the methods above remember to HTML and then JavaScript encode the untrusted data  Avoid passing untrusted data to eval(), setTimeout() etc.  Don’t eval() JSON to convert it to native JavaScript objects. Instead use JSON.toJSON() and JSON.parse()  Run untrusted scripts in a sandbox (ECMAScript canopy, HTML 5 frame sandbox, etc) March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 16
  • 17. (2) 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: URL’s, 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 March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 17
  • 18. Attacks on Access Control Vertical Access Control Attacks  A standard user accessing administration functionality  “Privilege Escalation” Horizontal Access Control attacks  Same role, but accessing another user's private data Business Logic Access Control Attacks  Abuse of workflow March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 18
  • 19. Best Practice: Code to the Activity if (AC.hasAccess(ARTICLE_EDIT, NUM)) { //execute activity } Code it once, never needs to change again Implies policy is persisted/centralized in some way Requires more design/work up front to get right March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 19
  • 20. Best Practice: Use a Centralized Access Controller In Presentation Layer if (ACL.isAuthorized(VIEW_LOG_PANEL)) { <h2>Here are the logs</h2> <%=getLogs();%/> } In Controller try (ACL.assertAuthorized(DELETE_USER)) { deleteUser(); } March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 20
  • 21. (3) Access Control Positive Patterns Code to the activity, 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 March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 21
  • 22. Anatomy of an CSRF Attack Consider a consumer banking application that contains the following form <form action=“https://bank.com/Transfer.asp” method=“POST” id=“form1”> <p>Account Num: <input type=“text” name=“acct” value=“13243”/></p> <p>Transfer Amt: <input type=“text” name=“amount” value=“1000” /></p> </form> <script>document.getElementById(‘form1’).submit(); </script> March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 22
  • 23. (4) Cross Site Request Forgery Defenses Cryptographic Tokens Primary and most powerful defense. Randomness is your friend. Request that cause side effects should use (and require) the POST method Alone, this is not sufficient Require users to re-authenticate Amazon.com does this *really* well Double-cookie submit Decent defense, but no based on randomness, based on SOP March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 23
  • 24. Authentication Dangers Weak password Login Brute Force Username Harvesting Session Fixation Weak or Predictable Session Plaintext or poor password storage Weak "Forgot Password” feature Weak "Change Password” feature Credential or session exposure in transit via network sniffing Session Hijacking via XSS March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 24
  • 25. (5) Authentication Defenses  2FA  Develop generic failed login messages that do not indicate whether the user-id or password was incorrect  Enforce account lockout after a pre-determined number of failed login attempts  Force re-authentication at critical application boundaries edit email, edit profile, edit finance info, ship to new address, change password, etc.  Implement server-side enforcement of credential syntax and strength March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 25
  • 26. (6) 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 March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 26
  • 27. (7) Session Defenses  Ensure secure session ID’s 20+ 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 March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 27
  • 28. (8) Clickjacking Defense  Standard Option: X-FRAME-OPTIONS Header // 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" );  Frame-breaking Script defense: <style id="antiClickjack">body{display:none}</style> <script type="text/javascript"> if (self == top) { var antiClickjack = document.getElementByID("antiClickjack"); antiClickjack.parentNode.removeChild(antiClickjack) } else { top.location = self.location; } </script> March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 28
  • 29. (9a) Secure Password Storage public String hash(String plaintext, String salt, int iterations) throws EncryptionException { byte[] bytes = null; try { MessageDigest digest = MessageDigest.getInstance(hashAlgorithm); digest.reset(); digest.update(ESAPI.securityConfiguration().getMasterSalt()); digest.update(salt.getBytes(encoding)); digest.update(plaintext.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"); }} March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 29
  • 30. (9b) Password Security Defenses Disab le Browser Autocomplete  <form AUTOCOMPLETE="off”>  <input AUTOCOMPLETE="off”> Pass word and form fields  Input type=password Additi onal password securityManico and Eoin Keary March 2012 Top Ten Controls v4.1 Jim Page 30
  • 31. (10) Encryption in Transit (TLS)  Authentication credentials and session identifiers must me 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!  https://www.ssllabs.com free online assessment of public facing server HTTPS configuration  https://www.owasp.org/index.php/Transport_Layer_Protection_ for HTTPS best practices March 2012 Top Ten Controls v4.1 Jim Manico and Eoin Keary Page 31

Notes de l'éditeur

  1. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  2. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  3. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  4. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  5. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  6. 1 -
  7. 2/1/12 ©2007 Ernst &amp; Young Advanced Security Center
  8. 1 -
  9. 1 -
  10. 1 -
  11. Need to expand this section!
  12. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  13. March 25, 2012 ©2007 Ernst &amp; Young Advanced Security Center
  14. March 25, 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;