CORS

Cross-Origin Resource Sharing

Cross-Origin Resource Sharing (CORS)

Cross-origin resource sharing (CORS) is a browser mechanism which enables controlled access to resources located outside of a given domain. It extends and adds flexibility to the same-origin policy (SOP). However, it also provides potential for cross-domain attacks, if a website's CORS policy is poorly configured and implemented. CORS is not a protection against cross-origin attacks such as cross-site request forgery (CSRF).

In any site disclosing users & passwords (or other sensitive info), try CORS.

Same-origin policy (SOP)

The same-origin policy is a restrictive cross-origin specification that limits the ability for a website to interact with resources outside of the source domain. The same-origin policy was defined many years ago in response to potentially malicious cross-domain interactions, such as one website stealing private data from another. It generally allows a domain to issue requests to other domains, but not to access the responses.

URL accessed
Access permitted?

http://normal-website.com/example/

Yes: same scheme, domain, and port

http://normal-website.com/example2/

Yes: same scheme, domain, and port

https://normal-website.com/example/

No: different scheme and port

http://en.normal-website.com/example/

No: different domain

http://www.normal-website.com/example/

No: different domain

http://normal-website.com:8080/example/

No: different port

Prerequisites

  • BURP HEADER >

    • Origin: https://evil.com OR

    • Origin: null

  • VICTIM HEADER >

    • Access-Control-Allow-Origin: https://evil.com OR

    • Access-Control-Allow-Origin: null

  • VICTIM HEADER >

    • Access-Control-Allow-Credentials: true

Access-Control-Allow-Origin: Response header indicates whether the response can be shared with requesting code from the given origin.

Access-Control-Allow-Credentials: The server allows cookies (or other user credentials) to be included on cross-origin requests.

Exploitation

This PoC requires that the respective JS script is hosted at evil.com

Tools

CORS PoC

CORS PoC 2

CORS PoC 3 - Sensitive Data Leakage

CORS JSON PoC

Last updated