The vulnerability, CWE-420 (Unprotected Alternate Channel), exists because ComfyUI-Manager stored its data, configuration, and executable scripts in the user/default/ComfyUI-Manager/ directory. In older versions of the parent application, ComfyUI, the entire user/default/ directory was served by the internal web server and accessible to remote users if ComfyUI was started with the --listen flag. This allowed an unauthenticated remote attacker to read and write files in the manager's data directory, leading to several security risks, including remote code execution.
The primary exploitation vector involves an attacker writing malicious commands to startup-scripts/install-scripts.txt. The prestartup_script.execute_startup_script function would then read and execute these commands the next time ComfyUI was started. Another vector involves modifying config.ini via the exposed directory to lower the security_level, which would disable security checks and allow the attacker to use the manager's own features to install malicious custom nodes.
The patch addresses this vulnerability by migrating the manager's data to a new, protected user/__manager/ directory, which is not served by the web server. This is achieved through a new manager_migration.py module. For systems running older, vulnerable versions of ComfyUI that do not support this protected directory, the patch implements several security hardening measures, such as forcing the security level to its highest setting (strong) and disabling the execution of startup scripts to mitigate the risk.