Why User Uploads Belong on a Separate Domain
Serving user uploads from a separate domain keeps an uploaded HTML file away from your users' sessions. Why origin isolation beats file-type filters.
Serving user uploads from a separate domain means every file a visitor or editor uploads is delivered from a hostname that is not your application's hostname. The browser's same-origin policy then treats an uploaded HTML or SVG file as a stranger: it cannot read your session cookie, call your authenticated APIs or alter your pages. The TYPO3 upload path leak, CVE-2026-125160, is a current example of why this matters. Its cross-site scripting outcome exists only because uploaded files were served from the same origin as the site.
Why does the origin of an uploaded file matter?
Browsers isolate websites by origin, which is the combination of scheme, hostname and port. Script running in a page from one origin can read cookies, local storage and page content for that origin only. An uploaded HTML file served from your main domain runs with your main domain's privileges; the same file served from a different hostname runs with nothing.
This is why file-type filtering and CSP headers are described as mitigations while origin separation is described as a design decision. Filters and headers try to keep the executable file from executing. A separate domain accepts that it may execute and removes anything worth stealing from its reach.
The problem with "we block dangerous file types"
Every upload filter has the same failure modes, and the TYPO3 case shows two of them in one release. The Form Framework treated an empty MIME allow list as "allow everything," so forms without an explicit list accepted HTML and SVG. The separate deny pattern only blocked PHP-related extensions. Both were working as designed; the design was simply narrower than operators assumed.
Beyond configuration gaps, filters face polyglot files that are valid in two formats at once, content-type sniffing where the browser ignores the declared type, and formats people forget are active, such as SVG, which is XML and can carry script. Each new bypass gets patched, and each patch arrives after someone used the bypass. A filter is necessary. It is not sufficient.
What does a separate upload domain look like?
In practice it is a second hostname, often a dedicated registrable domain rather than a subdomain, that points at the same storage but is never used to serve application pages. The application writes uploads to storage as before and rewrites every link to them to use the upload hostname. Large platforms have done this for years: GitHub serves raw user file content from githubusercontent.com hosts rather than from github.com, which is the pattern to copy.
Three design choices decide how much isolation you get:
- A different registrable domain beats a subdomain. Cookies can be scoped to a parent domain, so a subdomain may still receive your session cookie. A separate domain cannot.
- No authentication on the upload host. The upload domain should never set cookies or accept credentials. If access control is needed, use short-lived signed URLs generated by the application.
- Static serving only. No application code runs on the upload host. It serves bytes with the right content type and a restrictive Content-Security-Policy, and nothing else.
How do you migrate uploads to a separate domain?
Point a new hostname at the existing storage, make the application generate upload links with that hostname, and set the upload host to serve files with a strict Content-Security-Policy and no cookies. Then redirect old upload URLs on the main domain to the new host for a transition period before removing them.
The order matters. Start with new uploads only, confirm nothing breaks, then migrate historical links. Watch for hard-coded absolute URLs inside editorial content, email templates, RSS feeds and third-party integrations, because those are the links a redirect will not catch once the old path is removed.
When the separate domain is not practical
A content management system like TYPO3 ties uploads to the site's file storages, and editors expect files under the site's own hostname. Agencies hosting dozens of small sites may not want a second certificate and DNS record per client. In those cases the fallback is to make the upload folder as inert as possible on the main domain: a strict CSP with the sandbox directive, an explicit MIME allow list on every upload element, and monitoring for browser-executable file types landing in upload paths. The step-by-step configuration is in how to set a CSP header for upload folders.
The CSP approach works, as TYPO3's advisory itself acknowledges by scoping the XSS impact to servers without the recommended policy. Its weakness is fragility. The header lives in a web server configuration file that is easy to lose during a migration, a container rebuild or an nginx template change, and TYPO3 notes that its shipped .htaccess is not updated automatically once created. Origin separation, by contrast, fails loudly: if the upload host stops working, uploads stop displaying and someone notices.
Why this is a planning decision, not a patch
The TYPO3 fix closed the error-message leak and tightened the MIME check. It did not change where uploaded files live or which origin serves them. The next leak, whether in TYPO3 or in any other platform, will reveal file locations again, and the question of what an attacker can do with a known URL to an uploaded file will be answered by the architecture, not by the patch.
Put the decision on the roadmap with a clear owner. For a new build, serving uploads from a separate domain costs a hostname, a certificate and a configuration change in the storage layer. For an existing site, budget for the link migration and the redirect period. Either way, the control is one that never needs a security advisory to remind you it is there. For the broader lesson on why leaked paths keep turning into exploited bugs, read what CWE-209 is and why error messages leak secrets.