Skip to content

fix: use platform path separator in attachment validation#148

Closed
dmbutko wants to merge 1 commit intodevartifex:masterfrom
dmbutko:master
Closed

fix: use platform path separator in attachment validation#148
dmbutko wants to merge 1 commit intodevartifex:masterfrom
dmbutko:master

Conversation

@dmbutko
Copy link
Copy Markdown
Contributor

@dmbutko dmbutko commented Apr 13, 2026

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 the startsWith check always failed - silently dropping every image attachment with an ATTACHMENT_PATH_REJECTED warning.

This was a bug we introduced in v1.0.0. Commit bb9daa8 fixed the same class of Windows path separator issue in the frontend components but missed the server-side validation in attachments.ts. Apologies for the oversight.

Fix: Replace '/' with node:path.sep to support both platforms.

Also updated the test to use join() instead of a hardcoded / for the prefix-substring attack test case.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant