Skip to content

Commit 03c1750

Browse files
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>
1 parent ec1762b commit 03c1750

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/server/src/utils/createAttachment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export const createFileAttachment = async (req: Request) => {
2727
const appServer = getRunningExpressApp()
2828

2929
const chatflowid = req.params.chatflowId
30+
const chatId = req.params.chatId
31+
3032
if (!chatflowid || !isValidUUID(chatflowid)) {
3133
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid chatflowId format - must be a valid UUID')
3234
}
33-
if (isPathTraversal(chatflowid)) {
35+
if (isPathTraversal(chatflowid) || (chatId && isPathTraversal(chatId))) {
3436
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Invalid path characters detected')
3537
}
3638

37-
const chatId = req.params.chatId
38-
3939
// Validate chatflow exists and check API key
4040
const chatflow = await appServer.AppDataSource.getRepository(ChatFlow).findOneBy({
4141
id: chatflowid

0 commit comments

Comments
 (0)