fix: use platform path separator in attachment validation#149
Merged
devartifex merged 1 commit intodevartifex:masterfrom Apr 14, 2026
Merged
fix: use platform path separator in attachment validation#149devartifex merged 1 commit intodevartifex:masterfrom
devartifex merged 1 commit intodevartifex:masterfrom
Conversation
isValidAttachmentPath() used hardcoded '/' separator which fails on Windows where paths use '\'. Replace with node:path sep to support both platforms. Also fix test to use join() instead of hardcoded '/'. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
devartifex
approved these changes
Apr 14, 2026
Owner
devartifex
left a comment
There was a problem hiding this comment.
LGTM — Clean, correct fix. Using path.sep instead of hardcoded / properly supports Windows path separators. Security logic remains sound: resolve() + startsWith(prefix + sep) prevents both path traversal and prefix-substring attacks. Test update with join() is consistent. All 399 unit tests pass (the check failure is a pre-existing coverage threshold issue unrelated to this change).
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.
isValidAttachmentPath()used a hardcoded forward slash ('/') when checking if an uploaded file path was inside the upload directory. On Windows,node:path.resolve()returns backslash-separated paths, so thestartsWithcheck always failed - silently dropping every image attachment with anATTACHMENT_PATH_REJECTEDwarning.This was a bug we introduced in v1.0.0. Commit
bb9daa8fixed the same class of Windows path separator issue in the frontend components but missed the server-side validation inattachments.ts.Fix: Replace
'/'withnode:path.septo support both platforms.Also updated the test to use
join()instead of a hardcoded/for the prefix-substring attack test case.