OWASP Top 10 : Let’s know & solve

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    OWASP Top 10 : Let’s know & solve - Presentation Transcript

    1. OWASP Top 10 : Let’s know & solve Harit Kothari
    2. Top 10
      • Cross Site Scripting (XSS)
      • Injection Flaws
      • Malicious File Execution
      • Insecure Direct Object Reference
      • Cross Site Request Forgery (CSRF)
      • Information Leakage and Improper Error Handling
      • Broken Authentication and Session Management
      • Insecure Cryptographic Storage
      • Insecure Communications
      • Failure to Restrict URL Access
    3. Cross Site Scripting (XSS)
    4. Remedies
      • Client side validation (using JavaScript etc.)
      • Specify character set (e.g. UTF-8, 8859_1) in HTML with CHARSET header
      • Server side validation
      • Best practse : Error reporting / Server logs
    5. Examples
      • Replace special character(s) with blanks ‘ ’
      • final String filterPattern=&quot;[<>{}\[\];\&]&quot;;
      • String inputStr = s.replaceAll(filterPattern,&quot; &quot;);
      • Another – check if String matches any of characters except numeric, using RegEx
      • final String inputStr = request.getParameter(&quot;input&quot;);
      • final String numericPattern = &quot;^\d+$&quot;;
      • if (!inputStr.matches(numericPattern))
      • {
      • /* invalid input, do something with error*/
      • }
      • Yet another, change characters representation into decimal equivalent, of course paying performance penalty
      • public static String encode(String data)
      • {
      • final StringBuffer buf = new StringBuffer();
      • final char[] chars = data.toCharArray();
      • for (int i = 0; i < chars.length; i++)
      • {
      • buf.append(&quot;&#&quot; + (int) chars[i]);
      • }
      • return buf.toString();
      • }
    6. Examples continued
      • Secure Exceptions thrown at server pages
      • <!-- Maps the 404 Not Found response code to the error page /errPage404 -->
      • <error-page>
      • <error-code>404</error-code>
      • <location>/errPage404</location>
      • </error-page>
      • <!-- Maps any thrown ServletExceptions to the error page /errPageServ -->
      • <error-page>
      • <exception-type>javax.servlet.ServletException</exception-type>
      • <location>/errPageServ</location>
      • </error-page>
      • <!-- Maps any other thrown exceptions to a generic error page /errPageGeneric -->
      • <error-page>
      • <exception-type>java.lang.Throwable</exception-type>
      • <location>/errPageGeneric</location>
      • </error-page>
    7. Injection Flaws
    8. Remedies
      • Input validation
      • Strongly typed query APIs (PreparedStatement in JDBC & ORM in Hibernate)
      • Avoid dynamic query APIs (Statement in JDBC)
      • Use of escape characters as prefix and sufix to values to eliminate LDAP injection
    9. Examples
      • Using PreparedStatement
      • try
      • {
      • // Prepare a statement to insert a record
      • String sql = &quot;INSERT INTO my_table (columnName) VALUES(?)&quot;;
      • PreparedStatement pstmt = connection.prepareStatement(sql);
      • // Insert 10 rows
      • for (int i=0; i<10; i++)
      • {
      • // Set the value
      • pstmt.setString(1, &quot;row &quot;+i);
      • // Insert the row
      • pstmt.executeUpdate();
      • }
      • }
      • catch (SQLException e)
      • {
      • }
    10. Examples Continued
      • To add Escape Chars
      • public static String escapeDN(String name)
      • {
      • StringBuffer sb = new StringBuffer(); // If using JDK >= 1.5 consider using StringBuilder
      • if ((name.length() > 0) && ((name.charAt(0) == ' ') || (name.charAt(0) == '#')))
      • sb.append('\'); // add the leading backslash if needed
      • for (int i = 0; i < name.length(); i++)
      • {
      • char curChar = name.charAt(i);
      • switch (curChar)
      • {
      • case '\': sb.append(&quot;\\&quot;); break;
      • case ',': sb.append(&quot;\,&quot;); break;
      • case '+' sb.append(&quot;\+&quot;); break;
      • case '&quot;': sb.append(&quot;\&quot;&quot;); break;
      • case '<': sb.append(&quot;\<&quot;); break;
      • case '>': sb.append(&quot;\>&quot;); break;
      • case ';': sb.append(&quot;\;&quot;); break;
      • default: sb.append(curChar);
      • }
      • }
      • if ((name.length() > 1) && (name.charAt(name.length() - 1) == ' '))
      • sb.insert(sb.length() - 1, '\'); // add the trailing backslash if needed
      • return sb.toString();
      • }
      • To filter Escape Chars
      • public static final String escapeLDAPSearchFilter(String filter)
      • {
      • StringBuffer sb = new StringBuffer(); // If using JDK >= 1.5 consider using StringBuilder
      • for (int i = 0; i < filter.length(); i++)
      • {
      • char curChar = filter.charAt(i);
      • switch (curChar)
      • {
      • case '\':
      • sb.append(&quot;\5c&quot;);
      • break;
      • case '*':
      • sb.append(&quot;\2a&quot;);
      • break;
      • case '(':
      • sb.append(&quot;\28&quot;);
      • break;
      • case ')':
      • sb.append(&quot;\29&quot;);
      • break;
      • case 'u0000':
      • sb.append(&quot;\00&quot;);
      • break;
      • default:
      • sb.append(curChar);
      • }
      • }
      • return sb.toString();
      • }
    11. Malicious File Execution
    12. Remedies
      • Strongly validate user
      • Add firewall
      • Check any user supplied files or filenames
      • Consider implementing a chroot jail / SandBox
    13. Insecure Direct Object Reference
    14. Remedies
      • Limit direct reference (public access) to secure entities (objects)
      • Use some alternate parameter to check for access permission, e.g. userID
      • Use of index values to avoid actual name / parameter manipulation
    15. Example
      • int bankAccountNo = Integer.parseInt( request.getParameter( &quot;AccountNo&quot; ) );
      • User user = (User)request.getSession().getAttribute( &quot;user&quot; );
      • String query = &quot;SELECT * FROM account_master WHERE ac_no=&quot; + bankAccountNo + &quot; AND userID=&quot; + user.getID();
    16. Cross Site Request Forgery (XSRF)
      • Also knows as…
        • Session Riding
        • One-Click Attacks
        • Hostile Linking
        • Automation Attack
    17. Example
      • Applications e.g.
        • Ask for current password to change to new
        • Avoid hidden form fields
        • Use cryptographic tokens
    18. Remedies
      • Limit direct reference (public access) to secure entities (objects)
      • Use some alternate parameter to check for access permission, e.g. userID
      • Use of index values to avoid actual name / parameter manipulation
      • Extensive use of SessionID (JSessionID In case of JavaEE), which is unpredictable
    19. Information Leakage and Improper Error Handling
    20. Remedies
      • Exception handling & simplified message (that too only if required) on user end – a key!
      • Define error pages at AppServer level. E.g. 40X – Page related errors
    21. Broken Authentication and Session Management
    22. Example
      • On logout,
        • Session.invalidate();
    23. Remedies
      • Proper session management
        • No other routine then application server’s default mechanism
      • Session timeout after specific time
      • Destruction of session on logout / time out.
      • No session details in logs or URL
    24. Insecure Cryptographic Storage
    25. Remedies
      • Really secure encryption algorithm
      • Ensure that every sensitive piece of information is encrypted well
      • Use publicly aproved algoriths instead of user defined
      • Store private keys in extremely secure location (offline)
      • Ensure encrypted data is not easily decrypted
    26. Insecure Communications
    27. Remedies
      • Use of secure encryption while sending important data over network (SSL)
      • Encryption of sensitive data
      • Ensure communication between infrastructure elements (e.g. DB &Server) uses transport layer security or protocol level encryption
    28. Failure to Restrict URL Access
    29. Remedies
      • Access control matrix
      • No read access to unauthorized user
      • Hidden URLs known only to the users, it is meant for, is wrong assumption
      • Include / Header files out of public scope, outside root of application
      • Block access to the type of files not entertained by application
    30. References
      • http://java.sun.com/javaee/security/
      • http://www.owasp.org/index.php/Top_10_2007

    + Harit KothariHarit Kothari, 2 years ago

    custom

    868 views, 1 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 868
      • 868 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories