Detecting and Analyzing a PyPI Supply Chain Attack: The ZiChatBot Case Study

Overview

In July 2025, a sophisticated supply chain attack targeting the Python Package Index (PyPI) was uncovered. Threat actors linked to the OceanLotus group uploaded malicious wheel packages disguised as legitimate libraries. These packages, while appearing to perform benign functions, secretly delivered a previously unknown malware family named ZiChatBot. Unlike traditional botnets, ZiChatBot does not rely on a dedicated command-and-control (C2) server; instead, it abuses the public REST APIs of the Zulip team chat application to receive commands and exfiltrate data. This case study walks through the detection, analysis, and understanding of this attack, providing a practical guide for security researchers and defenders.

Detecting and Analyzing a PyPI Supply Chain Attack: The ZiChatBot Case Study
Source: securelist.com

The attack involved three fake PyPI projects: uuid32-utils, colorinal, and termncolor. These packages were designed to mimic popular libraries, tricking developers into installing them via pip install. Once installed, the malicious packages dropped either a DLL (Windows) or shared object (.so) file (Linux), serving as a dropper for the final ZiChatBot payload. The campaign highlights the importance of monitoring open-source package repositories for malicious activity.

Prerequisites

Knowledge Requirements

Tools and Environment

Step-by-Step Guide

1. Identifying Malicious PyPI Packages

The first step is to recognize suspect packages in the PyPI repository. In this case, the attacker uploaded three packages with recent first-upload dates and suspicious author emails:

These packages claim to provide UUID generation and terminal color formatting, but they contain hidden malicious code. To identify such threats, examine the wheel file metadata and check for unexpected .pyd or .so files. For example, the colorinal project offers multiple platform-specific wheels:

Download and extract a wheel file using unzip to inspect its contents. Look for binary files in unexpected locations (e.g., inside colorinal/ directory alongside Python scripts). The presence of a DLL or .so file that isn't part of a standard Python extension may indicate a dropper.

2. Analyzing the Infection Chain

Both uuid32-utils and colorinal use similar infection chains. The focus here is on colorinal. After installation, the package imports a module that loads the malicious binary from a hardcoded location. For example, the code might do:

import os
import sys
# Decode and execute shellcode or load DLL
if sys.platform == 'win32':
    os.system('rundll32.exe malicious.dll')  # simplified example

In reality, the actual loading mechanism is obfuscated. The dropper decrypts or extracts the payload (ZiChatBot) and runs it in memory to avoid disk detection. On Linux, it uses dlopen to load a shared library. The payload communicates back to the attacker via the Zulip API.

To analyze the dropper statically, decompile the Python bytecode using tools like uncompyle6 or pycdc. Look for strings referencing Zulip endpoints, API keys, or encryption routines.

3. Understanding the ZiChatBot Payload

ZiChatBot is a new malware family that, instead of traditional C2, uses the Zulip team chat service's public REST API. The bot registers as a Zulip user (or abuses an existing bot account) to listen for commands and send back data. Key characteristics:

Detecting and Analyzing a PyPI Supply Chain Attack: The ZiChatBot Case Study
Source: securelist.com

Reverse-engineer the binary (e.g., using IDA Pro for the DLL) to identify the Zulip API calls, like GET /messages or POST /messages. The bot likely uses an API token stored encrypted within the dropper.

4. Mapping C2 via Zulip APIs

To understand the command flow, set up a test environment and run the malware (in a sandbox) with network monitoring. Use mitmproxy or Wireshark to capture HTTPS traffic to Zulip API endpoints. Look for patterns:

By analyzing the traffic, you can understand the bot's update cycle and potentially spoof the C2 to issue decoy commands. The attacker creates a dedicated Zulip organization and stream for each victim group, making it harder to take down.

Common Mistakes and Pitfalls

Summary

This case study reveals how the OceanLotus group executed a PyPI supply chain attack using three fake packages to deliver the ZiChatBot malware. By imitating common libraries (UUID generation, color formatting) and leveraging Zulip's REST APIs for C2, the attackers evaded traditional detection. Defenders must adopt proactive measures: scrutinizing package metadata, analyzing wheel contents, monitoring for unusual network traffic to SaaS APIs, and sharing threat intelligence. The ZiChatBot campaign underscores the evolving sophistication of supply chain threats and the need for continuous vigilance in open-source ecosystems.

Recommended

Discover More

Effortless Security: Managing Sensitive Data in Performance Tests with Grafana Cloud k6React Native 0.84: Boosted Performance with Hermes V1 and Streamlined BuildsHow to Teleport a Photon State Between Quantum Dots Over 270 Meters: A Step-by-Step Guide7 Must-Have Android Game & App Deals Today (Plus Hardware Savings)Space Force Accelerates Golden Dome Program: Orbital Missile Interceptors Targeted for 2028 Demo