Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the Same Origin Policy prevent reading GET responses?

I've done a bit of research on the web and searched through a few questions about SOP and what kinds of abuse it mitigates, but most answers are focused on preventing stolen credentials. This makes sense to me.

What doesn't make sense to me is why browsers following SOP rules block the response outright, rather than blocking cookie and local storage access.

In other words, if cookies and local storage didn't exist, would there still be a need to prevent reading GET responses? Presumably this is already what happens to some degree with <img>, <script>, and <iframe>.

like image 970
sevenflow Avatar asked Dec 16 '16 20:12

sevenflow


1 Answers

According to Mozilla Developer Network :

The same-origin policy restricts how a document or script loaded from one origin can interact with a resource from another origin. It is a critical security mechanism for isolating potentially malicious documents.

According to RFC 6454 :

Although user agents group URIs into origins, not every resource in an origin carries the same authority (in the security sense of the word "authority", not in the [RFC3986] sense). For example, an image is passive content and, therefore, carries no authority, meaning the image has no access to the objects and resources available to its origin. By contrast, an HTML document carries the full authority of its origin, and scripts within (or imported into) the document can access every resource in its origin.

To answer your question, even if cookies and local storage didn't exist, it will be still dangerous to execute unknown script in the context of the document. These scripts could issue XHR requests with the same IP as the authorized scripts and behave badly.

like image 160
Ortomala Lokni Avatar answered Nov 15 '22 10:11

Ortomala Lokni