The vulnerability, identified as GHSA-m6hv-x64c-27mm, was caused by an incomplete check in the copyparty file serving logic. The nohtml configuration flag was intended to prevent Cross-Site Scripting (XSS) by serving potentially dangerous files as plain text. However, the implementation only checked for 'html' in the file's MIME type, completely missing other file types that can execute JavaScript, most notably SVG images (image/svg+xml).
The analysis of the patch commit 1c9f894e149b6be3cc7de81efc93a4ce4766e0e5 reveals that the core of the vulnerability was in the HttpCli.tx_file and HttpCli.tx_zget methods within copyparty/httpcli.py. These functions are responsible for serving files to the user, either directly from the filesystem or from within a zip archive.
The patch introduces a more robust check. Instead of just looking for 'html', it now checks the file's MIME type against a pre-defined set of safe MIME types (SAFE_MIMES). If the MIME type is not in this safe set, the new safe_mime utility function is called to return a safe MIME type, either text/plain or application/octet-stream. This forces the browser to download the file or render it as text, rather than executing it, thus mitigating the XSS vulnerability.
The vulnerable functions are HttpCli.tx_file and HttpCli.tx_zget because they were the ones that would, upon request for a malicious SVG file, serve it with a content type that caused the browser to execute embedded scripts. The safe_mime function is included as a mitigation function that is now part of the execution flow when serving potentially unsafe files.