HAKATEMIA
02Modules

CORS (Cross-Origin Resource Sharing) - Browser Insecurity feature

Medium1H 30MIN

What is CORS?

In the last module, we went through the same origin policy (SOP), which is meant to isolate web pages in different windows or tabs of the same browser from each other, while still allowing interaction between different websites.

While SOP is a security feature, CORS (Cross-Origin Resource Sharing) is a insecurity feature. Its only purpose is to voluntarily waive some of the protections provided by SOP, and when misunderstood, it can quickly create serious security vulnerabilities in a web application.

CORS allows you to:

  • Allow a foreign web application to read the responses of HTTP requests that the application sends to your application.
  • Allowing a foreign web application to send HTTP requests with cookies to your application that normally should not be sent.
  • Allow a foreign web application to send cookie-enabled HTTP requests to your application with an HTTP verb (such as PUT) that is not normally allowed.
  • Allow a foreign web application to send HTTP requests with cookies to your application, with HTTP headers or content types (Content-Type) that are not normally allowed.
  • Allow a foreign web application to read any headers returned by your application's HTTP responses.

CORS is enabled by returning HTTP headers starting with Access-Control- in your application's HTTP responses, let's go through them next.

1 / 14
Hakatemia Pro

Learn to hack — start here

Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.