Ever wondered why websites deployed on Vercel get URLs like:
myproject.vercel.app
Instead of:
myproject.vercel.com
At first, it might look like a simple domain naming decision.
But there's an interesting security concept behind this: Origin Isolation.
And understanding it can change how you think about hosting user-generated content.
Imagine This Scenario#
Let's say you're building a platform where users can deploy their own websites.
You have your main application:
dashboard.example.com
Users can log in, manage projects, configure deployments, and access their account information.
Now imagine allowing users to deploy their own HTML, CSS, and JavaScript directly under your main domain.
For example:
- alice.example.com
- bob.example.com
- charlie.example.com
What if Alice deploys a malicious website?
Could it somehow interfere with your main application?
This is where browser security becomes important.
1. Understanding Same-Origin Policy#
Browsers follow an important security mechanism called the Same-Origin Policy (SOP).
An origin consists of three things:
- Protocol
- Hostname
- Port
For example:
https://example.com:443
Two URLs have the same origin only when all three match.
Consider these examples:
- https://example.com/about — Same origin.
- https://example.com:443 — Same origin because HTTPS uses port 443 by default.
- http://example.com — Different origin because the protocol is different.
- https://app.example.com — Different origin because the hostname is different.
- https://example.net — Different origin because the domain is different.
This policy prevents JavaScript running on one origin from freely accessing sensitive browser resources belonging to another origin.
For example, a malicious website generally cannot read your dashboard's localStorage or directly access its DOM.
But here's where things get interesting.
Different origins don't always mean different sites.
2. Origin vs Site: What's the Difference?#
This is one of the most important distinctions in web security.
An origin uses the protocol, hostname, and port.
A site is generally determined using the scheme and registrable domain.
Let's compare:
https://dashboard.example.com
https://alice.example.com
These are:
- Different origins.
- Generally the same site.
Why does this matter?
Because browsers handle cookies differently from how they enforce the Same-Origin Policy.
Cookies can be configured to work across subdomains using the Domain attribute.
For example:
Set-Cookie: session=abc123; Domain=example.com; Secure; HttpOnly
This cookie can be sent to matching subdomains of example.com.
That means a website hosted on a subdomain may have opportunities to interfere with cookie behaviour at the parent-domain level, depending on how the application's cookies are configured.
3. What Is Cookie Tossing?#
Let's understand a related attack.
Imagine your main application uses a cookie to maintain user sessions.
An attacker controls:
attacker.example.com
If the attacker can set a cookie for the parent domain:
Domain=example.com
They may be able to inject a cookie with the same name as one used by your main application.
This is commonly called Cookie Tossing.
Depending on the application's cookie handling, duplicate cookie names and unexpected cookie values can cause problems.
For example, they can potentially contribute to:
- Session fixation.
- Authentication confusion.
- CSRF-related vulnerabilities.
- Unexpected application behaviour.
One important clarification: this doesn't mean an attacker can automatically read an HttpOnly session cookie. Cookie tossing is about injecting or manipulating cookies, not simply reading protected cookies.
GitHub explained this exact class of risk when it moved GitHub Pages away from github.com subdomains.
4. Why GitHub Moved to github.io#
This isn't just a theoretical security example.
In 2013, GitHub moved its GitHub Pages hosting service from:
username.github.com
to:
username.github.io
Why?
Because GitHub Pages allowed users to publish custom HTML and JavaScript.
Hosting that user-controlled content under github.com created potential security risks involving related-domain cookies and phishing.
GitHub identified two major concerns:
1. Cookie-related attacks
A malicious Pages website could potentially inject cookies into the parent github.com domain, creating risks involving session fixation and CSRF.
2. Phishing attacks
Imagine someone hosting:
account-security.github.com
A malicious website under the trusted GitHub domain could make users believe they were visiting an official GitHub service.
Moving Pages to github.io helped separate user-controlled websites from GitHub's main application domain.
GitHub documented this migration and its security reasoning in its engineering blog.
Read GitHub's original explanation (opens in a new tab)
5. How Does This Relate to Vercel?#
Now let's come back to Vercel.
When you deploy a project, Vercel automatically provides a deployment URL ending in:
vercel.app
For example:
myproject.vercel.app
Instead of placing arbitrary user deployments under the main vercel.com application domain, Vercel uses a separate domain namespace.
This creates an important security boundary between the platform's main application and websites deployed by its users.
There's another interesting detail.
vercel.app is included in the Public Suffix List.
This matters because browsers use the Public Suffix List to determine cookie boundaries.
For example, a project hosted at:
myproject.vercel.app
cannot simply set a cookie for the shared parent domain:
vercel.app
This helps prevent one Vercel project from creating a cookie that affects other projects hosted under the same namespace.
Vercel explains this behaviour in its own documentation.
Read Vercel's cookie security explanation (opens in a new tab)
The important lesson isn't that every deployment must use .app.
It's that untrusted user-controlled content should be isolated from your trusted application environment.
6. When Should You Use a Separate Domain?#
This architecture is useful whenever your platform allows users to publish or execute content that you don't fully control.
Some examples include:
- Website builders.
- Static site hosting platforms.
- Online code playgrounds.
- User-generated HTML and JavaScript.
- Preview deployments.
- Sandboxed application environments.
Instead of hosting everything under your primary application domain, consider using a separate registrable domain.
For example:
Main application: dashboard.example.com User deployments: project.exampleusercontent.com
You should also consider:
- Using host-only cookies wherever possible.
- Avoiding broad Domain cookie attributes.
- Setting Secure, HttpOnly, and appropriate SameSite attributes.
- Isolating untrusted code in sandboxed environments.
- Restricting communication between trusted and untrusted origins.
A separate domain is one layer of defence, not a complete security solution.
Final Thoughts#
Sometimes, the most important security decisions aren't visible in the UI.
A domain name might look like a branding choice, but it can also be part of your security architecture.
When you're building a platform that hosts websites, executes code, or accepts user-generated content, you need to think beyond simply making deployments work.
You need to think about what happens when someone uses your platform maliciously.
Because securing your application isn't just about protecting what you build. It's also about isolating what other people can build on your platform.




