Web Same-Origin-Policy Lab

17
Web Same-Origin-Policy Lab Zutao Zhu 11/06/2009

description

Web Same-Origin-Policy Lab. Zutao Zhu 11/06/2009. Outline. Background Setting SOP. Background. Document Object Model (DOM) Cookie XMLHttpRequest HTML LiveHTTPHeaders extension for Firefox. DOM. - PowerPoint PPT Presentation

Transcript of Web Same-Origin-Policy Lab

Page 1: Web Same-Origin-Policy Lab

Web Same-Origin-Policy Lab

Zutao Zhu

11/06/2009

Page 2: Web Same-Origin-Policy Lab

Outline

• Background

• Setting

• SOP

Page 3: Web Same-Origin-Policy Lab

Background

• Document Object Model (DOM)

• Cookie

• XMLHttpRequest

• HTML

• LiveHTTPHeaders extension for Firefox

Page 4: Web Same-Origin-Policy Lab

DOM

• The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. – from wiki

Page 5: Web Same-Origin-Policy Lab

Cookie

• Cookies are placeholders for server-provided data in the web browser typically used to track sessions.

• Each cookie is a key-value pair such as "color=green" and may have some optional attributes.

• Web applications can create a cookie in the web browser using the set-cookie header in the HTTP response.

Page 6: Web Same-Origin-Policy Lab

Cookie (cont.)

• After cookies are created, web browsers attach the cookies in all the subsequent requests to the web application.

• In a JavaScript program, All the cookies in the web application can be referenced using document.cookie object.

• In cookie-based session-management schemes, web applications store the session identifier in a cookie in the web browser.

Page 7: Web Same-Origin-Policy Lab

Use Live HTTP Header (tools)

Page 8: Web Same-Origin-Policy Lab

XMLHttpRequest

• XMLHttpRequest has an important role in the AJAX web development technique. – from wiki

• http://www.w3.org/TR/XMLHttpRequest/• <script>

xhr = new XMLHttpRequest();xhr.open(POST,"http://www.originalphpbb.com/posting.php",true);

xhr.send(null);

</script>

Page 9: Web Same-Origin-Policy Lab

HTML

• http://www.w3schools.com/TAGS/tag_a.asp– frame– iframe– img– a

Page 10: Web Same-Origin-Policy Lab

LiveHTTPHeaders

• Observe the post request

• Observe the response

• Observe the cookie

Page 11: Web Same-Origin-Policy Lab

Setting

• about:config in address bar of Firefox

Page 12: Web Same-Origin-Policy Lab

SOP

• Origin: <protocol, domain, port>– Protocol: http://, file://, ftp://, etc.– Domain: microsoft.com, google.com, etc.– Port: 80, 8080, 21, 3128, etc.

• The SOP identifies each web site using its origin, and creates a context for each origin.

• For each origin, the web browser creates a context and stores the resources of the web application from the origin in the context.

• JavaScript programs from one origin are not allowed to access resources from another origin.

Page 13: Web Same-Origin-Policy Lab

Examples

• checks against the URL "http://www.example.com/dir/page.html". -- from wiki

Page 14: Web Same-Origin-Policy Lab

Resources for SOP

• Cookie

• History

• URL

• Contents

• Etc.

Page 15: Web Same-Origin-Policy Lab

URL

• When in URL bar, I input some cross domain web page, can you use “forward” and “backward”?

• Is the URL showing?

Page 16: Web Same-Origin-Policy Lab

Tags do not honor SOP

• Find out by yourself!

Page 17: Web Same-Origin-Policy Lab

Reference

• http://wikipedia.org/

• http://www.w3.org/TR/2008/WD-XMLHttpRequest2-20080930/

• http://getfirebug.com/