fix: validate resolved path in createFolder to prevent traversal via folder name#88
Merged
DenizAltunkapan merged 1 commit intoJun 26, 2026
Conversation
…folder name createFolder validated the parent path but not the resolved target, so a folder name containing '..' escaped the user's root - the same gap Vault-Web#77 fixed for upload. Normalize the resolved path and run it through the existing validatePath guard before Files.createDirectory, matching delete/rename/getFolderTree. Add a regression test for the name vector.
DenizAltunkapan
approved these changes
Jun 26, 2026
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.
What
FolderService.createFoldervalidated the parent path but not the resolved target, so a foldernamecontaining..escaped the user's root. Every other method in the service —delete,rename,getFolderTree— normalizes and re-validates the final path;createFolderwas the only one that didn't. Same class of bug as #77 (which fixed it for upload); folder creation was missed.createFolder(root, "", "../../hack")created a directory outside the user's root.createFolder(root, "../../", "hack")was already blocked (the parent argument is validated); only thenamevector was affected.Fix
Normalize the resolved path and run it through the existing
validatePathguard beforeFiles.createDirectory, matching the other methods. Traversal attempts now surface asInvalidPathException→400via the existingGlobalExceptionHandler.Test
Added
createFolder_pathTraversalViaName_throwsInvalidPathExceptionfor thenamevector — the existing traversal test only exercised the parent-path parameter. All 55FolderServiceTesttests pass; spotless clean.Fixes #87