From 03c1750d73d7a7a599d0e438bd0dc7abdef63ea7 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Thu, 6 Nov 2025 22:19:27 +0000 Subject: [PATCH] Bugfix/path traversal check on chatId (#5428) * path traversal check on chatId * Update packages/server/src/utils/createAttachment.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/server/src/utils/createAttachment.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/server/src/utils/createAttachment.ts b/packages/server/src/utils/createAttachment.ts index 022a3f82c..10495140d 100644 --- a/packages/server/src/utils/createAttachment.ts +++ b/packages/server/src/utils/createAttachment.ts @@ -27,15 +27,15 @@ export const createFileAttachment = async (req: Request) => { const appServer = getRunningExpressApp() const chatflowid = req.params.chatflowId + const chatId = req.params.chatId + if (!chatflowid || !isValidUUID(chatflowid)) { throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid chatflowId format - must be a valid UUID') } - if (isPathTraversal(chatflowid)) { + if (isPathTraversal(chatflowid) || (chatId && isPathTraversal(chatId))) { throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid path characters detected') } - const chatId = req.params.chatId - // Validate chatflow exists and check API key const chatflow = await appServer.AppDataSource.getRepository(ChatFlow).findOneBy({ id: chatflowid