SOP: Same Origin Policy
Under the poliy, a web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages have the same origin.
This policy prevents a malicious script on one page from obtaining access to sensitive data on another web page through that page's DOM.
It's very important to remember that SOP applies only to scripts. This means that resource such as images, CSS, and dynamically-loaded scrips can be accessed across origins via the corresponding HTML tags (with fonts being a notable exception).
Attackers take advantage of the fact that SOP does not apply to HTLM tags.
SOP allows simple cross-origin requests (GET/POST/HEAD) with a set of allowed custom headers only:
- Accept
- Accept-Language
- Content-Language
- Content-Type
- application/x-www-form-urlencoded
- multipart/form-data
- text/palin
Also, for cross-origin request, by default JavaScript may only access so-called 'simple' response headers:
- Cache-Control
- Content-Language
- Content-Type
- Expires
- Last-Modified
- Pragma
Any 'non-simple' requests, the browser does not make such requests right away. Before, it sends a preliminary, so-called 'preflight' request OPTIONS
, asking for permission (is at this point that CORS gets involved).