Repository navigation
Conversation
…aversal DirectUrlDocumentLoader and CalmHubDocumentLoader each carried a copy of the directory-traversal check and of the request-path allowlist, and the two allowlists had drifted apart (finos#3024 items 1 and 2). Both now use one shared helper in document-loader/request-guards.ts, following the response-origin.ts precedent. The old check, documentId.includes('/..'), only saw a literal "..". The WHATWG URL parser also resolves "%2e%2e", ".%2E", "\.." (http/https) and dots split by a tab or newline, so those forms reached the server as an already-resolved path and bypassed the guard. The shared guard applies the same rewrites before looking for "/..". The CalmHub allowlist's optional "(\.json)?" suffix was already covered by the character class, so a single pattern keeps today's behaviour. Refs finos#3024 Signed-off-by: Toyenzo <64788123+Toyenzo@users.noreply.github.com>
Toyenzo
requested review from
LeighFinegold,
Thels,
aidanm3341,
grahampacker-ms,
jpgough-ms,
lbulanti-ms,
markscott-ms,
rocketstack-matt and
willosborne
as code owners
November 5, 2026 03:33
This branch has not been deployed
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.
Description
This covers items 1 and 2 of #3024.
DirectUrlDocumentLoaderandCalmHubDocumentLoadernow share one request-path allowlist and one directory-traversal guard, indocument-loader/request-guards.ts. It follows theresponse-origin.tsprecedent. A future tightening now applies to both loaders.While writing the shared guard I found that the old check,
documentId.includes('/..'), only caught a literal... The WHATWG URL parser also resolves these forms to..:%2e%2e,%2E%2E,.%2e,%2e.\..\in http(s) URLs, where the parser treats\as/By the time either loader read
url.pathname, the parser had already resolved the segment away. Sohttps://calm.finos.org/calm/%2e%2e/secret.jsonpassed the guard and was requested as/secret.json. The same happened withcalm:/schemas/2025-03/%2e%2e/%2e%2e/admin/...against CalmHub. The shared guard applies the same rewrites as the parser before it looks for/... Plain URLs behave as before.Notes:
(\.json)?suffix was already matched by the character class, so one pattern keeps today's behaviour for both loaders.loadSchemas()) are left for follow-ups. Item 3 needs the Node/browser design agreed first, as the comment on the issue says. I used "Refs" so the issue stays open.Refs #3024
AI-assisted: drafted with Claude Code; reviewed and tested by me.
Type of Change
Affected Components
cli/)calm/)calm-ai/)calm-hub/)calm-hub-ui/)calm-lab/)calm-models/)calm-server/)calm-studio/)calm-widgets/)calm-guard/)docs/)shared/)calm-plugins/vscode/)Commit Message Format ✅
Testing
I have tested my changes locally
I have added/updated unit tests
All existing tests pass
29 new tests: 19 unit tests for the shared guards, plus 5 per loader for the parser-resolved traversal forms. The loader tests also check that no HTTP request is sent.
All 10 new loader tests fail against the old inline checks. The old code sent the request and failed later with "Failed to load document ...".
npm run build:clipasses.npm test --workspace sharedpasses 1573/1573, with coverage thresholds met and the browser-entry check OK.CLI: 982 unit tests pass.
cli.e2epasses 60/60 when run with--hookTimeout=300000. With the default 30s hook timeout it times out locally while packing and installing the CLI, which is unrelated to this change.npm run lint: 0 errors. The only warnings are existing ones in untouched packages.Checklist
shared/AGENTS.md, Document Loader section)🤖 Generated with Claude Code