#174 Fix: validate share link before serving direct asset URLs

This commit is contained in:
Alan Grainger
2026-01-12 21:08:47 +13:00
parent a9acfc3135
commit 765afd9e26
3 changed files with 258 additions and 77 deletions
+3 -2
View File
@@ -125,8 +125,9 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
return
}
// Security fix: Validate share link and check password before serving assets
// Validate share link and check password before serving assets
// This prevents direct URL access from bypassing password protection
// The password is provided from the encrypted session cookie (if set)
const share = await immich.getShareByKey(req.params.key, req.password)
if (!share) {
respondToInvalidRequest(res, 404, 'Invalid share link')
@@ -140,7 +141,7 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
}
// Verify the requested asset belongs to this share link
const assetBelongsToShare = share.assets?.some(a => a.id === req.params.id)
const assetBelongsToShare = share.link?.assets?.some(a => a.id === req.params.id)
if (!assetBelongsToShare) {
respondToInvalidRequest(res, 404, 'Asset not found in share')
return