#174 Fix: validate share link before serving direct asset URLs
This commit is contained in:
+3
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user