Your site's functions can now remember things: a key-value store for every site, on Pro and Team.Build an app with sign-in

Why user content never shares a domain with the dashboard

GitHub serves pages on github.io, not on github.com. Netlify uses netlify.app, not netlify.com. It looks like branding. It is a cookie boundary, and getting it wrong hands your dashboard to anyone who can upload a file.

Every service that hosts other people's files does the same thing, and it is worth knowing why before you build one.

  • GitHub's dashboard is github.com; pages are served from github.io.
  • Netlify's is netlify.com; sites are on netlify.app.
  • Ours is dropto.run; the sites are on dropto.live.

Two different registrable domains, not two subdomains of one. That is not a branding decision that happened to come out consistent three times. It is the only arrangement in which uploaded JavaScript cannot reach the session of the person who uploaded it.

What goes wrong on a shared domain

Suppose we had done the obvious thing: dashboard on example.com, and every customer site on {name}.example.com.

A customer publishes a page. That page can contain whatever JavaScript they want — that is the product. And a page served from evil.example.com can set a cookie scoped to .example.com, its parent, because the browser's rule for cookies is about the domain hierarchy rather than about who is serving which host.

That single fact gives you a list of attacks that no amount of care elsewhere closes:

  • Session fixation. Set a session cookie on the parent domain before the victim signs in. The dashboard reads it. They are now in a session the attacker chose and can also use.
  • Cookie shadowing. Set a cookie with the same name as the real session cookie but a different path or domain specificity, so the one the dashboard reads is not the one it wrote. Browsers do not tell the server which of several same-named cookies was set by whom.
  • Cookie jar overflow. Write enough cookies on the parent domain to evict the real one, forcing a re-authentication the attacker is positioned to observe.
  • Anything scoped by domain rather than origin. Some browser storage, some header policies, and a good deal of third-party tooling treat "same registrable domain" as "same trust boundary".

The important property: none of those are bugs you fix. They are the browser working correctly on a hierarchy you volunteered to share with untrusted code.

Why the same-origin policy is not enough

The usual objection is that origins are already isolated — evil.example.com cannot read the DOM of app.example.com, and that is true.

But the same-origin policy and the cookie scoping rules are two different rules with two different notions of "same". Origin is scheme + host + port, and it is strict. Cookie domain scope walks up to the registrable domain, and it is not. Something that cannot read your page can still write a cookie your page will send.

There is a second mechanism that addresses part of this: the Public Suffix List, a list browsers consult to decide where "registrable domain" stops. Getting a domain on it means browsers refuse cookies set for the parent — which is precisely why hosting providers apply. It is a real defence and a good idea, and ours is not on it yet, which is why running customers' code meant rebuilding every header a function sends. It is also a list maintained by other people, applied on their schedule, and effective only in clients that ship a current copy of it. Buying a second domain takes an afternoon and is enforced by every client that ever existed.

What it costs

Two domains is not free, and the costs land in places worth naming:

Nothing can be shared between the two by cookie. A signed-in dashboard user visiting one of their own sites is anonymous over there, and that is correct, but it means any feature that wants to know "is this the owner looking at their own site" has to carry the answer explicitly rather than reading it from a session.

Every link between them is cross-origin. Requests, embeds and any shared tooling need explicit configuration, and none of it can fall back on implicit trust.

It has to be enforced, not just intended. "User content only on the content domain" is the kind of rule that a convenient feature erodes — a preview iframe here, an admin view of somebody's file there. Ours is checked mechanically: a hook rejects a change that would serve content from the control-plane domain or route the dashboard onto the content domain, and it runs before the edit is applied rather than in review.

That last point is the one we would give to anybody building the same thing. The rule is easy to agree with and easy to violate incrementally, and the violation does not look like a security decision at the time. It looks like a small routing change on a Friday.

The short version

If you are building anything that serves files somebody else uploaded — a hosting product, a preview service, a file share, a CMS with a public preview — put that content on a different registrable domain from anything that holds a session. Not a subdomain. A different domain.

It is the cheapest security decision available at the start of a project and one of the most expensive to make later, because by then the addresses are in other people's bookmarks.

This site is the product it is written about.

Drag a folder in and read the link back. No account and no card to publish.