Skip to content

Commit 03d4bb6

Browse files
committed
fix(security): prevent unauthenticated SSRF in imageproxy
1 parent 5e64d49 commit 03d4bb6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/routes/imageproxy.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ function initTvdbImageProxy() {
3232

3333
router.get('/:type/*', async (req, res) => {
3434
const imagePath = req.path.replace(/^\/\w+/, '');
35+
36+
if (
37+
!imagePath.startsWith('/') ||
38+
imagePath.startsWith('//') ||
39+
imagePath.includes('://')
40+
) {
41+
logger.error('Invalid image path detected', {
42+
imagePath: imagePath.slice(0, 200),
43+
});
44+
return res.status(400).send('Invalid image path');
45+
}
46+
3547
try {
3648
let imageData;
3749
if (req.params.type === 'tmdb') {

0 commit comments

Comments
 (0)