diff options
| author | Bond-009 <bond.009@outlook.com> | 2026-07-21 14:52:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-21 14:52:40 +0200 |
| commit | 9b9b609c83404faeff485919b18cb88ce6cc4db6 (patch) | |
| tree | 5f3d6897c40d0c1189c515bda5718cfbdc90f815 /Emby.Server.Implementations/Library | |
| parent | 527ba2e11c8136980fb0864a360cd0c60f1128da (diff) | |
| parent | 4cc69f4be0a568ebc8c922dcf1f855458755ad85 (diff) | |
Merge pull request #17368 from Shadowghost/security-path-traversal-fixes
Backport and extend path traversal fixes
Diffstat (limited to 'Emby.Server.Implementations/Library')
| -rw-r--r-- | Emby.Server.Implementations/Library/PathManager.cs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Library/PathManager.cs b/Emby.Server.Implementations/Library/PathManager.cs index fad948ad97..2a50fcc7fe 100644 --- a/Emby.Server.Implementations/Library/PathManager.cs +++ b/Emby.Server.Implementations/Library/PathManager.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using Jellyfin.Extensions; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; @@ -43,7 +44,19 @@ public class PathManager : IPathManager public string? GetAttachmentPath(string mediaSourceId, string fileName) { var folder = GetAttachmentFolderPath(mediaSourceId); - return folder is null ? null : Path.Combine(folder, fileName); + if (folder is null) + { + return null; + } + + var safeName = PathHelper.GetSafeLeafFileName(fileName); + if (safeName is null) + { + _logger.LogWarning("Rejecting attachment filename '{FileName}' for MediaSource {MediaSourceId}: not a valid leaf name.", fileName, mediaSourceId); + return null; + } + + return Path.Combine(folder, safeName); } /// <inheritdoc /> |
