In the world of cloud computing and neural networks, security often takes a backseat. Many developers and enthusiasts rent powerful GPU servers on platforms like Clore.cloud or Vast.ai to work with artificial intelligence. However, by leaving the standard ComfyUI port (8188) open to the entire internet, users risk not only losing control of their resources but also becoming victims of cunning attacks.

Attack Mechanics: From Scanning to Infiltration

Recently, a real hacking incident was recorded where attackers used extremely sophisticated masking methods. It all started with scanning bots monitoring the network 24/7 for unprotected ComfyUI ports. As soon as such a server is detected, the bot automatically installs a plugin for executing arbitrary code via the standard ComfyUI-Manager interface — in this case, srl-nodes was used.

This plugin became the key to the system: through it, hackers injected malicious code directly into the core of the neural network generation, modifying the execution.py file. Thus, the mining process became an integral part of the neural network's operation itself.

"Smart" Miner Masking

To avoid detection, the virus acted extremely covertly. Its algorithm was built on dynamic load management:

  • Stealth Mode: As soon as the user launched image generation, the miner automatically stopped, freeing up the graphics card and processor. After generation was complete, it resumed work.
  • Anti-Removal Protection: The virus constantly checked its own activity. If the owner tried to stop the process, the built-in scheduler generated new random paths on the server, downloaded clean files from GitHub, and launched them under different names — for example, cleaner-run, task-agent02, auth-cleaner.

This tactic allowed the miner to remain undetected even during active server usage.

Solution Without Stopping Operations

The peculiarity of the situation was that dozens of websites, Telegram bots, and external scripts were connected to the server. Simply blocking access to ComfyUI was impossible — it would have broken all automation. To solve the problem, special protection was developed.

Together with the AI coding agent Antigravity, a security plugin comfyui-2ips-guard was created. It is embedded directly into the neural network's web server at startup and checks the IP addresses of all incoming requests:

  • Requests from trusted IPs (home PC, website servers, and bots) pass instantly and without changes.
  • Any other requests (including hacker scanners) immediately receive a 403 Forbidden error.

This allowed for the complete exclusion of attacker access without disrupting existing integrations.

Conclusion and Key Lesson

The malicious code was removed, miners were deleted, and ComfyUI is now securely protected by an IP whitelist without the need to change Docker settings or external script code.

The main takeaway from this story is simple but critically important: never leave neural network interfaces open to the entire internet without IP filtering or the use of a VPN. Even if it seems that your server is of no interest to anyone — it can become an easy target for automated attacks.