CVE-2023-43662 (published 2023-09-28T22:15Z)

ShokoServer is a media server which specializes in organizing anime. In affected versions the `/api/Image/WithPath` endpoint is accessible without authentication and is supposed to return default server images. The endpoint accepts the parameter `serverImagePath`, which is not sanitized in any way before being passed to `System.IO.File.OpenRead`, which results in an arbitrary file read. This issue may lead to an arbitrary file read which is exacerbated in the windows installer which installs the ShokoServer as administrator. Any unauthenticated attacker may be able to access sensitive information and read files stored on the server. The `/api/Image/WithPath` endpoint has been removed in commit `6c57ba0f0` which will be included in subsequent releases. Users should limit access to the `/api/Image/WithPath` endpoint or manually patch their installations until a patched release is made. This issue was discovered by the GitHub Security lab and is also indexed as GHSL-2023-191.

CVSS v3 base score: 8.6, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/ShokoAnime/ShokoServer
commit_details: repo_url: https://github.com/ShokoAnime/ShokoServer
author: Kevin Stubbings
author_date: 2023-09-27 17:50:01-07:00
msg: Merge pull request from GHSA-mwcv-ghjq-8f2g

* Fix arbitrary file read WithPath endpoint

* Remove WithPath Endpoint from APIv1

It's unnecessary and a security issue

---------

Co-authored-by: da3dsoul <da3dsoul@gmail.com>
repository: repo_url: https://github.com/ShokoAnime/ShokoServer
repo_name: ShokoAnime/ShokoServer
description: Repository for Shoko Server.
repo_language: C#
owner: ShokoAnime
file_changes: filename: ShokoServiceImplementationImage.cs
change_type: ModificationType.MODIFY
diff: @@ -39,19 +39,6 @@ public class ShokoServiceImplementationImage : Controller, IShokoServerImage, IH
         return System.IO.File.OpenRead(path);
     }
 
-    [HttpGet("WithPath/{serverImagePath}")]
-    public object GetImageUsingPath(string serverImagePath)
-    {
-        if (!System.IO.File.Exists(serverImagePath))
-        {
-            logger.Trace("Could not find AniDB_Cover image: {0}", serverImagePath);
-            return NotFound();
-        }
-
-        Response.ContentType = Mime.GetMimeMapping(serverImagePath);
-        return System.IO.File.OpenRead(serverImagePath);
-    }
-
     [HttpGet("Blank")]
     public object BlankImage()
     {

programming_language: C#