From 2adc332586903a84fd2c82fc79b81630488f2096 Mon Sep 17 00:00:00 2001 From: Mark Gilbert <50398495+MarkProminic@users.noreply.github.com> Date: Tue, 30 Sep 2025 21:37:51 -0500 Subject: [PATCH] Potential fix for code scanning alert no. 25: Server-side URL redirect Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- routes/fileServer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/routes/fileServer.js b/routes/fileServer.js index 2df8d1d..bb93f4b 100644 --- a/routes/fileServer.js +++ b/routes/fileServer.js @@ -238,7 +238,12 @@ router.get('*splat', authenticateDownloads, async (req, res) => { return res.status(400).send('Invalid redirect path'); } - return res.redirect(301, safeRedirectPath); + if (isLocalUrl(safeRedirectPath)) { + return res.redirect(301, safeRedirectPath); + } else { + logger.warn('Blocked attempted open redirect', { path: safeRedirectPath }); + return res.status(400).send('Invalid redirect path'); + } } return handleDirectoryListing(req, res, fullPath, requestPath); }