A Custom Hostname Is Not a Tenant Isolation Boundary
Maya runs a small website builder. One customer points shop.alpha.example at her platform, another points shop.beta.example at the same platform. Both get certificates, resolve to Cloudflare, and load the same application. Maya assumes different hostnames mean separate customers. They do not. A hostname is an address; it creates no runtime, database, or permission boundary.
A tenant is one customer. A custom hostname is a customer-owned domain Cloudflare serves for you. A dispatch namespace holds the Workers you deploy for customers; a user Worker is one of those scripts.
Cloudflare for SaaS solves the hostname problem: it validates domain control, issues certificates, and routes each custom hostname to a fallback or custom origin. It is bundled with non-Enterprise plans and an add-on for Enterprise, with 100 hostnames included, a 50,000 ceiling on Free, Pro, and Business, and $0.10 per additional hostname (SaaS plans). Every hostname still reaches one origin by default, adding no per-tenant process or storage.
Workers for Platforms solves execution. A dispatch Worker receives each request, resolves the tenant, and invokes that tenant's script through a namespace binding. User Workers run untrusted by default: request.cf is unavailable, caches are isolated, and caches.default is disabled (worker isolation). There is no per-account script cap in a namespace.
One namespace, many tenants
Keep every customer Worker in one namespace, such as production, not one namespace per customer. A namespace is an execution container, not a tenancy boundary; tenancy lives in your registry, tags, and bindings.
The apartment analogy: a custom hostname is the nameplate by the street entrance, which helps visitors find the building but does not lock the door. Workers for Platforms is the unit inside, with its own key and meter.
Figure 1 shows where the boundary appears. The hostname layer is shared; the dispatch Worker is platform code; isolation begins at the namespace lookup. The dashed path is the trap: SaaS alone sends every hostname to one origin.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
V["Visitor: shop.alpha.example"] --> S["Cloudflare for SaaS
hostname and TLS"]
S --> M{"Hostname registry"}
M -->|"mapped"| D["Dispatch Worker
authenticate and authorize"]
M -->|"unmapped"| R["404 before tenant code"]
D --> N["Dispatch namespace"]
N --> A["Alpha user Worker
untrusted isolate"]
N --> B["Beta user Worker
untrusted isolate"]
A --> DA[("Alpha KV, D1, R2")]
B --> DB[("Beta KV, D1, R2")]
S -.->|"SaaS alone"| F["Shared fallback origin
one app, one data store"]
D -.->|"platform secrets"| P["Registry, egress, billing"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class S,F primary;
class V,M,D,R,N,P secondary;
class A,B ok;
Figure 2 draws the same point in layers. Address and transport sit at the top, execution in the middle, tenant data at the bottom. A hostname never crosses into the data layer on its own. Your code must translate a verified hostname into a tenant identity, then into a scoped execution and data path.
Dispatching Customer Code and Routing Tenant Requests
The dispatch Worker decides who the caller is, which tenant owns the hostname, and which script runs. A mistake here is not one tenant's bug; it is a cross-tenant incident.
Two hosts, one dispatcher. Alpha is at alpha.platform.example, Beta at shop.beta.example.
Host-based routing beats path prefixes. A path design that puts the tenant in the URL is easy but weak: tenants share one origin and cookie scope, and a path prefix is easy to spoof. Host-based routing is stronger because the hostname is part of the request authority, covered by the certificate, and a natural registry key. Pair a wildcard route on the SaaS zone with custom hostnames so subdomains and customer domains reach one dispatcher (hostname routing); a */* route also avoids per-hostname route limits, at the cost of capturing all traffic on that zone.
| Model | Execution boundary | Custom domains | Per-tenant limits | Main operational cost |
|---|---|---|---|---|
| SaaS plus one shared Worker | None between customers | Yes, managed certificates | No per-tenant CPU cap | Lowest; one blast radius |
| Workers for Platforms, subdomains | One user Worker per tenant | Subdomains under your zone | CPU and subrequests per invocation | Namespace and registry ownership |
| Workers for Platforms plus SaaS | One user Worker per tenant | Customer domains and subdomains | CPU and subrequests per invocation | Highest routing and certificate complexity |
| One account Worker per tenant | One Worker per tenant | Routes attached per Worker | Account limits only | Many deploys and routes |
Keep the product boundary precise. SaaS owns hostname validation, certificates, and edge routing. Workers for Platforms owns dynamic execution. Either works alone; a real platform usually needs both. Availability differs too: Workers for Platforms is a paid product listed at $25 per month with 20 million requests, 60 million CPU milliseconds, and 1,000 scripts included (pricing). Confirm entitlement before quoting a per-tenant price.
Figure 3 traces the request. The registry lookup is platform-owned. The dispatch key comes from the registry, not the URL. Authentication and route authorization happen before invocation, custom limits are applied at invocation, egress passes a policy, and the response is sanitized.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
sequenceDiagram
autonumber
participant V as Visitor
participant D as Dispatch Worker
participant R as Registry
participant N as Namespace
participant W as User Worker
participant O as Outbound Worker
V->>D: GET shop.alpha.example/report
D->>R: resolve verified hostname
alt unmapped
R-->>D: no tenant
D-->>V: 404, app not invoked
else found
R-->>D: tenant, script, policy hash
D->>D: authenticate and check route
alt denied
D-->>V: 401 or 403
else allowed
D->>N: get script with limits
N->>W: invoke with scoped props
W->>O: external fetch
alt not allowlisted
O-->>W: 403 egress denied
D-->>V: sanitized 502
else allowed
O-->>W: response
W-->>D: response
D-->>V: 200, headers sanitized
end
end
end
The dispatch key must come from the registry, not the request. The widget shows the lookup, normalization, and invocation path; the callout states the rule that keeps it safe.
Never trust the script name from the request
If scriptName comes from the request, a tenant can ask for another tenant's Worker. Resolve it from a registry row keyed by a normalized, exact-match hostname; lowercase the host, strip the port, and reject suffix matches, or shop.alpha.example.attacker.test becomes a route into Alpha. When a hostname moves between tenants, revoke the old mapping and rotate tokens before the new customer serves traffic.
Secrets follow the same line. Platform secrets belong in the dispatch or outbound Worker; tenant secrets belong only in that tenant's bindings. Never pass a tenant secret through props, because tenant code can log it; pass a capability exposing one narrow method. Publish route policy with the code, validate the manifest at upload, and deny undeclared routes. A route gate protects the door; ownership checks protect the drawers.
Per-Tenant Bindings, Secrets, Quotas, and Evidence
Bindings attach at upload and persist on every invocation. Each Worker reaches only its own bindings, but a binding to a shared namespace grants the whole namespace. The table separates configuration-enforced isolation from code-enforced convention.
| Model | Boundary enforced by | Failure mode | Audit evidence |
|---|---|---|---|
| Per-tenant resource | Platform configuration | A missing binding fails closed | One resource ID per tenant |
| Shared namespace plus prefix | Customer code | One missed check or list() exposes another tenant | Prefix conventions only |
| Platform capability | Platform code | A scope bug inside the capability | Method-level ownership checks |
A binding name is not an access policy
A binding name is not an access policy. If every user Worker shares one KV namespace, bucket, or database and relies on a tenant prefix, isolation depends on code you do not control; one bug or one list() exposes another tenant. Attach a unique resource per tenant, or put the shared resource behind a capability that enforces scope.
Figure 4 contrasts the models. On the left, each tenant owns its storage and secret binding, so the boundary is auditable and a missing binding fails closed. On the right, both Workers reach one bucket and the boundary exists only if every line of customer code honors the prefix. The capability at the bottom is the fallback: the Worker calls readOwn(id), not the bucket.
Quotas need the same honesty. Workers for Platforms has no hard script ceiling, but billing includes 1,000 scripts then $0.02 each, so "unlimited" is financial too. The platform maximum is 30 seconds of CPU per invocation, below the Workers Paid 5-minute maximum, and custom limits set a lower ceiling. Tags stop at eight per script and Gradual Deployments are unsupported for user Workers, so a change deploys all at once (limits). The API allows 1,200 requests per five minutes per user token.
Two failures follow. A provisioning bug can create thousands of scripts because nothing caps them; make creation idempotent on (tenant, project, commit) and alert on script-count growth. Noisy neighbors survive per-invocation limits: one tenant can stay under every CPU cap and still consume the account's request budget. Custom limits do not cap requests per second, concurrency, storage, egress, or spend; add dispatch rate limiting and a budget alert.
Evidence makes this operable. Log one record per request, then keep tenant-facing queries scoped server-side to that script. The table lists the fields and where they come from.
| Evidence field | Source | Why it matters |
|---|---|---|
| Normalized hostname | Dispatch Worker | Shows which registry key was used |
| Tenant ID | Registry lookup | Attributes the request to one customer |
| Script and version | Dispatch invocation | Records which code actually ran |
| Policy hash | Registry or release record | Detects route-policy drift |
| Applied limits | Dispatch Worker | Records the CPU and subrequest ceilings |
| Outcome | Dispatch and user Worker | Separates denial, failure, and success |
| Release ID | Release record | Ties the request to a build and commit |
Use Workers Logs, Logpush, Tail Workers, Analytics Engine, or GraphQL to collect the fields. GraphQL's workersInvocationsAdaptive exposes dispatch namespace and script name; scope tenant-facing queries server-side to the tenant's script, or the viewer becomes the leak.
Artifacts fits as storage for customer source, not the runtime data plane: namespaces group repositories, repositories hold file trees and commits, and a Worker binding can create, fork, and delete repos and mint scoped tokens.
Artifacts, Builds, and Customer Project Lifecycles
The lifecycle starts with a source of truth. A tenant creates a project; the platform creates an Artifacts repository and records its ID; the tenant pushes with Git or the platform writes through the binding. Each repository is an isolated Git service with its own URL, tokens, history, and durable state, replicated synchronously across data centers (how Artifacts works). Auth has three paths: the Workers binding, the REST API with an Artifacts Read or Edit token, and Git with a repo-scoped read or write token. Mint short-lived tokens per session; never hand a tenant an account API token.
Figure 5 shows the pipeline and its failures. An oversized push never becomes a commit; a failed build produces no release record; a failed deploy leaves the old mapping. Rollback is a mapping change back to the previous script version, because user Workers lack Gradual Deployments.
Build is a separate trust boundary. A user Worker runs JavaScript in an isolate, so it is the wrong place for a package install or a full toolchain. Build in a container sandbox, Workflow, or external CI with only the repository it needs, then upload the bundle with the tenant's bindings and tags. The widget shows the three surfaces: the binding that reads source, the Wrangler config, and the repo and deploy commands.
Workers Builds can connect an Artifacts repository and deploy on push, with previews for other branches (integration); or a repo.pushed event starts a Workflow using @cloudflare/ci and deploys to a user Worker (build and deploy).
Managed builds are account-wide
The managed path has tenancy limits: only main is a production branch, autoconfiguration creates no pull request for Artifacts repos, and paid plans allow six concurrent builds per account with a 20-minute timeout. Those six are account-wide, so a hundred simultaneous tenants queue behind one slow build. At scale, run per-tenant builds yourself, cap concurrency by plan tier, and keep the mapping update out of the build job.
Artifacts limits shape the product. Repositories created on or after 2026-09-29 have 1 GB; older ones retain 10 GB, and the account limit is 1 TB. A push is capped at 64 MiB, a file at 32 MiB, and a push at 50,000 objects; rates are 2,000 requests per 10 seconds per namespace or artifact (limits). Use Artifacts for source and R2 for media: a 300 MB asset folder needs a different storage tier, not a bigger push. Git is history, not a CDN.
Residency is a per-product decision
Residency is a namespace property. An Artifacts namespace is created with an EU or US jurisdiction, every repository inherits it, and it cannot be changed (data localization). Give an EU-only tenant its own namespace and point the binding and remote at it. Runtime data has separate controls: Durable Objects support EU, US, and FedRAMP; R2 has jurisdictional buckets; Regional Services controls processing as part of the Enterprise Data Localization Suite. Build a residency profile per tenant and map each product to it.
Cost attribution is a platform feature, not an invoice feature. Workers for Platforms bills one request across the dispatch, user, and outbound chain, plus CPU and scripts beyond the allotment. Artifacts starts billing on 2026-11-12: 10,000 operations and 1 GB-month included, then $0.15 per 1,000 operations and $0.50 per GB-month (pricing). Write a request-time ledger keyed by tenant and script, then reconcile monthly. Eight tags per script cover tenant, plan, environment, region, and release.
Design a Small Multi-Tenant Publishing Platform
Design a Small Multi-Tenant Publishing Platform
Status: design-only. No hosted execution was performed. These steps are a reproducible plan for a controlled account, not a measured result. Confirm Workers for Platforms entitlement and Artifacts billing before any paid step.
Prerequisites.
- Workers Paid, required for Artifacts.
- Workers for Platforms enabled.
- Two test hostnames you control:
alpha.lab.exampleandbeta.lab.example. - A current Wrangler release supporting the
artifactsbinding. - A scratch zone you can delete. No production zone or real customer data.
Setup.
- One dispatch namespace:
d10-prod. - One dispatch Worker and two user Workers:
alpha-appandbeta-app. - One KV namespace or D1 database per tenant.
- One Artifacts namespace,
d10-projects, with reposalpha-siteandbeta-site.
- Create the dispatch and Artifacts namespaces; store the IDs in the registry.
- Add rows for
alpha.lab.exampleandbeta.lab.examplewith script names and policy hashes. - Deploy the dispatcher with a stub authenticator, hostname normalizer, and the 50 ms CPU and 10-subrequest limits from the widget above. Return 404 for unknown hosts.
- Create separate tenant storage and attach only the matching resource plus one tenant secret to each Worker.
- Upload both user Workers with a
tenant_idtag and confirm each reads only its own binding. - Create both repos, mint short-lived read tokens, push a minimal site plus Worker entry, and record the commit SHA.
- Design the build as a sandbox or CI job that checks out the commit and emits a bundle plus manifest, without the account API token.
- Deploy the bundle, write a release record (tenant, repo, commit, build, policy hash, version), and route both hosts to the dispatcher.
- Run negative tests: Beta's cookie on Alpha's host, a spoofed
X-Tenant-Id, a cross-tenant key read, an unknown host, a CPU overrun, a blocked egress destination, and an expired token.
Expected observations. Alpha's host reaches only alpha-app; neither the Beta cookie nor the spoofed header changes that. Cross-tenant reads return not found or forbidden. Unknown hosts return 404 before any user Worker runs. Limit exceptions become a controlled 5xx. Blocked egress is denied and logged. Expired or read-only tokens cannot push, and oversized pushes fail before creating a commit.
Failure checks. Repeat step 4 with one shared KV namespace and the same prefix; the cross-tenant read should now succeed, proving the prefix was never a boundary. Switch a staging copy to trusted mode and confirm request.cf appears and caches merge. Then read the script name from the URL and confirm a tenant can dispatch into the other's Worker. Record each failure as evidence the control works.
Cost dimensions. Workers Paid has a $5 monthly minimum. Workers for Platforms is $25 per month with 20 million requests, 60 million CPU milliseconds, and 1,000 scripts, then $0.30 per million requests, $0.02 per million CPU milliseconds, and $0.02 per script. Artifacts includes 10,000 operations and 1 GB-month, then $0.15 per 1,000 operations and $0.50 per GB-month. Custom hostnames include 100 at $0.10 each beyond that. No total is estimated.
Cleanup. Delete both user Workers, the dispatcher, the namespace, both repos, the Artifacts namespace, all repo tokens, the KV or D1 resources, test DNS records and hostnames, the scratch zone, and any budget alert. Confirm no orphaned scripts or tokens remain.
Reject Cross-Tenant Access and Map Cost Attribution
Pass/fail evidence. A platform is ready for a pilot only when every check has a recorded result.
- Hostname resolution: Alpha's host resolves to
tenant-alpha; a spoofedHost,X-Tenant-Id, or query parameter resolves to the same tenant or is rejected. Pass requires normalized exact match. - Dispatch authority: the script name comes from the registry, and no path, query, or cookie reaches another tenant's Worker.
- Data isolation: a cross-tenant read, list, or object fetch returns not found or forbidden. A prefixed shared resource fails by design.
- Egress control: a non-allowlisted destination is denied and logged without leaking internal names. Outbound Workers do not intercept Durable Object or mTLS traffic, and enabling one disables raw
connect()sockets. - Quota containment: a tenant over its CPU or subrequest limit gets a controlled error while others keep serving. This does not prove immunity to account-level limits.
- Release provenance: the deployed version maps to an Artifacts commit, build ID, and policy hash; rollback restores the prior mapping and the prior commit stays readable.
- Token scope: read-only cannot push, expired and revoked tokens fail, and no tenant holds the platform API token.
- Cost attribution: every invocation carries a tag or script name mapped to a tenant, and a monthly per-tenant report comes from your own metering.
Self-check. Does a custom hostname isolate tenant code? No. It provides address, certificate, and routing. Isolation starts when a dispatcher maps a verified hostname to a tenant and invokes a separate user Worker with separate bindings.
A shared namespace with a prefix is unsafe. The binding grants the whole namespace, and customer code can list or read any key. One missed prefix check or one malicious deploy exposes another tenant.
What do custom limits not cap? Requests per second, concurrency, storage, egress, and spend. Pair them with dispatch rate limiting, storage quotas, an egress policy, and budget alerts.
Unresolved limitations. Enterprise and committed-use terms vary by account, and per-tenant billing is not a native invoice dimension, so cost attribution is a ledger you build. Artifacts limits and pricing changed recently, including the 1 GB repository limit for repos created on or after 2026-09-29 and billing from 2026-11-12. Gradual Deployments are unavailable for user Workers, so release safety lives at the mapping. Residency is product-specific: Artifacts jurisdiction is immutable, Durable Objects and R2 have separate controls, and Regional Services is an Enterprise add-on. SaaS validates control at claim time but does not track your tenant registry, so re-claim handling stays yours. The exercise is design-only; no hosted validation or failover test was executed.
Verification note. Behavior, limits, and prices were checked against Cloudflare documentation on 2026-11-05, against a planning baseline of 2026-11-02. No tested tool versions are claimed; confirm Wrangler, entitlement, and Artifacts billing before running the exercise.
References.
- Cloudflare for Platforms: https://developers.cloudflare.com/cloudflare-for-platforms/
- Workers for Platforms: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
- How Workers for Platforms works: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/how-workers-for-platforms-works/
- Worker isolation: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/worker-isolation/
- Workers for Platforms limits: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/limits/
- Workers for Platforms pricing: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/pricing/
- Bindings: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/configuration/bindings/
- Hostname routing: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/configuration/hostname-routing/
- Observability: https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/configuration/observability/
- Cloudflare for SaaS plans: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/plans/
- Artifacts: https://developers.cloudflare.com/artifacts/
- How Artifacts works: https://developers.cloudflare.com/artifacts/concepts/how-artifacts-works/
- Artifacts limits: https://developers.cloudflare.com/artifacts/platform/limits/
- Artifacts pricing: https://developers.cloudflare.com/artifacts/platform/pricing/
- Artifacts data localization: https://developers.cloudflare.com/artifacts/guides/data-localization/
- Workers Builds Artifacts integration: https://developers.cloudflare.com/workers/ci-cd/builds/git-integration/artifacts-integration/
- Data Localization Suite: https://developers.cloudflare.com/data-localization/