SlideShare a Scribd company logo
1 of 35
CS526 Topic 11: Web Security Part 1 1
Information Security
CS 526
Topic 11
Web Security Part 1
CS526 Topic 11: Web Security Part 1 2
Readings for This Lecture
• Wikipedia
– HTTP Cookie
– Same Origin Policy
– Cross Site Scripting
– Cross Site Request Forgery
Background
• Many sensitive tasks are done through web
– Online banking, online shopping
– Database access
– System administration
• Web applications and web users are targets of
many attacks
– Cross site scripting
– SQL injection
– Cross site request forgery
– Information leakage
– Session hijacking
CS526 3
Topic 11: Web Security Part 1
Web Browser and Network
Browser
Network
• Browser sends requests
• Web site sends response pages, which may include code
• Interaction susceptible to network attacks
OS
Hardware
Web
site
request
reply
CS526 4
Topic 11: Web Security Part 1
Web Security/Privacy Issues
• Secure communications between client & server
– HTTPS (HTTP over Secure Socket Layer)
• User authentication & session management
– Cookies & other methods
• Active contents from different websites
– Protecting resources maintained by browsers
• Web application security
• Web site authentication (e.g., anti-phishing)
• Privacy concerns
CS526 Topic 11: Web Security Part 1 5
HTTP: HyperText Transfer Protocol
• Browser sends HTTP requests to the server
– Methods: GET, POST, HEAD, …
– GET: to retrieve a resource (html, image, script, css,…)
– POST: to submit a form (login, register, …)
– HEAD
• Server replies with a HTTP response
• Stateless request/response protocol
– Each request is independent of previous requests
– Statelessness has a significant impact on design and
implementation of applications
CS526 6
Topic 11: Web Security Part 1
Use Cookies to Store State Info
• Cookies
– A cookie is a name/value pair created by a website to
store information on your computer
Browser
Server
Enters form data
Response + cookies
Browser
Server
Request + cookies
Returns data
Http is stateless protocol; cookies add state
CS526 7
Topic 11: Web Security Part 1
Cookies Fields
• An example cookie from my browser
– Name session-token
– Content "s7yZiOvFm4YymG….”
– Domain .amazon.com
– Path /
– Send For Any type of connection
– Expires Monday, September 08, 2031 7:19:41 PM
CS526 Topic 11: Web Security Part 1 8
Cookies
• Stored by the browser
• Used by the web applications
– used for authenticating, tracking, and maintaining
specific information about users
• e.g., site preferences, contents of shopping carts
– data may be sensitive
– may be used to gather information about specific
users
• Cookie ownership
– Once a cookie is saved on your computer, only the
website that created the cookie can read it
CS526 9
Topic 11: Web Security Part 1
Web Authentication via Cookies
• HTTP is stateless
– How does the server recognize a user who has signed in?
• Servers can use cookies to store state on client
– After client successfully authenticates, server computes
an authenticator and gives it to browser in a cookie
• Client cannot forge authenticator on his own (session id)
– With each request, browser presents the cookie
– Server verifies the authenticator
CS526 10
Topic 11: Web Security Part 1
A Typical Session with Cookies
client server
POST /login.cgi
Set-Cookie:authenticator
GET /restricted.html
Cookie:authenticator
Restricted content
Verify that this
client is authorized
Check validity of
authenticator
Authenticators must be unforgeable and tamper-proof
(malicious clients shouldn’t be able to modify an existing authenticator)
How to design it?
CS526 11
Topic 11: Web Security Part 1
Cross Site Scripting
CS526 Topic 11: Web Security Part 1 12
Client Side Scripting
• Web pages (HTML) can embed dynamic contents
(code) that can be executed on the browser
• JavaScript
– embedded in web pages and executed inside browser
• Java applets
– small pieces of Java bytecodes that execute in
browsers
• Browser extensions (plug-ins) provide further
client-side programming abilities
– E.g., Flash
CS526 13
Topic 11: Web Security Part 1
HTML and Scripting
<html>
…
<P>
<script>
var num1, num2, sum
num1 = prompt("Enter first number")
num2 = prompt("Enter second number")
sum = parseInt(num1) + parseInt(num2)
alert("Sum = " + sum)
</script>
…
</html>
Browser receives content, displays
HTML and executes scripts
CS526 14
Topic 11: Web Security Part 1
Scripts are Powerful
• Client-side scripting is powerful and flexible, and
can access the following resources
– Local files on the client-side host
• read / write local files
– Webpage resources maintained by the browser
• Cookies
• Domain Object Model (DOM) objects
– steal private information
– control what users see
– impersonate the user
– Communicating with websites (via XMLHttpRequest)
CS526 15
Topic 11: Web Security Part 1
CS526 Topic 11: Web Security Part 1 16
Domain Object
Model (DOM)
• Object-oriented model
to represent webpages
that allow
programming access
in Javascript
Browser as an Operating System
• Web users visit multiple websites simultaneously
• A browser serves web pages (which may contain
programs) from different web domains
– i.e., a browser runs programs provided by mutually untrusted
entities
– Running code one does not know/trust is dangerous
– A browser also maintains resources created/updated by web
domains
• Browser must confine (sandbox) these scripts so that
they cannot access arbitrary local resources
• Browser must have a security policy to manage/protect
browser-maintained resources and to provide separation
among mutually untrusted scripts
CS526 Topic 11: Web Security Part 1 17
Sandbox
• A security mechanism for separating/limiting running
programs
– Running untrusted programs.
• E.g., javascripts in webpages, mobile apps
– Running programs that are likely to be exploited.
• E.g., network daemon programs
• Implementation: Clearly identify what resources a
program needs and cut off the rest
– Examples include operating system–level virtualization (such as
Unix chroot), virtual machine monitors (VMMs), Java applets,
CS526 Topic 11: Web Security Part 1 18
Same Origin Policy
• The basic security model enforced in the browser
• SoP isolates the scripts and resources downloaded
from different origins
– E.g., evil.org scripts cannot access bank.com resources
• Use origin as the security principal
– Note that the concept of user accounts does not apply
here as security principals
• Origin = domain name + protocol + port
– all three must be equal for origin to be considered the
same
CS526 19
Topic 11: Web Security Part 1
Same Original Policy: What it Controls
• Same-origin policy applies to the following accesses:
– manipulating browser windows
– URLs requested via the XmlHttpRequest
– manipulating frames (including inline frames)
– manipulating documents (included using the object tag)
– manipulating cookies
CS526 21
Topic 11: Web Security Part 1
Problems with S-O Policy
• Poorly enforced on some browsers
– Particularly older browsers
• Limitations if site hosts unrelated pages
– Example: Web server often hosts sites for unrelated parties
• http://www.example.com/account/
• http://www.example.com/otheraccount/
– Same-origin policy allows script on one page to access properties
of document from another
• Can be bypassed in Cross-Site-Scripting attacks
• Usability: Sometimes prevents desirable cross-origin
resource sharing
CS526 22
Topic 11: Web Security Part 1
Browser Architecture: One Process
versus Multiple Processes
• Most processes (e.g., Firefox, Internet Explorer) use one
process for a web browser
– Multiple threads are used for rendering different webpages
• Chrome uses multiple processes
– Use OS protection mechanism to ensure that webpages from
different sites cannot easily interact
• Because they run in different processes
– Reliability advantage: crashing in rendering one website doesn’t
affect another
– Security advantage: vulnerability in rendering does not
compromise other sites; isolate plug-ins
– Uses 3 types of processes: browser, renderers, plug-
ins
CS526 Topic 11: Web Security Part 1 23
What will the following program
output?
#include <stdio.h>
void main() {
int x;
int y;
y = (x = 3) + (x = 4);
printf("%d %dn", x, y);
}
CS526 Topic 11: Web Security Part 1 24
Cross Site Scripting (XSS)
• Recall the basics
– scripts embedded in web pages run in browsers
– scripts can access cookies
• get private information
– and manipulate DOM objects
• controls what users see
– scripts controlled by the same-origin policy
• Why would XSS occur
– Web applications often take user inputs and use them
as part of webpage (these inputs can have scripts)
CS526 25
Topic 11: Web Security Part 1
How XSS Works on Online Blog
• Everyone can post comments, which will be displayed to
everyone who view the post
• Attacker posts a malicious comment that includes scripts
(which reads local authentication credentials and send of
to the attacker)
• Anyone who view the post can have local authentication
cookies stolen
• Web apps will check that posts do not include scripts,
but the check sometimes fail.
• Bug in the web application. Attack happens in browser.
CS526 Topic 11: Web Security Part 1 26
Effect of the Attack
• Attacker can execute arbitrary scripts in browser
• Can manipulate any DOM component on
victim.com
– Control links on page
– Control form fields (e.g. password field) on this page
and linked pages.
• Can infect other users: MySpace.com worm.
CS526 27
Topic 11: Web Security Part 1
MySpace.com (Samy worm)
• Users can post HTML on their pages
– MySpace.com ensures HTML contains no
<script>, <body>, onclick, <a href=javascript://>
– However, attacker find out that a way to include
Javascript within CSS tags:
<div style=“background:url(‘javascript:alert(1)’)”>
And can hide “javascript” as “javanscript”
• With careful javascript hacking:
– Samy’s worm: infects anyone who visits an infected
MySpace page … and adds Samy as a friend.
– Samy had millions of friends within 24 hours.
• More info: http://namb.la/popular/tech.html
CS526 28
Topic 11: Web Security Part 1
Avoiding XSS bugs (PHP)
• Main problem:
– Input checking is difficult --- many ways to inject
scripts into HTML.
• Preprocess input from user before echoing it
• PHP: htmlspecialchars(string)
&  &amp; "  &quot; '  &#039;
<  &lt; >  &gt;
– htmlspecialchars(
"<a href='test'>Test</a>", ENT_QUOTES);
Outputs:
&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;
CS526 29
Topic 11: Web Security Part 1
Avoiding XSS bugs (ASP.NET)
• ASP.NET 1.1:
– Server.HtmlEncode(string)
• Similar to PHP htmlspecialchars
– validateRequest: (on by default)
• Crashes page if finds <script> in POST data.
• Looks for hardcoded list of patterns.
• Can be disabled:
<%@ Page validateRequest=“false" %>
CS526 30
Topic 11: Web Security Part 1
CS526 Topic 11: Web Security Part 1 31
Cross site request
forgery
Cross site request forgery (abbrev.
CSRF or XSRF)
• Also known as one click attack or session
riding
• Effect: Transmits unauthorized commands from a
user who has logged in to a website to the
website.
• Recall that a browser attaches cookies set by
domain X to a request sent to domain X; the
request may be from another domain
– Site Y redirects you to facebook; if you already logged
in, the cookie is attached by the browser
CS526 32
Topic 11: Web Security Part 1
CSRF Explained
• Example:
– User logs in to bank.com. Forgets to sign off.
– Session cookie remains in browser state
– Then user visits another site containing:
<form name=F action=http://bank.com/BillPay.php>
<input name=recipient value=badguy> …
<script> document.F.submit(); </script>
– Browser sends user auth cookie with request
• Transaction will be fulfilled
• Problem:
– The browser is a confused deputy; it is serving both the
websites and the user and gets confused who initiated a
request
CS526 33
Topic 11: Web Security Part 1
Real World CSRF Vulnerabilities
• Gmail
• NY Times
• ING Direct (4th largest saving bank in US)
• YouTube
• Various DSL Routers
• Purdue WebMail
• PEFCU
• Purdue CS Portal
• …
CS526 34
Topic 11: Web Security Part 1
Prevention
• Server side:
– use cookie + hidden fields to authenticate a web form
• hidden fields values need to be unpredictable and user-
specific; thus someone forging the request need to guess the
hidden field values
– requires the body of the POST request to contain cookies
• Since browser does not add the cookies automatically,
malicious script needs to add the cookies, but they do not
have access because of Same Origin Policy
• User side:
– logging off one site before using others
– selective sending of authentication tokens with requests (may
cause some disruption in using websites)
CS526 35
Topic 11: Web Security Part 1
CS526 Topic 11: Web Security Part 1 36
Coming Attractions …
• More Web Security Issues
– SQL injection
– Side channel information leakage
– Cookie privacy issues

More Related Content

Similar to 14_526_topic11.ppt

Blackhat11 shreeraj reverse_engineering_browser
Blackhat11 shreeraj reverse_engineering_browserBlackhat11 shreeraj reverse_engineering_browser
Blackhat11 shreeraj reverse_engineering_browserShreeraj Shah
 
02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptx02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptxssuserec53e73
 
CompTIASecPLUSAASS-part4 - Edited (1).pptx
CompTIASecPLUSAASS-part4 - Edited (1).pptxCompTIASecPLUSAASS-part4 - Edited (1).pptx
CompTIASecPLUSAASS-part4 - Edited (1).pptxmohedkhadar60
 
OWASP top 10-2013
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013tmd800
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)Sam Bowne
 
How to Ensure You're Launching the Most Secure Website - Michael Tremante
How to Ensure You're Launching the Most Secure Website - Michael TremanteHow to Ensure You're Launching the Most Secure Website - Michael Tremante
How to Ensure You're Launching the Most Secure Website - Michael TremanteWP Engine
 
Securing your web application through HTTP headers
Securing your web application through HTTP headersSecuring your web application through HTTP headers
Securing your web application through HTTP headersAndre N. Klingsheim
 
ISM Chapter 3 Application and Network Attacks.ppt
ISM Chapter 3 Application and Network Attacks.pptISM Chapter 3 Application and Network Attacks.ppt
ISM Chapter 3 Application and Network Attacks.pptSajjadAbdullah4
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)Sam Bowne
 
Browser Security – Issues and Best Practices1Outli
Browser Security – Issues and Best Practices1OutliBrowser Security – Issues and Best Practices1Outli
Browser Security – Issues and Best Practices1OutliVannaSchrader3
 
Ch 10: Hacking Web Servers
Ch 10: Hacking Web ServersCh 10: Hacking Web Servers
Ch 10: Hacking Web ServersSam Bowne
 
Ch 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS VulnerabilitesCh 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS VulnerabilitesSam Bowne
 
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
 
Do you lose sleep at night?
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?Nathan Van Gheem
 
CNIT 123: 8: Desktop and Server OS Vulnerabilites
CNIT 123: 8: Desktop and Server OS VulnerabilitesCNIT 123: 8: Desktop and Server OS Vulnerabilites
CNIT 123: 8: Desktop and Server OS VulnerabilitesSam Bowne
 

Similar to 14_526_topic11.ppt (20)

Blackhat11 shreeraj reverse_engineering_browser
Blackhat11 shreeraj reverse_engineering_browserBlackhat11 shreeraj reverse_engineering_browser
Blackhat11 shreeraj reverse_engineering_browser
 
02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptx02-browser-sec-model-sop.pptx
02-browser-sec-model-sop.pptx
 
CompTIASecPLUSAASS-part4 - Edited (1).pptx
CompTIASecPLUSAASS-part4 - Edited (1).pptxCompTIASecPLUSAASS-part4 - Edited (1).pptx
CompTIASecPLUSAASS-part4 - Edited (1).pptx
 
Isys20261 lecture 09
Isys20261 lecture 09Isys20261 lecture 09
Isys20261 lecture 09
 
OWASP top 10-2013
OWASP top 10-2013OWASP top 10-2013
OWASP top 10-2013
 
Web Security
Web SecurityWeb Security
Web Security
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
 
How to Ensure You're Launching the Most Secure Website - Michael Tremante
How to Ensure You're Launching the Most Secure Website - Michael TremanteHow to Ensure You're Launching the Most Secure Website - Michael Tremante
How to Ensure You're Launching the Most Secure Website - Michael Tremante
 
Securing your web application through HTTP headers
Securing your web application through HTTP headersSecuring your web application through HTTP headers
Securing your web application through HTTP headers
 
ISM Chapter 3 Application and Network Attacks.ppt
ISM Chapter 3 Application and Network Attacks.pptISM Chapter 3 Application and Network Attacks.ppt
ISM Chapter 3 Application and Network Attacks.ppt
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
 
Browser Security – Issues and Best Practices1Outli
Browser Security – Issues and Best Practices1OutliBrowser Security – Issues and Best Practices1Outli
Browser Security – Issues and Best Practices1Outli
 
Ch 10: Hacking Web Servers
Ch 10: Hacking Web ServersCh 10: Hacking Web Servers
Ch 10: Hacking Web Servers
 
Ch 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS VulnerabilitesCh 8: Desktop and Server OS Vulnerabilites
Ch 8: Desktop and Server OS Vulnerabilites
 
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...
 
Owasp top 10 2017
Owasp top 10 2017Owasp top 10 2017
Owasp top 10 2017
 
Web browser architecture.pptx
Web browser architecture.pptxWeb browser architecture.pptx
Web browser architecture.pptx
 
Do you lose sleep at night?
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?
 
Owasp
OwaspOwasp
Owasp
 
CNIT 123: 8: Desktop and Server OS Vulnerabilites
CNIT 123: 8: Desktop and Server OS VulnerabilitesCNIT 123: 8: Desktop and Server OS Vulnerabilites
CNIT 123: 8: Desktop and Server OS Vulnerabilites
 

More from ssuserec53e73

Threats in network that can be noted in security
Threats in network that can be noted in securityThreats in network that can be noted in security
Threats in network that can be noted in securityssuserec53e73
 
Lsn21_NumPy in data science using python
Lsn21_NumPy in data science using pythonLsn21_NumPy in data science using python
Lsn21_NumPy in data science using pythonssuserec53e73
 
OpenSecure socket layerin cyber security
OpenSecure socket layerin cyber securityOpenSecure socket layerin cyber security
OpenSecure socket layerin cyber securityssuserec53e73
 
Hash functions, digital signatures and hmac
Hash functions, digital signatures and hmacHash functions, digital signatures and hmac
Hash functions, digital signatures and hmacssuserec53e73
 
Asian Elephant Adaptations - Chelsea P..pptx
Asian Elephant Adaptations - Chelsea P..pptxAsian Elephant Adaptations - Chelsea P..pptx
Asian Elephant Adaptations - Chelsea P..pptxssuserec53e73
 
Module 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptxModule 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptxssuserec53e73
 
50134147-Knowledge-Representation-Using-Rules.ppt
50134147-Knowledge-Representation-Using-Rules.ppt50134147-Knowledge-Representation-Using-Rules.ppt
50134147-Knowledge-Representation-Using-Rules.pptssuserec53e73
 
IoT Reference Architecture.pptx
IoT Reference Architecture.pptxIoT Reference Architecture.pptx
IoT Reference Architecture.pptxssuserec53e73
 
Introduction to measurement.pptx
Introduction to measurement.pptxIntroduction to measurement.pptx
Introduction to measurement.pptxssuserec53e73
 
ML-DecisionTrees.ppt
ML-DecisionTrees.pptML-DecisionTrees.ppt
ML-DecisionTrees.pptssuserec53e73
 

More from ssuserec53e73 (20)

Threats in network that can be noted in security
Threats in network that can be noted in securityThreats in network that can be noted in security
Threats in network that can be noted in security
 
Lsn21_NumPy in data science using python
Lsn21_NumPy in data science using pythonLsn21_NumPy in data science using python
Lsn21_NumPy in data science using python
 
OpenSecure socket layerin cyber security
OpenSecure socket layerin cyber securityOpenSecure socket layerin cyber security
OpenSecure socket layerin cyber security
 
Hash functions, digital signatures and hmac
Hash functions, digital signatures and hmacHash functions, digital signatures and hmac
Hash functions, digital signatures and hmac
 
Asian Elephant Adaptations - Chelsea P..pptx
Asian Elephant Adaptations - Chelsea P..pptxAsian Elephant Adaptations - Chelsea P..pptx
Asian Elephant Adaptations - Chelsea P..pptx
 
Module 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptxModule 10-Introduction to OOP.pptx
Module 10-Introduction to OOP.pptx
 
unit-1-l3.ppt
unit-1-l3.pptunit-1-l3.ppt
unit-1-l3.ppt
 
AI.ppt
AI.pptAI.ppt
AI.ppt
 
50134147-Knowledge-Representation-Using-Rules.ppt
50134147-Knowledge-Representation-Using-Rules.ppt50134147-Knowledge-Representation-Using-Rules.ppt
50134147-Knowledge-Representation-Using-Rules.ppt
 
Dr Jose Reena K.pdf
Dr Jose Reena K.pdfDr Jose Reena K.pdf
Dr Jose Reena K.pdf
 
Enumeration.pptx
Enumeration.pptxEnumeration.pptx
Enumeration.pptx
 
footscan.PPT
footscan.PPTfootscan.PPT
footscan.PPT
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
Unit 1 iot.pptx
Unit 1 iot.pptxUnit 1 iot.pptx
Unit 1 iot.pptx
 
IoT Reference Architecture.pptx
IoT Reference Architecture.pptxIoT Reference Architecture.pptx
IoT Reference Architecture.pptx
 
patent ppt.pptx
patent ppt.pptxpatent ppt.pptx
patent ppt.pptx
 
Introduction to measurement.pptx
Introduction to measurement.pptxIntroduction to measurement.pptx
Introduction to measurement.pptx
 
ML-DecisionTrees.ppt
ML-DecisionTrees.pptML-DecisionTrees.ppt
ML-DecisionTrees.ppt
 
ML_Lecture_7.ppt
ML_Lecture_7.pptML_Lecture_7.ppt
ML_Lecture_7.ppt
 
070308-simmons.ppt
070308-simmons.ppt070308-simmons.ppt
070308-simmons.ppt
 

Recently uploaded

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 

Recently uploaded (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

14_526_topic11.ppt

  • 1. CS526 Topic 11: Web Security Part 1 1 Information Security CS 526 Topic 11 Web Security Part 1
  • 2. CS526 Topic 11: Web Security Part 1 2 Readings for This Lecture • Wikipedia – HTTP Cookie – Same Origin Policy – Cross Site Scripting – Cross Site Request Forgery
  • 3. Background • Many sensitive tasks are done through web – Online banking, online shopping – Database access – System administration • Web applications and web users are targets of many attacks – Cross site scripting – SQL injection – Cross site request forgery – Information leakage – Session hijacking CS526 3 Topic 11: Web Security Part 1
  • 4. Web Browser and Network Browser Network • Browser sends requests • Web site sends response pages, which may include code • Interaction susceptible to network attacks OS Hardware Web site request reply CS526 4 Topic 11: Web Security Part 1
  • 5. Web Security/Privacy Issues • Secure communications between client & server – HTTPS (HTTP over Secure Socket Layer) • User authentication & session management – Cookies & other methods • Active contents from different websites – Protecting resources maintained by browsers • Web application security • Web site authentication (e.g., anti-phishing) • Privacy concerns CS526 Topic 11: Web Security Part 1 5
  • 6. HTTP: HyperText Transfer Protocol • Browser sends HTTP requests to the server – Methods: GET, POST, HEAD, … – GET: to retrieve a resource (html, image, script, css,…) – POST: to submit a form (login, register, …) – HEAD • Server replies with a HTTP response • Stateless request/response protocol – Each request is independent of previous requests – Statelessness has a significant impact on design and implementation of applications CS526 6 Topic 11: Web Security Part 1
  • 7. Use Cookies to Store State Info • Cookies – A cookie is a name/value pair created by a website to store information on your computer Browser Server Enters form data Response + cookies Browser Server Request + cookies Returns data Http is stateless protocol; cookies add state CS526 7 Topic 11: Web Security Part 1
  • 8. Cookies Fields • An example cookie from my browser – Name session-token – Content "s7yZiOvFm4YymG….” – Domain .amazon.com – Path / – Send For Any type of connection – Expires Monday, September 08, 2031 7:19:41 PM CS526 Topic 11: Web Security Part 1 8
  • 9. Cookies • Stored by the browser • Used by the web applications – used for authenticating, tracking, and maintaining specific information about users • e.g., site preferences, contents of shopping carts – data may be sensitive – may be used to gather information about specific users • Cookie ownership – Once a cookie is saved on your computer, only the website that created the cookie can read it CS526 9 Topic 11: Web Security Part 1
  • 10. Web Authentication via Cookies • HTTP is stateless – How does the server recognize a user who has signed in? • Servers can use cookies to store state on client – After client successfully authenticates, server computes an authenticator and gives it to browser in a cookie • Client cannot forge authenticator on his own (session id) – With each request, browser presents the cookie – Server verifies the authenticator CS526 10 Topic 11: Web Security Part 1
  • 11. A Typical Session with Cookies client server POST /login.cgi Set-Cookie:authenticator GET /restricted.html Cookie:authenticator Restricted content Verify that this client is authorized Check validity of authenticator Authenticators must be unforgeable and tamper-proof (malicious clients shouldn’t be able to modify an existing authenticator) How to design it? CS526 11 Topic 11: Web Security Part 1
  • 12. Cross Site Scripting CS526 Topic 11: Web Security Part 1 12
  • 13. Client Side Scripting • Web pages (HTML) can embed dynamic contents (code) that can be executed on the browser • JavaScript – embedded in web pages and executed inside browser • Java applets – small pieces of Java bytecodes that execute in browsers • Browser extensions (plug-ins) provide further client-side programming abilities – E.g., Flash CS526 13 Topic 11: Web Security Part 1
  • 14. HTML and Scripting <html> … <P> <script> var num1, num2, sum num1 = prompt("Enter first number") num2 = prompt("Enter second number") sum = parseInt(num1) + parseInt(num2) alert("Sum = " + sum) </script> … </html> Browser receives content, displays HTML and executes scripts CS526 14 Topic 11: Web Security Part 1
  • 15. Scripts are Powerful • Client-side scripting is powerful and flexible, and can access the following resources – Local files on the client-side host • read / write local files – Webpage resources maintained by the browser • Cookies • Domain Object Model (DOM) objects – steal private information – control what users see – impersonate the user – Communicating with websites (via XMLHttpRequest) CS526 15 Topic 11: Web Security Part 1
  • 16. CS526 Topic 11: Web Security Part 1 16 Domain Object Model (DOM) • Object-oriented model to represent webpages that allow programming access in Javascript
  • 17. Browser as an Operating System • Web users visit multiple websites simultaneously • A browser serves web pages (which may contain programs) from different web domains – i.e., a browser runs programs provided by mutually untrusted entities – Running code one does not know/trust is dangerous – A browser also maintains resources created/updated by web domains • Browser must confine (sandbox) these scripts so that they cannot access arbitrary local resources • Browser must have a security policy to manage/protect browser-maintained resources and to provide separation among mutually untrusted scripts CS526 Topic 11: Web Security Part 1 17
  • 18. Sandbox • A security mechanism for separating/limiting running programs – Running untrusted programs. • E.g., javascripts in webpages, mobile apps – Running programs that are likely to be exploited. • E.g., network daemon programs • Implementation: Clearly identify what resources a program needs and cut off the rest – Examples include operating system–level virtualization (such as Unix chroot), virtual machine monitors (VMMs), Java applets, CS526 Topic 11: Web Security Part 1 18
  • 19. Same Origin Policy • The basic security model enforced in the browser • SoP isolates the scripts and resources downloaded from different origins – E.g., evil.org scripts cannot access bank.com resources • Use origin as the security principal – Note that the concept of user accounts does not apply here as security principals • Origin = domain name + protocol + port – all three must be equal for origin to be considered the same CS526 19 Topic 11: Web Security Part 1
  • 20. Same Original Policy: What it Controls • Same-origin policy applies to the following accesses: – manipulating browser windows – URLs requested via the XmlHttpRequest – manipulating frames (including inline frames) – manipulating documents (included using the object tag) – manipulating cookies CS526 21 Topic 11: Web Security Part 1
  • 21. Problems with S-O Policy • Poorly enforced on some browsers – Particularly older browsers • Limitations if site hosts unrelated pages – Example: Web server often hosts sites for unrelated parties • http://www.example.com/account/ • http://www.example.com/otheraccount/ – Same-origin policy allows script on one page to access properties of document from another • Can be bypassed in Cross-Site-Scripting attacks • Usability: Sometimes prevents desirable cross-origin resource sharing CS526 22 Topic 11: Web Security Part 1
  • 22. Browser Architecture: One Process versus Multiple Processes • Most processes (e.g., Firefox, Internet Explorer) use one process for a web browser – Multiple threads are used for rendering different webpages • Chrome uses multiple processes – Use OS protection mechanism to ensure that webpages from different sites cannot easily interact • Because they run in different processes – Reliability advantage: crashing in rendering one website doesn’t affect another – Security advantage: vulnerability in rendering does not compromise other sites; isolate plug-ins – Uses 3 types of processes: browser, renderers, plug- ins CS526 Topic 11: Web Security Part 1 23
  • 23. What will the following program output? #include <stdio.h> void main() { int x; int y; y = (x = 3) + (x = 4); printf("%d %dn", x, y); } CS526 Topic 11: Web Security Part 1 24
  • 24. Cross Site Scripting (XSS) • Recall the basics – scripts embedded in web pages run in browsers – scripts can access cookies • get private information – and manipulate DOM objects • controls what users see – scripts controlled by the same-origin policy • Why would XSS occur – Web applications often take user inputs and use them as part of webpage (these inputs can have scripts) CS526 25 Topic 11: Web Security Part 1
  • 25. How XSS Works on Online Blog • Everyone can post comments, which will be displayed to everyone who view the post • Attacker posts a malicious comment that includes scripts (which reads local authentication credentials and send of to the attacker) • Anyone who view the post can have local authentication cookies stolen • Web apps will check that posts do not include scripts, but the check sometimes fail. • Bug in the web application. Attack happens in browser. CS526 Topic 11: Web Security Part 1 26
  • 26. Effect of the Attack • Attacker can execute arbitrary scripts in browser • Can manipulate any DOM component on victim.com – Control links on page – Control form fields (e.g. password field) on this page and linked pages. • Can infect other users: MySpace.com worm. CS526 27 Topic 11: Web Security Part 1
  • 27. MySpace.com (Samy worm) • Users can post HTML on their pages – MySpace.com ensures HTML contains no <script>, <body>, onclick, <a href=javascript://> – However, attacker find out that a way to include Javascript within CSS tags: <div style=“background:url(‘javascript:alert(1)’)”> And can hide “javascript” as “javanscript” • With careful javascript hacking: – Samy’s worm: infects anyone who visits an infected MySpace page … and adds Samy as a friend. – Samy had millions of friends within 24 hours. • More info: http://namb.la/popular/tech.html CS526 28 Topic 11: Web Security Part 1
  • 28. Avoiding XSS bugs (PHP) • Main problem: – Input checking is difficult --- many ways to inject scripts into HTML. • Preprocess input from user before echoing it • PHP: htmlspecialchars(string) &  &amp; "  &quot; '  &#039; <  &lt; >  &gt; – htmlspecialchars( "<a href='test'>Test</a>", ENT_QUOTES); Outputs: &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt; CS526 29 Topic 11: Web Security Part 1
  • 29. Avoiding XSS bugs (ASP.NET) • ASP.NET 1.1: – Server.HtmlEncode(string) • Similar to PHP htmlspecialchars – validateRequest: (on by default) • Crashes page if finds <script> in POST data. • Looks for hardcoded list of patterns. • Can be disabled: <%@ Page validateRequest=“false" %> CS526 30 Topic 11: Web Security Part 1
  • 30. CS526 Topic 11: Web Security Part 1 31 Cross site request forgery
  • 31. Cross site request forgery (abbrev. CSRF or XSRF) • Also known as one click attack or session riding • Effect: Transmits unauthorized commands from a user who has logged in to a website to the website. • Recall that a browser attaches cookies set by domain X to a request sent to domain X; the request may be from another domain – Site Y redirects you to facebook; if you already logged in, the cookie is attached by the browser CS526 32 Topic 11: Web Security Part 1
  • 32. CSRF Explained • Example: – User logs in to bank.com. Forgets to sign off. – Session cookie remains in browser state – Then user visits another site containing: <form name=F action=http://bank.com/BillPay.php> <input name=recipient value=badguy> … <script> document.F.submit(); </script> – Browser sends user auth cookie with request • Transaction will be fulfilled • Problem: – The browser is a confused deputy; it is serving both the websites and the user and gets confused who initiated a request CS526 33 Topic 11: Web Security Part 1
  • 33. Real World CSRF Vulnerabilities • Gmail • NY Times • ING Direct (4th largest saving bank in US) • YouTube • Various DSL Routers • Purdue WebMail • PEFCU • Purdue CS Portal • … CS526 34 Topic 11: Web Security Part 1
  • 34. Prevention • Server side: – use cookie + hidden fields to authenticate a web form • hidden fields values need to be unpredictable and user- specific; thus someone forging the request need to guess the hidden field values – requires the body of the POST request to contain cookies • Since browser does not add the cookies automatically, malicious script needs to add the cookies, but they do not have access because of Same Origin Policy • User side: – logging off one site before using others – selective sending of authentication tokens with requests (may cause some disruption in using websites) CS526 35 Topic 11: Web Security Part 1
  • 35. CS526 Topic 11: Web Security Part 1 36 Coming Attractions … • More Web Security Issues – SQL injection – Side channel information leakage – Cookie privacy issues

Editor's Notes

  1. What should the authenticator depends upon? User name, current time
  2. Do not want one site to manipulate another site’s web page. XmlHttpRequest is an API that can be used by web browser scripting languages to transfer XML and other text data to and from a web server using HTTP, by establishing an independent and asynchronous communication channel. used by AJAX