Lably
Skip to content

Same-origin policy

Security measure for client-side scripting

  • 8 min read
  • 7 chapters

Related on Lably

Through Web application and JavaScript

This mechanism bears a particular significance for modern web applications that extensively depend on HTTPS cookies to maintain authenticated user sessions, as servers act based on the HTTP cookie information to reveal sensitive information or perform state-changing actions. A strict separation between content provided by unrelated sites must be maintained on the client-side to prevent the loss of data confidentiality or integrity.

The same-origin policy applies only to scripts. This means that resources such as images, CSS, and dynamically loaded scripts can be accessed across origins via the corresponding HTML tags (with fonts being a notable exception). Attacks take advantage of the fact that the same origin policy does not apply to HTML tags.

There are some mechanisms available to relax the SOP; one of them is cross-origin resource sharing (CORS).

History

The concept of same-origin policy was introduced by Netscape Navigator 2.02 in 1995, shortly after the introduction of JavaScript in Netscape 2.0. JavaScript enabled scripting on web pages, and in particular programmatic access to the DOM.

The policy was originally designed to protect access to the DOM, but has since been broadened to protect sensitive parts of the global JavaScript object.

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Computing and communication