SlideShare a Scribd company logo
Security App. web
Ivan Ortega
Benjamin Porta
A1: SQL Injection
SQL injection is a technique where malicious users can
inject SQL commands into an SQL statement, via web page
input.
Injected SQL commands can alter SQL statement and
compromise the security of a web application.
SQL injection is considered one of the top 10 web
application vulnerabilities of 2007 and 2010
WARNING
In its most common form, a SQL injection attack gives
access to sensitive information such as social
security numbers, credit card numbers or other
financial data. SQL injection is one of the most
prevalent types of web application security
vulnerability.
Reasons
Incorrectly filtered escape characters
Incorrect type handling
' OR '1'='1' --
' OR '1'='1' ({
' OR '1'='1' /*
1;DROP TABLE users
Preventing SQL Injection 1 / 2
● Adopt an input validation technique in which user
input is authenticated against a set of defined
rules for length, type and syntax.
● Users with the permission to access the database
must have the least privileges. Also, you should
always make sure that a database user is created
only for a specific application and this user is
not able to access other applications.
Preventing SQL Injection 2 / 2
● Use strongly typed parameterized query APIs
with placeholder substitution markers, even
when calling stored procedures.
● Show care when using stored procedures can be
injectable (such as via the use of exec() or
concatenating arguments within the stored
procedure).
Environment / Context 1/3
CLIENT
SERVER
(php)
SQLClient send data
to server
Environment / Context 2/3
CLIENT
SERVER
(php)
SQL
You must verify
data before
sending them to
server
Environment / Context 3/3
CLIENT
SERVER
(php)
SQLData are sent to server
(treated with php) and then,
they are sent to client
SQL can protect from
DROP and ALTER if
parametrized
Example 1: Injection 1/3
This program is web page link to an SQL
database which show the list of movies
present in database and allow anyone to add a
new entry in database.
Movie 1: Normal use case
Example 1: Injection 2/3
But we can easily attack this web page because
server doesn't check presence of javascript from
inputs added by users. We will show an example of
possible attack (injection of javascript code) on
this web page.
With this attack, each client is affected !!!
Movie 1: Attack use case
Example 1: Injection 3/3
To prevent of this kind of attack, we have to
block all the javascript which provide from
user, to do it, it's very simple, we have to
use a specific method from php, strip_tags().
It remove tags "<" and ">" but also tags like
"&lt;" and "&gt;"
Movie 1: Prevent use case
Example 2: SQL Injection 1/3
This program is a web page link to an SQL
database that show the list of users present
in database and allow anyone to subscribe. If
you are subscribed, you can log in.
Movie 2: Normal use case
Example 2: SQL Injection 2/3
The attack consist in connect and steal all personal informations of
an user with his login but without his password. It’s simple, a
request look like this:
$query = "SELECT * FROM user WHERE pseudo='".$p."' AND
mdp='".$pass."' ";
So attacker can inject a code after his pseudo (' -- ) and the end
of the request SQL will be interpreted as:
SELECT * FROM user WHERE pseudo='PSEUDO' -- AND mdp='WHATYOUWANT'
As you can see, AND mdp='...' is interpreted as a commentary!
Movie 2: Attack use case
Example 2: SQL Injection 3/3
To prevent of this kind of attack, use:
mysqli_real_escape_string() or bin2hex()
$link = mysqli_connect("127.0.0.1", "root", "", "secuweb");
$login = mysqli_real_escape_string($link,$login);
$user = $ins->getUserFromPseudoAndPassword($login,$pass);
Then, the input string change and replace ' -- to ' --
Movie 2: Prevent use case
Exemple 3: SQL Injection* 1/2
In reality, a lot of problems induced by SQL injection
are already fixed. For example in php, you can’t submit
multiple request to mysql without using mysqli->multi_query
Probably because it is very dangerous. You can modify data,
table and also delete them.
For this example, mysqli_real_escape_string
is deactivated.
Movie 3: Multi-request attack
Exemple 3: SQL Injection* 2/2
Allow only what is
necessary to an user, it
can prevent a lot of
actions
About SQL injection
Finally, it’s not difficult to prevent from SQL
injection, problem provides from webmaster because
they don’t check all cases of possible attack. There
is a lot of way to secure data inputted like methods
quoted before or others as preparation of request with
bindParam.
FIN de la partie 1
OwaspA3
CrossSiteScripting
XSS
CrossSiteScripting
1. What is it?
2. Types of XSS
3. Consequences
4. OWASP Prevention Cheat
Sheet
5. Testing my application
CrossSiteScripting
1. What is it?
2. Types of XSS
3. Consequences
4. OWASP Prevention Cheat
Sheet
5. Testing my application
What is it?
XSS attacks are a type of
injection
An attacker uses a web application to send malicious scripts
which will be executed when the page is built
Howcaniinjectcode?
CrossSiteScripting
1. What is it?
2. Types of XSS
3. Consequences
4. OWASP Prevention Cheat
Sheet
5. Testing my application
Types of Cross-Site Scripting
Stored XSS (Persistent or Type I)
Reflected XSS (Non-Persistent or Type II)
DOM Based XSS (Type-0)
Stored XSS
Most frequent vulnerabilities sites: where user input is
stored on the target server, such as in a database, in a
message forum, visitor log, comment field, etc.
Attacker use this input to inject
The injected script is permanently stored on the target
servers.
The victim then retrieves the malicious script from the
server when it requests the stored information.
Web Security - OWASP - SQL injection & Cross Site Scripting XSS
StoredXSS
Reflected XSS
The injected script is reflected off the web server, such as
response that includes some or all of the input sent to the
server as part of the request
Reflected attacks are delivered to victims via another
route, such as in an e-mail message, or on some other web
site.
Reflected XSS
Then the user click on a malicious link that contain XSS
injection as part of request to “trusted site” which
reflects the attack back to the user’s browser.
The browser then executes the code because it came from a
"trusted" server.
Web Security - OWASP - SQL injection & Cross Site Scripting XSS
Reflected xss-ExecutingJS
ReflectedXSS-Phishing
DOM Based XSS
It’s an XSS attack wherein the attack payload is executed as
a result of modifying the DOM in the victim’s browser used
by the original client side script.
Web Security - OWASP - SQL injection & Cross Site Scripting XSS
Ihavebeenattacked!
Whathappennow?
CrossSiteScripting
1. What is it?
2. Types of XSS
3. Consequences
4. OWASP Prevention Cheat
Sheet
5. Testing my application
Consequences
The consequences are the same although it
changes the type of XSS
Consequences
The consequences are the same although it
changes the type of XSS
ACCESS TO EXECUTE JAVASCRIPT
cookies, user files, installation of Trojan
horse programs, redirect the user to some
other page, modify presentation of content...
Whatcanidoto
preventXSSattacks?
CrossSiteScripting
1. What is it?
2. Types of XSS
3. Consequences
4. OWASP Prevention Cheat
Sheet
5. Testing my application
owaspPreventionCheatSheet
https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)
_Prevention_Cheat_Sheet
7 RULES TO PREVENT XSS
“Many organizations may find that allowing
only Rule #1 and Rule #2 are sufficient for
their needs.”
owaspPreventionCheatSheet
RULE#1-HTMLEscapeBeforeInsertingUntrustedDatainto
HTMLElementContent
<body>...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...</body>
<div>...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...</div>
any other normal HTML elements
& --> &amp;
< --> &lt;
> --> &gt;
" --> &quot;
' --> &#x27;
owaspPreventionCheatSheet
RULE#2-AttributeEscapeBeforeInsertingUntrustedData
intoHTMLCommonAttributes
<div attr=...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...>content</div>
inside UNquoted attribute
<div attr='...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'>content</div>
inside single quoted attribute
<div attr="...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...">content</div>
inside double quoted attribute
owaspPreventionCheatSheet
RULE#1-5-
EscapeBeforeInsertingUntrustedData
intoHTML
owaspPreventionCheatSheet
RULE#1-5-EscapeBeforeInsertingUntrustedDataintoHTML
HOW CAN I ESCAPE
UNTRUSTED DATA?
owaspPreventionCheatSheet
RULE#1-5-EscapeBeforeInsertingUntrustedDataintoHTML
https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet#XSS_Cheat_Sheet
escapinghtmlwithphp
Filteringuserinputwithphp
owaspPreventionCheatSheet
RULE#6-SanitizeHTMLMarkupwithaLibraryDesignedfor
theJob
● HtmlSanitizer - https://github.com/mganss/HtmlSanitizer
● OWASP AntiSamy - https://www.owasp.org/index.php/Category:
OWASP_AntiSamy_Project
● PHP Html Purifier - http://htmlpurifier.org/
● JavaScript/Node.JS Bleach - https://github.com/ecto/bleach
● Python Bleach - https://pypi.python.org/pypi/bleach
owaspPreventionCheatSheet
RULE#6-SanitizeHTMLMarkupwithaLibraryDesignedfortheJob
HtmlSanitizer - https://github.com/mganss/HtmlSanitizer
An open-source .Net library.
The HTML is cleaned with a white list approach.
owaspPreventionCheatSheet
RULE#7-PreventDOM-basedXSS
Testing Tools and Techniques
● The DOMinator Tool - A commercial tool based on the Firefox browser with modified
Spidermonkey Javascript engine that helps testers identify and verify DOM based XSS flaws
https://dominator.mindedsecurity.com/
● The DOM XSS Wiki - The start of a Knowledgebase for defining sources of attacker
controlled inputs and sinks which could potentially introduce DOM Based XSS issues. http://code.
google.com/p/domxsswiki/
● DOM Snitch - An experimental Chrome extension that enables developers and testers to
identify insecure practices commonly found in client-side code. From Google. http://code.
google.com/p/domsnitch/
Defense Techniques
https://www.owasp.org/index.php/DOM_based_XSS_Prevention_Cheat_Sheet
owaspPreventionCheatSheet:RESUME
RULE#0-NeverInsertUntrustedDataExceptinAllowedLocations
RULE#1-#5:ESCAPEUNTRUSTEDDATA
RULE#6-SanitizeHTMLMarkupwithaLibraryDesignedfortheJob
RULE#7-PreventDOM-basedXSS
owaspPreventionCheatSheet: BONUSRULES
4 BONUS RULES
Bonus Rule #1: Use HTTPOnly cookie flag
Bonus Rule #2: Implement Content Security Policy
Bonus Rule #3: Use an Auto-Escaping Template System
Bonus Rule #4: Use the X-XSS-Protection Response Header
owaspPreventionCheatSheet: BONUSRULES
BonusRule#1:UseHTTPOnlycookieflag
To help mitigate the impact of an XSS flaw on your site, OWASP also
recommends you set the HTTPOnly flag on your session cookie and any custom
cookies you have that are not accessed by any Javascript you wrote.
PHP
JAVA
PYTHON
owaspPreventionCheatSheet: BONUSRULES
BonusRule#2:ImplementContentSecurityPolicy
No execute any inline script if it isn’t declare in CSP whitelist.
Whitelists “safe” scripts hosts
default-src
script-src
style-src
img-src
frame-src
OWASP PAGE: https://www.owasp.org/index.php/Content_Security_Policy
owaspPreventionCheatSheet: BONUSRULES
BonusRule#3:UseanAuto-EscapingTemplateSystem
Many web application frameworks provide automatic contextual escaping functionality such as AngularJS
strict contextual escaping.
owaspPreventionCheatSheet: BONUSRULES
BonusRule#4:UsetheX-XSS-ProtectionResponseHeader
This HTTP response header enables the Cross-site scripting
(XSS) filter built into some modern web browsers.
Re-enable if the user disable the option for some sites.
Ifinishmywebsite
Howcanitestit?
CrossSiteScripting
1. What is it?
2. Types of XSS
3. Consequences
4. OWASP Prevention Cheat
Sheet
5. Testing my application
vulnerabilitytest
OWASP testing guide: https://www.owasp.org/index.
php/Testing_for_Cross_site_scripting
Tools
● OWASP CAL9000 - http://www.owasp.org/index.php/Category:
OWASP_CAL9000_Project
“CAL9000 includes a sortable implementation of RSnake's XSS Attacks,
Character Encoder/Decoder, HTTP Request Generator and Response
Evaluator, Testing Checklist, Automated Attack Editor and much more.”
It's hosted at: http://sec101.sourceforge.net/CAL9000/
● PHP Charset Encoder(PCE) - http://yehg.net/encoding
● HackVector(HVR) - http://www.businessinfo.co.
uk/labs/hackvertor/hackvertor.php
Thisattack...
Exist?
AccordingtotheWebHackingIncidentDatabase,11.3%ofwebattacksutilizeXSS.(2014)
Iunderstandnothing.
questions?

More Related Content

PDF
Sql Injection and XSS
PDF
XSS And SQL Injection Vulnerabilities
PDF
Introduction to Cross Site Scripting ( XSS )
PPTX
JSON SQL Injection and the Lessons Learned
PPTX
Owasp Top 10 A1: Injection
PPTX
Cross site scripting XSS
PPTX
SQL Injection and Clickjacking Attack in Web security
Sql Injection and XSS
XSS And SQL Injection Vulnerabilities
Introduction to Cross Site Scripting ( XSS )
JSON SQL Injection and the Lessons Learned
Owasp Top 10 A1: Injection
Cross site scripting XSS
SQL Injection and Clickjacking Attack in Web security

What's hot (20)

PPT
Xss talk, attack and defense
PPTX
Sql injection
PPTX
Cross Site Scripting (XSS)
PPTX
Cross Site Scripting Defense Presentation
PPTX
Cross site scripting
PPTX
Cross Site Scripting ( XSS)
PDF
New Insights into Clickjacking
PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
PPTX
Owasp Top 10 A3: Cross Site Scripting (XSS)
PPT
Php & Web Security - PHPXperts 2009
KEY
Cross Site Scripting - Mozilla Security Learning Center
PDF
The Cross Site Scripting Guide
PPTX
Reflective and Stored XSS- Cross Site Scripting
PPT
XSS - Attacks & Defense
PDF
Web Security 101
PPTX
RSA Europe 2013 OWASP Training
PPTX
04. xss and encoding
PPTX
Deep understanding on Cross-Site Scripting and SQL Injection
PPTX
Cross Site Scripting
PPT
Web application attacks using Sql injection and countermasures
Xss talk, attack and defense
Sql injection
Cross Site Scripting (XSS)
Cross Site Scripting Defense Presentation
Cross site scripting
Cross Site Scripting ( XSS)
New Insights into Clickjacking
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
Owasp Top 10 A3: Cross Site Scripting (XSS)
Php & Web Security - PHPXperts 2009
Cross Site Scripting - Mozilla Security Learning Center
The Cross Site Scripting Guide
Reflective and Stored XSS- Cross Site Scripting
XSS - Attacks & Defense
Web Security 101
RSA Europe 2013 OWASP Training
04. xss and encoding
Deep understanding on Cross-Site Scripting and SQL Injection
Cross Site Scripting
Web application attacks using Sql injection and countermasures
Ad

Viewers also liked (20)

PPT
SQL Injection in PHP
PPT
Sql Injection Tutorial!
PDF
Neutralizing SQL Injection in PostgreSQL
PPTX
Xss what the heck-!
PDF
SQL Injection - The Unknown Story
PDF
Application Security around OWASP Top 10
PPTX
Web application Security
PDF
Web application security (RIT 2014, rus)
PPTX
Owasp web security
PDF
OWASP Top 10 Overview
PDF
End to end web security
PDF
Web security: OWASP project, CSRF threat and solutions
PDF
Defcon 17-joseph mccray-adv-sql_injection
PPTX
Cross site scripting (xss)
PPTX
Cross Site Scripting(XSS)
PDF
Secure Password Storage & Management
PPT
Blind SQL Injection - Optimization Techniques
PDF
Threat Modeling for Web Applications (and other duties as assigned)
PDF
Cross site scripting
PPTX
[Wroclaw #1] Android Security Workshop
SQL Injection in PHP
Sql Injection Tutorial!
Neutralizing SQL Injection in PostgreSQL
Xss what the heck-!
SQL Injection - The Unknown Story
Application Security around OWASP Top 10
Web application Security
Web application security (RIT 2014, rus)
Owasp web security
OWASP Top 10 Overview
End to end web security
Web security: OWASP project, CSRF threat and solutions
Defcon 17-joseph mccray-adv-sql_injection
Cross site scripting (xss)
Cross Site Scripting(XSS)
Secure Password Storage & Management
Blind SQL Injection - Optimization Techniques
Threat Modeling for Web Applications (and other duties as assigned)
Cross site scripting
[Wroclaw #1] Android Security Workshop
Ad

Similar to Web Security - OWASP - SQL injection & Cross Site Scripting XSS (20)

PDF
Seminar2015Bilic_Nicole
PPT
Web security 2010
PPT
WebApps_Lecture_15.ppt
PPTX
ASP.NET Web Security
PDF
Prevention of SQL Injection Attack in Web Application with Host Language
PPTX
Sql injection
PDF
Security Awareness
DOCX
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
PPTX
.NET Security Topics
PPT
Owasp Top 10 - Owasp Pune Chapter - January 2008
PDF
IRJET - SQL Injection: Attack & Mitigation
PPTX
Sql injections (Basic bypass authentication)
PPTX
Web-Security-Application.pptx
PDF
Secure coding guidelines
PDF
SeanRobertsThesis
PDF
Security vulnerabilities related to web-based data
PPTX
Owasp Top 10 2017
DOC
Attackers Vs Programmers
PDF
2013 OWASP Top 10
Seminar2015Bilic_Nicole
Web security 2010
WebApps_Lecture_15.ppt
ASP.NET Web Security
Prevention of SQL Injection Attack in Web Application with Host Language
Sql injection
Security Awareness
WEB APPLICATION VULNERABILITIES: DAWN, DETECTION, EXPLOITATION AND DEFENSE
.NET Security Topics
Owasp Top 10 - Owasp Pune Chapter - January 2008
IRJET - SQL Injection: Attack & Mitigation
Sql injections (Basic bypass authentication)
Web-Security-Application.pptx
Secure coding guidelines
SeanRobertsThesis
Security vulnerabilities related to web-based data
Owasp Top 10 2017
Attackers Vs Programmers
2013 OWASP Top 10

More from Ivan Ortega (8)

PDF
Great Firewall & Great cannon
PPTX
Plan de empresa: Cómetec
PDF
Presentación #hackathonugr ultimo día (1)
PDF
Presentación Evenge #hackathonugr
PPTX
Proyect Evenge. Event manager
PPTX
Apache, getting the best version
PDF
Learning j query
PPTX
Implementing Telematic Services
Great Firewall & Great cannon
Plan de empresa: Cómetec
Presentación #hackathonugr ultimo día (1)
Presentación Evenge #hackathonugr
Proyect Evenge. Event manager
Apache, getting the best version
Learning j query
Implementing Telematic Services

Recently uploaded (20)

PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Understanding Forklifts - TECH EHS Solution
PDF
medical staffing services at VALiNTRY
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Online Work Permit System for Fast Permit Processing
PDF
System and Network Administraation Chapter 3
PPTX
Introduction to Artificial Intelligence
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Understanding Forklifts - TECH EHS Solution
medical staffing services at VALiNTRY
L1 - Introduction to python Backend.pptx
Operating system designcfffgfgggggggvggggggggg
VVF-Customer-Presentation2025-Ver1.9.pptx
Online Work Permit System for Fast Permit Processing
System and Network Administraation Chapter 3
Introduction to Artificial Intelligence
Which alternative to Crystal Reports is best for small or large businesses.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Softaken Excel to vCard Converter Software.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
2025 Textile ERP Trends: SAP, Odoo & Oracle
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

Web Security - OWASP - SQL injection & Cross Site Scripting XSS