Official MASTR logo MASTR Support the work
Contents
← Wiki home

Web fundamentals

Same-origin policy: the browser's boundary between sites

Scheme, host and port determine which documents share an origin.

Web2 foundation · 1 min read

Research articles and reference entries are published in English. Navigation is available in seven languages.

People & projects

In this article
  1. Why origin matters
  2. The boundary can be weakened
  3. Sources and originals

Why origin matters

The same-origin policy restricts how scripts from one origin interact with resources from another. An origin is defined by the scheme, host and port. Changing a path normally leaves the origin unchanged; changing a host or protocol does not.

This prevents an unrelated page from freely reading another site's authenticated data simply because the same browser has both open. Cross-origin embedding and sending requests are not identical to permission to read the response.

The boundary can be weakened

CORS provides a controlled way for servers to allow certain cross-origin reads. A permissive response must be assessed with the endpoint's data and credential handling. A configuration that is reasonable for public assets may be inappropriate for private account data.

The boundary also does not protect an application from scripts it deliberately loads into its own page. A third-party script can become part of the trusted execution environment. Review who can change those dependencies. Connect this to Content Security Policy and wallet-facing page content.

Sources and originals

Related reading

MASTR

Support independent research

The investigations, original evidence and guides here are free to read. Voluntary donations help fund the research and keep MASTR’s tools available.

Open wallet