SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Downloaden Sie, um offline zu lesen
Isolating content between domains since 1996
Riyaz Walikar | @riyazwalikar | www.riyazwalikar.com
whoami
• WebAppSec Consultant, Penetration Tester, Bug Bounty
Hunter for Google, Facebook, Paypal, Mozilla and other
bounty programs
• One of the null Security Community Bangalore Chapter
Moderator
• Work at a Big4 and have conducted several Penetration Tests
all over the world.
• Spoken at several international security conferences
Imagine the Internet if
• fabekook.cn was able to read DOM values from facebook.com
from another browser tab
• gmaail.br was able to read your address book from
http://mail.google.com/mail/c/data/contactstore?type=4&ma
x=-1
• boinkofindia.com was able to read your account balance and
obtain a list of all your transactions from your internet
banking account while you are logged in.
Why is this possible?
Uh oh!
What is SOP?
• SOP restricts how a document or script loaded
from one origin can interact with a resource
from another origin
• Earliest available implementation – Netscape
Navigator 2.0 (1996)
define: origin
URL Outcome Reason
http://store.company.com/dir2/other.html Success ----
http://store.company.com/dir/inner/another.html Success ----
https://store.company.com/secure.html Failure Different protocol
http://store.company.com:81/dir/etc.html Failure Different port
http://news.company.com/dir/other.html Failure Different host
Access made from: http://store.company.com/dir/page.html
Changing 'origins'
• Setting document.domain to a suffix of the
current domain.
• Setting document.domain to another domain
altogether isn’t allowed.
Demo
A document.domain change set
Cross Origin Network Access
• Origin is permitted to send data to another
origin but not read
• Interactions between origins are placed in three
categories:
– Cross origin writes (redirects, links, form action etc.)
– Cross origin embedding (html tag with src/hrefs)
– Cross origin reads (not allowed without CORS etc.)
Cross Origin Embedding
• JavaScript <script src="..."></script>.
• CSS with <link rel="stylesheet" href="...">.
• Images with <img>.
• Media files with <video> and <audio> tags.
• Plug-ins with <object>, <embed> and <applet>.
• Fonts with @font-face.
• Anything with <frame> and <iframe>.
Prevent Cross Origin Access
• To prevent Cross origin writes, use a CSRF token
• To prevent Cross origin embedding, ensure
resource is not interpreted as any of the formats
discussed earlier.
• To prevent Cross Origin reads of a resource, ensure
that it is non-embeddable.
• For iframes the X-Frame-Options header can be
used to control access to the page.
Cross Origin Resource Sharing
• W3C specification that allows cross domain
communication from the browser
• Works by adding new HTTP headers that
describe the set of origins that are permitted to
read across domains
3 Pointers
• Browsers prevent data from being accessed
cross domain via the Same Origin Policy
• In case a page loads another domain via a
frame, X-Frame-Options can be used to control
access
• CORS is used to relax the Same Origin Policy for
legitimate and trusted requests.
References
• https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript
• http://www.w3.org/Security/wiki/Same_Origin_Policy
• http://code.google.com/p/browsersec/wiki/Part2
Allowing Cross origin resource sharing since March 2004
Riyaz Walikar | @riyazwalikar | www.riyazwalikar.com
What is CORS?
• W3C working draft that defines how the browser
and server must communicate when accessing
sources across origins
• Implemented via HTTP headers that servers set
and browsers enforce
• Can be categorized into
– Simple requests
– Requests that need a ‘preflight’
Demo
A simple cross origin request without CORS
CORS standard exchange between client and server
Why is CORS needed?
• For legitimate and trusted requests to gain access
to authorized data from other domains
• Think cross application data sharing models
• Allows data to be exchanged with trusted sites
while using a relaxed Same Origin policy mode.
• Application APIs exposed via web services and
trusted domains require CORS to be accessible
over the SOP
APIs that support CORS!
CORS – Simple Requests
• Preflight is not needed if
– Request is a HEAD/GET/POST via XHR
– No Custom headers
– Body is text/plain
• Server responds with a CORS header
– Browser determines access
– Neither the request, nor response contain cookies
CORS Headers – Simple Request
• Origin
– Header set by the client for every CORS request
– Value is the current domain that made the request
• Access-Control-Allow-Origin
– Set by the server and used by the browser to
determine if the response is to be allowed or not.
– Can be set to * to make resources public (bad
practice!)
Demo
A cross origin request with CORS for a simple request
CORS – Requests with Preflight
• Preflight requests are made if
– Request is a method other than HEAD/GET/POST
via XHR (PUT, DELETE etc.)
– Custom headers are present (X-PINGBACK etc.)
– Content-Type other than application/x-www-
form-urlencoded, multipart/form-data, or
text/plain
• A transparent request is made to the server
requesting access information using OPTIONS
CORS – Requests with Preflight
• Browser sends
– Origin header
– Access-Control-Request-Method
– Access-Control-Request-Headers – (Optional)
• Server sends set of CORS headers that the
browser uses to determine if the actual
request has to be made or not
CORS Headers – Request with Preflight
(Preflight Browser Request)
• Origin
– Header set by the client for every CORS request
– Value is the current domain that made the request
• Access-Control-Request-Method:
– Set by the browser, along with Origin.
– Value is the method that the request wants to use
• Access-Control-Request-Headers (Optional):
– A comma separated list of the custom headers being
used.
CORS Headers – Request with Preflight
(Preflight Server Response)
• Access-Control-Allow-Origin
– Same as in Simple requests
• Access-Control-Allow-Methods:
– a comma separated list of allowed methods
• Access-Control-Allow-Headers:
– a comma separated list of headers that the server will
allow.
• Access-Control-Max-Age:
– the amount of time in seconds that this preflight
request should be cached for.
Demo
A cross origin request with CORS for a preflight request
CORS (In)security?
• Several security issues arise from the improper
implementation of CORS, most commonly using a
universal allow notation (*) in the server headers
• Clients should not trust the received content
completely and eval or render content without
sanitization which could result in misplaced trust
• The application that allows CORS may become
vulnerable to CSRF attacks
CORS (In)security?
• Prolonged caching of Preflight responses could
lead to attacks arising out of abuse of the
Preflight Client Cache
• Access control decisions based on the Origin
header could result in vulnerabilities as this
can be spoofed by an attacker
CORS Security - Universal Allow
• Setting the 'Access-Control-Allow-Origin' header to *
• Effectively turns the content into a public resource,
allowing access from any domain
• Scenarios?
– An attacker can steal data from an intranet site that has set
this header to * by enticing a user to visit an attacker
controlled site on the Internet.
– An attacker can perform attacks on other remote apps via
a victim’s browser when the victim navigates to an attacker
controlled site.
Demo
A universal allow for the Access-Control-Allow-Origin header
CORS Security – Misplaced Trust
• Data exchange between two domains is based on trust
• If one of the servers involved in the exchange of data is
compromised then the model of CORS is put at risk
• Scenarios?
– An attacker can compromise site A and host malicious
content knowing site B trusts the data that site A sends to
site B via CORS request resulting in XSS and other attacks.
– An attacker can compromise site B and use the exposed
CORS functionality in site A to attack users in site A.
CSRF with CORS
• Server may process client request to change server side
data while verifying that the Origin header was set
• An attacker can use the .withCredentials = “true” property
of XHR to replay any cookies to the application on which
the victim is logged in
• Scenarios?
– An attacker sets the Origin header or uses a trusted site A to
send a non idempotent request to site B
– The victim who is logged into site B when he is viewing the
trusted site A causes site B to create a user account without
his knowledge via a CSRF attack
Demo
A CSRF attack that creates a user using a trusted site via CORS
CORS – Caching of Preflight responses
• The Access-Control-Max-Age header is set to a high
value, allowing browsers to cache Preflight
responses
• Caching the preflight response for longer duration
can pose a security risk.
• If the COR access-control policy is changed on the
server the browser would still follow the old policy
available in the Preflight Result Cache
CORS – Access Control based on Origin
• The Origin header indicates that the request is from
a particular domain, but does not guarantee it
• Spoofing the Origin header allows access to the page
if access is based on this header
• Scenarios?
– An attacker sets the Origin header to view sensitive
information that is restricted
– Attacker uses cURL to set a custom origin header:
curl --header 'origin:http://someserver.com'
http://myserver.com:90/demo/origin_spoof.php
Demo
Sensitive information revealed via weak Access Control based on
the Origin header
References
• http://www.html5rocks.com/en/tutorials/cors/
• https://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
• http://arunranga.com/examples/access-control/
• http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-
resource-sharing/
Questions?
And hopefully answers as well
Riyaz Walikar | @riyazwalikar | karniv0re@null.co.in

Weitere ähnliche Inhalte

Was ist angesagt?

Directory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksDirectory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksRaghav Bisht
 
Threat Hunting Web Shells Using Splunk
Threat Hunting Web Shells Using SplunkThreat Hunting Web Shells Using Splunk
Threat Hunting Web Shells Using Splunkjamesmbower
 
HTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsneexemil
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingInMobi Technology
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourSoroush Dalili
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraPolyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraMathias Karlsson
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?Yurii Bilyk
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionVishal Kumar
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host headerSergey Belov
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site ScriptingAli Mattash
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseSurya Subhash
 

Was ist angesagt? (20)

Directory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksDirectory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion Attacks
 
Threat Hunting Web Shells Using Splunk
Threat Hunting Web Shells Using SplunkThreat Hunting Web Shells Using Splunk
Threat Hunting Web Shells Using Splunk
 
Ssrf
SsrfSsrf
Ssrf
 
HTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versionsHTTP Request Smuggling via higher HTTP versions
HTTP Request Smuggling via higher HTTP versions
 
Reflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site ScriptingReflective and Stored XSS- Cross Site Scripting
Reflective and Stored XSS- Cross Site Scripting
 
Burp Suite Starter
Burp Suite StarterBurp Suite Starter
Burp Suite Starter
 
HTTP Security Headers
HTTP Security HeadersHTTP Security Headers
HTTP Security Headers
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraPolyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPra
 
Deep dive into ssrf
Deep dive into ssrfDeep dive into ssrf
Deep dive into ssrf
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
Owasp zap
Owasp zapOwasp zap
Owasp zap
 
Deep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL InjectionDeep understanding on Cross-Site Scripting and SQL Injection
Deep understanding on Cross-Site Scripting and SQL Injection
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
SSRF exploit the trust relationship
SSRF exploit the trust relationshipSSRF exploit the trust relationship
SSRF exploit the trust relationship
 
ZeroNights 2018 | I <"3 XSS
ZeroNights 2018 | I <"3 XSSZeroNights 2018 | I <"3 XSS
ZeroNights 2018 | I <"3 XSS
 
Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
 
Cross Site Scripting
Cross Site ScriptingCross Site Scripting
Cross Site Scripting
 
Introduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & DefenseIntroduction to CSRF Attacks & Defense
Introduction to CSRF Attacks & Defense
 
Burp suite
Burp suiteBurp suite
Burp suite
 

Andere mochten auch

Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSMichael Neale
 
Breaking The Cross Domain Barrier
Breaking The Cross Domain BarrierBreaking The Cross Domain Barrier
Breaking The Cross Domain BarrierAlex Sexton
 
Cookie testing
Cookie testingCookie testing
Cookie testingBugRaptors
 
Deploying JHipster Microservices
Deploying JHipster MicroservicesDeploying JHipster Microservices
Deploying JHipster MicroservicesJoe Kutner
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Alvaro Sanchez-Mariscal
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Matt Raible
 
REST API Security: OAuth 2.0, JWTs, and More!
REST API Security: OAuth 2.0, JWTs, and More!REST API Security: OAuth 2.0, JWTs, and More!
REST API Security: OAuth 2.0, JWTs, and More!Stormpath
 
Api gateway : To be or not to be
Api gateway : To be or not to beApi gateway : To be or not to be
Api gateway : To be or not to beJaewoo Ahn
 
JHipster for Spring Boot webinar
JHipster for Spring Boot webinarJHipster for Spring Boot webinar
JHipster for Spring Boot webinarJulien Dubois
 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application Carlo Bonamico
 
Single-Page-Application & REST security
Single-Page-Application & REST securitySingle-Page-Application & REST security
Single-Page-Application & REST securityIgor Bossenko
 
Web Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORSWeb Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORSPerfectial, LLC
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkVolker Hirsch
 

Andere mochten auch (17)

Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
 
Breaking The Cross Domain Barrier
Breaking The Cross Domain BarrierBreaking The Cross Domain Barrier
Breaking The Cross Domain Barrier
 
Jhipster
JhipsterJhipster
Jhipster
 
Cookie testing
Cookie testingCookie testing
Cookie testing
 
Deploying JHipster Microservices
Deploying JHipster MicroservicesDeploying JHipster Microservices
Deploying JHipster Microservices
 
Intro to JHipster
Intro to JHipster Intro to JHipster
Intro to JHipster
 
JHipster
JHipsterJHipster
JHipster
 
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015Stateless authentication with OAuth 2 and JWT - JavaZone 2015
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
 
REST API Security: OAuth 2.0, JWTs, and More!
REST API Security: OAuth 2.0, JWTs, and More!REST API Security: OAuth 2.0, JWTs, and More!
REST API Security: OAuth 2.0, JWTs, and More!
 
Api gateway : To be or not to be
Api gateway : To be or not to beApi gateway : To be or not to be
Api gateway : To be or not to be
 
JHipster overview
JHipster overviewJHipster overview
JHipster overview
 
JHipster for Spring Boot webinar
JHipster for Spring Boot webinarJHipster for Spring Boot webinar
JHipster for Spring Boot webinar
 
AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application AngularJS Security: defend your Single Page Application
AngularJS Security: defend your Single Page Application
 
Single-Page-Application & REST security
Single-Page-Application & REST securitySingle-Page-Application & REST security
Single-Page-Application & REST security
 
Web Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORSWeb Security - Cookies, Domains and CORS
Web Security - Cookies, Domains and CORS
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
 

Ähnlich wie CORS and (in)security

What Is Cross-Origin Resource Sharing in Web Development.pdf
What Is Cross-Origin Resource Sharing in Web Development.pdfWhat Is Cross-Origin Resource Sharing in Web Development.pdf
What Is Cross-Origin Resource Sharing in Web Development.pdfMPrashanth13
 
Html cors- lior rotkovitch
Html cors- lior rotkovitchHtml cors- lior rotkovitch
Html cors- lior rotkovitchLior Rotkovitch
 
Lesson 6 web based attacks
Lesson 6 web based attacksLesson 6 web based attacks
Lesson 6 web based attacksFrank Victory
 
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
 
Of CORS thats a thing how CORS in the cloud still kills security
Of CORS thats a thing how CORS in the cloud still kills securityOf CORS thats a thing how CORS in the cloud still kills security
Of CORS thats a thing how CORS in the cloud still kills securityJohn Varghese
 
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicyBrowsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicysubbul
 
Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5DefconRussia
 
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)Ivo Andreev
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresRoel Palmaers
 
Web Hacking Series Part 5
Web Hacking Series Part 5Web Hacking Series Part 5
Web Hacking Series Part 5Aditya Kamat
 
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 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
 
cross document messaging, html 5
cross document messaging, html 5cross document messaging, html 5
cross document messaging, html 5Kristoffer Snabb
 
Advanced Client Side Exploitation Using BeEF
Advanced Client Side Exploitation Using BeEFAdvanced Client Side Exploitation Using BeEF
Advanced Client Side Exploitation Using BeEF1N3
 
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
 
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
 
AWS Webcast - Best Practices for Content Delivery using Amazon CloudFront
AWS Webcast - Best Practices for Content Delivery using Amazon CloudFrontAWS Webcast - Best Practices for Content Delivery using Amazon CloudFront
AWS Webcast - Best Practices for Content Delivery using Amazon CloudFrontAmazon Web Services
 
Best practices for content delivery using amazon cloud front
Best practices for content delivery using amazon cloud frontBest practices for content delivery using amazon cloud front
Best practices for content delivery using amazon cloud frontAmazon Web Services
 

Ähnlich wie CORS and (in)security (20)

What Is Cross-Origin Resource Sharing in Web Development.pdf
What Is Cross-Origin Resource Sharing in Web Development.pdfWhat Is Cross-Origin Resource Sharing in Web Development.pdf
What Is Cross-Origin Resource Sharing in Web Development.pdf
 
Html cors- lior rotkovitch
Html cors- lior rotkovitchHtml cors- lior rotkovitch
Html cors- lior rotkovitch
 
Lesson 6 web based attacks
Lesson 6 web based attacksLesson 6 web based attacks
Lesson 6 web based attacks
 
Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)Hacking HTML5 offensive course (Zeronights edition)
Hacking HTML5 offensive course (Zeronights edition)
 
HTML5 - The Promise & The Peril
HTML5 - The Promise & The PerilHTML5 - The Promise & The Peril
HTML5 - The Promise & The Peril
 
Of CORS thats a thing how CORS in the cloud still kills security
Of CORS thats a thing how CORS in the cloud still kills securityOf CORS thats a thing how CORS in the cloud still kills security
Of CORS thats a thing how CORS in the cloud still kills security
 
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicyBrowsers_SameOriginPolicy_CORS_ContentSecurityPolicy
Browsers_SameOriginPolicy_CORS_ContentSecurityPolicy
 
Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5Krzysztof Kotowicz - Hacking HTML5
Krzysztof Kotowicz - Hacking HTML5
 
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
Going Beyond Cross Domain Boundaries (jQuery Bulgaria)
 
Chrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasuresChrome extensions threat analysis and countermeasures
Chrome extensions threat analysis and countermeasures
 
Web Hacking Series Part 5
Web Hacking Series Part 5Web Hacking Series Part 5
Web Hacking Series Part 5
 
Do you lose sleep at night?
Do you lose sleep at night?Do you lose sleep at night?
Do you lose sleep at night?
 
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
 
cross document messaging, html 5
cross document messaging, html 5cross document messaging, html 5
cross document messaging, html 5
 
Advanced Client Side Exploitation Using BeEF
Advanced Client Side Exploitation Using BeEFAdvanced Client Side Exploitation Using BeEF
Advanced Client Side Exploitation Using BeEF
 
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...
 
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
 
AWS Webcast - Best Practices for Content Delivery using Amazon CloudFront
AWS Webcast - Best Practices for Content Delivery using Amazon CloudFrontAWS Webcast - Best Practices for Content Delivery using Amazon CloudFront
AWS Webcast - Best Practices for Content Delivery using Amazon CloudFront
 
Best practices for content delivery using amazon cloud front
Best practices for content delivery using amazon cloud frontBest practices for content delivery using amazon cloud front
Best practices for content delivery using amazon cloud front
 
Codefest2015
Codefest2015Codefest2015
Codefest2015
 

Mehr von n|u - The Open Security Community

Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...n|u - The Open Security Community
 

Mehr von n|u - The Open Security Community (20)

Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)
 
Osint primer
Osint primerOsint primer
Osint primer
 
Nmap basics
Nmap basicsNmap basics
Nmap basics
 
Metasploit primary
Metasploit primaryMetasploit primary
Metasploit primary
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Introduction to TLS 1.3
Introduction to TLS 1.3Introduction to TLS 1.3
Introduction to TLS 1.3
 
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
 
Talking About SSRF,CRLF
Talking About SSRF,CRLFTalking About SSRF,CRLF
Talking About SSRF,CRLF
 
Building active directory lab for red teaming
Building active directory lab for red teamingBuilding active directory lab for red teaming
Building active directory lab for red teaming
 
Owning a company through their logs
Owning a company through their logsOwning a company through their logs
Owning a company through their logs
 
Introduction to shodan
Introduction to shodanIntroduction to shodan
Introduction to shodan
 
Cloud security
Cloud security Cloud security
Cloud security
 
Detecting persistence in windows
Detecting persistence in windowsDetecting persistence in windows
Detecting persistence in windows
 
Frida - Objection Tool Usage
Frida - Objection Tool UsageFrida - Objection Tool Usage
Frida - Objection Tool Usage
 
OSQuery - Monitoring System Process
OSQuery - Monitoring System ProcessOSQuery - Monitoring System Process
OSQuery - Monitoring System Process
 
DevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -SecurityDevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -Security
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
 
Linux for hackers
Linux for hackersLinux for hackers
Linux for hackers
 
Android Pentesting
Android PentestingAndroid Pentesting
Android Pentesting
 
News bytes null 200314121904
News bytes null 200314121904News bytes null 200314121904
News bytes null 200314121904
 

Kürzlich hochgeladen

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 

Kürzlich hochgeladen (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 

CORS and (in)security

  • 1. Isolating content between domains since 1996 Riyaz Walikar | @riyazwalikar | www.riyazwalikar.com
  • 2. whoami • WebAppSec Consultant, Penetration Tester, Bug Bounty Hunter for Google, Facebook, Paypal, Mozilla and other bounty programs • One of the null Security Community Bangalore Chapter Moderator • Work at a Big4 and have conducted several Penetration Tests all over the world. • Spoken at several international security conferences
  • 3. Imagine the Internet if • fabekook.cn was able to read DOM values from facebook.com from another browser tab • gmaail.br was able to read your address book from http://mail.google.com/mail/c/data/contactstore?type=4&ma x=-1 • boinkofindia.com was able to read your account balance and obtain a list of all your transactions from your internet banking account while you are logged in.
  • 4. Why is this possible?
  • 6. What is SOP? • SOP restricts how a document or script loaded from one origin can interact with a resource from another origin • Earliest available implementation – Netscape Navigator 2.0 (1996)
  • 7. define: origin URL Outcome Reason http://store.company.com/dir2/other.html Success ---- http://store.company.com/dir/inner/another.html Success ---- https://store.company.com/secure.html Failure Different protocol http://store.company.com:81/dir/etc.html Failure Different port http://news.company.com/dir/other.html Failure Different host Access made from: http://store.company.com/dir/page.html
  • 8. Changing 'origins' • Setting document.domain to a suffix of the current domain. • Setting document.domain to another domain altogether isn’t allowed.
  • 10. Cross Origin Network Access • Origin is permitted to send data to another origin but not read • Interactions between origins are placed in three categories: – Cross origin writes (redirects, links, form action etc.) – Cross origin embedding (html tag with src/hrefs) – Cross origin reads (not allowed without CORS etc.)
  • 11. Cross Origin Embedding • JavaScript <script src="..."></script>. • CSS with <link rel="stylesheet" href="...">. • Images with <img>. • Media files with <video> and <audio> tags. • Plug-ins with <object>, <embed> and <applet>. • Fonts with @font-face. • Anything with <frame> and <iframe>.
  • 12. Prevent Cross Origin Access • To prevent Cross origin writes, use a CSRF token • To prevent Cross origin embedding, ensure resource is not interpreted as any of the formats discussed earlier. • To prevent Cross Origin reads of a resource, ensure that it is non-embeddable. • For iframes the X-Frame-Options header can be used to control access to the page.
  • 13. Cross Origin Resource Sharing • W3C specification that allows cross domain communication from the browser • Works by adding new HTTP headers that describe the set of origins that are permitted to read across domains
  • 14. 3 Pointers • Browsers prevent data from being accessed cross domain via the Same Origin Policy • In case a page loads another domain via a frame, X-Frame-Options can be used to control access • CORS is used to relax the Same Origin Policy for legitimate and trusted requests.
  • 16. Allowing Cross origin resource sharing since March 2004 Riyaz Walikar | @riyazwalikar | www.riyazwalikar.com
  • 17. What is CORS? • W3C working draft that defines how the browser and server must communicate when accessing sources across origins • Implemented via HTTP headers that servers set and browsers enforce • Can be categorized into – Simple requests – Requests that need a ‘preflight’
  • 18. Demo A simple cross origin request without CORS
  • 19. CORS standard exchange between client and server
  • 20. Why is CORS needed? • For legitimate and trusted requests to gain access to authorized data from other domains • Think cross application data sharing models • Allows data to be exchanged with trusted sites while using a relaxed Same Origin policy mode. • Application APIs exposed via web services and trusted domains require CORS to be accessible over the SOP
  • 22. CORS – Simple Requests • Preflight is not needed if – Request is a HEAD/GET/POST via XHR – No Custom headers – Body is text/plain • Server responds with a CORS header – Browser determines access – Neither the request, nor response contain cookies
  • 23. CORS Headers – Simple Request • Origin – Header set by the client for every CORS request – Value is the current domain that made the request • Access-Control-Allow-Origin – Set by the server and used by the browser to determine if the response is to be allowed or not. – Can be set to * to make resources public (bad practice!)
  • 24. Demo A cross origin request with CORS for a simple request
  • 25. CORS – Requests with Preflight • Preflight requests are made if – Request is a method other than HEAD/GET/POST via XHR (PUT, DELETE etc.) – Custom headers are present (X-PINGBACK etc.) – Content-Type other than application/x-www- form-urlencoded, multipart/form-data, or text/plain • A transparent request is made to the server requesting access information using OPTIONS
  • 26. CORS – Requests with Preflight • Browser sends – Origin header – Access-Control-Request-Method – Access-Control-Request-Headers – (Optional) • Server sends set of CORS headers that the browser uses to determine if the actual request has to be made or not
  • 27. CORS Headers – Request with Preflight (Preflight Browser Request) • Origin – Header set by the client for every CORS request – Value is the current domain that made the request • Access-Control-Request-Method: – Set by the browser, along with Origin. – Value is the method that the request wants to use • Access-Control-Request-Headers (Optional): – A comma separated list of the custom headers being used.
  • 28. CORS Headers – Request with Preflight (Preflight Server Response) • Access-Control-Allow-Origin – Same as in Simple requests • Access-Control-Allow-Methods: – a comma separated list of allowed methods • Access-Control-Allow-Headers: – a comma separated list of headers that the server will allow. • Access-Control-Max-Age: – the amount of time in seconds that this preflight request should be cached for.
  • 29. Demo A cross origin request with CORS for a preflight request
  • 30. CORS (In)security? • Several security issues arise from the improper implementation of CORS, most commonly using a universal allow notation (*) in the server headers • Clients should not trust the received content completely and eval or render content without sanitization which could result in misplaced trust • The application that allows CORS may become vulnerable to CSRF attacks
  • 31. CORS (In)security? • Prolonged caching of Preflight responses could lead to attacks arising out of abuse of the Preflight Client Cache • Access control decisions based on the Origin header could result in vulnerabilities as this can be spoofed by an attacker
  • 32. CORS Security - Universal Allow • Setting the 'Access-Control-Allow-Origin' header to * • Effectively turns the content into a public resource, allowing access from any domain • Scenarios? – An attacker can steal data from an intranet site that has set this header to * by enticing a user to visit an attacker controlled site on the Internet. – An attacker can perform attacks on other remote apps via a victim’s browser when the victim navigates to an attacker controlled site.
  • 33. Demo A universal allow for the Access-Control-Allow-Origin header
  • 34. CORS Security – Misplaced Trust • Data exchange between two domains is based on trust • If one of the servers involved in the exchange of data is compromised then the model of CORS is put at risk • Scenarios? – An attacker can compromise site A and host malicious content knowing site B trusts the data that site A sends to site B via CORS request resulting in XSS and other attacks. – An attacker can compromise site B and use the exposed CORS functionality in site A to attack users in site A.
  • 35. CSRF with CORS • Server may process client request to change server side data while verifying that the Origin header was set • An attacker can use the .withCredentials = “true” property of XHR to replay any cookies to the application on which the victim is logged in • Scenarios? – An attacker sets the Origin header or uses a trusted site A to send a non idempotent request to site B – The victim who is logged into site B when he is viewing the trusted site A causes site B to create a user account without his knowledge via a CSRF attack
  • 36. Demo A CSRF attack that creates a user using a trusted site via CORS
  • 37. CORS – Caching of Preflight responses • The Access-Control-Max-Age header is set to a high value, allowing browsers to cache Preflight responses • Caching the preflight response for longer duration can pose a security risk. • If the COR access-control policy is changed on the server the browser would still follow the old policy available in the Preflight Result Cache
  • 38. CORS – Access Control based on Origin • The Origin header indicates that the request is from a particular domain, but does not guarantee it • Spoofing the Origin header allows access to the page if access is based on this header • Scenarios? – An attacker sets the Origin header to view sensitive information that is restricted – Attacker uses cURL to set a custom origin header: curl --header 'origin:http://someserver.com' http://myserver.com:90/demo/origin_spoof.php
  • 39. Demo Sensitive information revealed via weak Access Control based on the Origin header
  • 40. References • http://www.html5rocks.com/en/tutorials/cors/ • https://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity • http://arunranga.com/examples/access-control/ • http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin- resource-sharing/
  • 42. Riyaz Walikar | @riyazwalikar | karniv0re@null.co.in