Repository navigation
LINDAT/SSR static pages no longer trust the Host header; SSR cache keyed by origin and language - #1687
Merged
milanmajchrak merged 1 commit intoNov 2, 2026
Conversation
…yed by origin and language * Load SSR static content from the configured UI origin, not the Host header During SSR, HtmlContentService built the static-file URL from the request protocol and Host header. A request with a spoofed Host made the server fetch /static-files/*.html from an attacker origin and render it unsanitized (dsSafeHtml); the SSR page caches, keyed by path only, could then serve that render to other visitors. Use the origin of the configured ui.baseUrl (the address the Node server listens on) instead and drop the now unused REQUEST injection. dspace-customers issue 1083, finding R22. * Key SSR page caches by origin and language, not only by path getCacheKey returned req.url, but an anonymous SSR render also depends on the request origin (protocol and Host header, e.g. citation_pdf_url via getCurrentOrigin) and on the dsLanguage cookie. A request with a forged Host or another language filled the bot and anonymous caches for everyone requesting that path. Move the key to getSsrCacheKey so it can be unit tested and include protocol, Host and the language cookie. The /reload check now reads req.url, because the key no longer starts with the path. dspace-customers issue 1083, finding R22. * Skip the SSR bot cache for authenticated requests cacheCheck read the bot cache for any bot user agent before checking for an authentication cookie, so an authenticated request with a bot user agent got the anonymous cached page instead of its own render. Read either cache only for anonymous requests; saveToCache already stores anonymous renders only. dspace-customers issue 1083, finding R22. * Do not load static page names that leave static-files once decoded The static page file name comes from the URL. Express decodes the path before serving files, so /static/..%2Findex loaded the app's own index.html into the page. Return no content for a name that contains a path separator after decoding (the query part is ignored), which renders the existing 404. dspace-customers issue 1083, finding R22. --------- Co-authored-by: jm <jm@maz> (cherry picked from commit 60f6ccb) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References
Description
SSR loads static pages from the origin of
ui.baseUrl, not from the Host header. The SSR caches are keyed by origin and language too, so a forged Host can no longer poison them.Instructions for Reviewers
List of changes in this PR:
60f6ccb1d430with-x, no changes. The original author stays.ui.baseUrlwith a valid certificate. Otherwise SSR shows the licence and ToS static pages as not found.LINDAT/title and GitHub refs written as plain text.How to test:
ssr-cache-key.util.spec.tsandhtml-content.service.spec.ts. By hand: request a static page with a forgedHostheader. The content still comes fromui.baseUrl.AI Disclosure
Claude Code made the cherry-pick and wrote this description.
Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.🤖 Generated with Claude Code