Repository navigation
Conversation
…language, no static file outside static-files Port of dtq-dev PR 1669 (commit 60f6ccb). - server.ts and ssr-cache-key.util(.spec).ts: the dtq-dev change as is; only the import block in server.ts conflicted. - html-content.service on zcu predates the dtq-dev static page rework (#1241): it only fetches a given URL and never reads the Host header, so that part of 1669 does not apply and the service and its spec are left out. zcu builds the static file URL in StaticPageComponent, so the isPlainFileName guard goes there, with a spec case.
6 tasks done
There was a problem hiding this comment.
🔵 Needs a closer look
The change alters security-sensitive SSR caching and standalone server routing, but lacks running Angular Universal/Express proxy validation for authenticated bypasses, origin/language isolation, and real URL/404 behavior.
No open issues 🎉
What changed in this PR
This PR hardens SSR caching and static-page loading by isolating cached renders by origin and language, preventing authenticated users from receiving bot-cache responses, and rejecting encoded paths that could escape static-files.
Changes:
- Added origin-, language-, and URL-aware SSR cache keys.
- Restricted bot-cache reads to anonymous requests.
- Added static filename validation and regression tests for encoded path traversal.
| File | Description |
|---|---|
| src/app/static-page/static-page.component.ts | Rejects decoded static-page filenames containing path separators before fetching static content. |
| src/app/static-page/static-page.component.spec.ts | Tests that encoded traversal paths produce a 404 without fetching a file. |
| src/app/shared/ssr-cache-key.util.ts | Defines shared SSR cache-key generation using request origin, language, and URL. |
| src/app/shared/ssr-cache-key.util.spec.ts | Tests cache separation by language and request origin. |
| server.ts | Uses the shared cache key and prevents authenticated requests from receiving bot-cache entries. |
Review effort: Lite
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
Port of dtq-dev PR 1669 (commit 60f6ccb). dspace-customers issue 1083, finding R22.
Description
The SSR page caches were keyed by
req.urlonly, and the bot cache was read before the login check. Now the key holds origin, path and language, the bot cache serves only anonymous requests, and a static page name like..%2Findexis refused.Instructions for Reviewers
server.tsand newssr-cache-key.util.ts: the same as the source. Only the import block conflicted.html-content.service.ts: not taken. On zcu it predates the dtq-dev static page rework ([Port to dtq-dev] static pages - SSR render; 404 behavior #1241): it only fetches a given URL and never reads theHostheader, so the Host header part does not apply.static-page.component.ts: zcu builds the static file URL here, so theisPlainFileNameguard from the source goes here. A name that leavesstatic-filesonce decoded is not requested and the existing not-found state (404) is shown.ssr-cache-key.util.spec.tsandstatic-page.component.spec.tswith a new case for..%2Findex(6 specs pass locally on Node 18). ESLint is clean on the changed files,yarn run build:prodpasses. Not tested on a running SSR server.Checklist