A backdoor was found hiding inside dbgpkg v1.3.7, a package that markets itself as a "Python Debugging Toolkit" on PyPI. Armando's analysis of the package shows that the malicious code fires automatically the moment the package is imported -- no install hook required. The package was published on May 13, 2025, and has since been removed from PyPI. With 439 total downloads across three versions, all of which are malicious, the package was a purpose-built attack vehicle from its first release. The backdoor establishes a reverse shell using gsocket and exfiltrates data via Pastebin, using RSA encryption to conceal the channel.
Key Findings
- Malicious version: v1.3.7, published 2025-05-13; no clean version exists -- all three releases are malicious
- Entry point:
__init__.py import-time execution and setup.py install lifecycle hook fire automatically on Python import and pip install respectively
- Targets: Python developers on any platform -- installs a gsocket reverse shell backdoor
- Evasion: RSA-encrypted exfiltration of the gsocket binary path to Pastebin hides the C2 channel from plaintext scanning; v1.3.7 has no duplicate-process check, firing on every import
- Detection: Script-Python.Backdoor.SupplyChain, Archive-ZIP.Backdoor.SupplyChain
Package Background
dbgpkg presents itself as a Python debugging utility with an MIT license. Its PyPI description reads "Python Debugging Toolkit" and it links to a blank GitHub profile page. The package has no declared source code repository -- a notable anomaly for a utility aimed at developers. It was first published on May 13, 2025, and all three versions (1.3.6, 1.3.7, 1.3.8) were published within 16 minutes of each other on the same day, forming a tight publication cluster consistent with a single attacker seeding multiple versions simultaneously. The package had 439 total downloads and zero direct imports by other public packages before PyPI removed it.
The publisher account is registered as "Lukasa" with the email me@lukasa.org. This mirrors the identity of Cory Benfield, a well-known Python HTTP ecosystem maintainer whose legitimate packages include h2, hpack, hyperframe, hyper, wsproto, and others. The same publisher account lists 24 packages -- nearly all of them are names directly taken from Benfield's real portfolio or from the broader Python HTTP/networking ecosystem (requests, certifi, brotlipy, priority, pep543). This is a systematic name-squatting campaign impersonating a known, trusted developer to capture installs from developers who search for or mistype these package names.
Attack Analysis
dbgpkg v1.3.7 embeds its malicious payload inside __init__.py, the module's top-level initialization file. This is a deliberate choice: __init__.py executes unconditionally the moment any Python code imports the package with import dbgpkg. There is no install-time step required; the backdoor fires silently at import time, with no output or error to alert the victim.
Armando's analysis shows the code defines a Proxy class that monkey-patches the requests and socket Python modules at runtime, hooking into the network layer before establishing its C2 channel. The attack sequence is as follows. On first invocation, the code fetches an RSA public key from Pastebin using a hardcoded paste key (qzTFV1NH). It then downloads and executes a gsocket reverse shell binary from https://gsocket.io/y. After the binary runs, the malicious code encrypts the gsocket binary's path on disk using the attacker's RSA public key and sends the encrypted result back to Pastebin via the Pastebin API (https://pastebin.com/api/api_post.php). This exfiltration step tells the attacker exactly where the binary was installed on the victim's system.
The use of RSA encryption for the exfiltration payload is a deliberate evasion choice: the binary path is never transmitted in plaintext, so network-layer tools that scan for recognizable strings would not flag the outbound traffic. Notably, v1.3.7 performs no duplicate-process check before launching gsocket -- it fires on every import. This means repeated imports of the package cause repeated gsocket invocations, which increases the attacker's visibility into the victim environment.
The package also registers a setup.py install hook. This gives the attacker a second execution path: pip install dbgpkg triggers setup.py during installation, before a developer ever writes import dbgpkg in their code. The pyproject.toml build system configuration reinforces this by declaring a build-time entry point. Between the install hook and the import-time execution, the backdoor has two independent triggers -- either one is sufficient to compromise the target.
Malicious Files
__init__.py is the primary malicious payload. It implements an import-time backdoor using a Proxy class that monkey-patches the requests and socket modules. On first invocation, it fetches an RSA public key from Pastebin (paste key qzTFV1NH), downloads and executes a gsocket reverse shell binary from https://gsocket.io/y, then encrypts the binary's installation path with the RSA key and exfiltrates the result back to Pastebin via https://pastebin.com/api/api_post.php. In v1.3.7, no duplicate-execution guard is present, so the sequence fires on every import. Detected as Script-Python.Backdoor.SupplyChain.
setup.py provides the install-time execution path. It is flagged as a container of malicious content (__init__.py and PKG-INFO) and fires when pip processes the sdist distribution. Detected as Script-Python.Backdoor.SupplyChain.
pyproject.toml declares the build-system configuration and registers the build entry point, reinforcing the install-time execution path alongside setup.py. Detected as Text.Backdoor.SupplyChain.
PKG-INFO carries metadata consistent with the malicious package identity. Detected as Text.Backdoor.SupplyChain.
dbgpkg-1.3.7-py3-none-any.whl is the wheel distribution, containing __init__.py and PKG-INFO. Detected as Archive-ZIP.Backdoor.SupplyChain.
dbgpkg-1.3.7.tar.gz is the sdist tarball, containing all malicious components including setup.py, pyproject.toml, and __init__.py. Detected as Archive-GZIP.Backdoor.SupplyChain.
Recommendations
Developers and security teams should take the following steps:
- Identify exposure: Check whether dbgpkg v1.3.7 (or any version of dbgpkg) appears in your dependency tree, including transitive dependencies. Any pipeline that ran
pip install while this version was current should be considered potentially affected.
- Update immediately: Remove dbgpkg entirely -- there is no clean version to upgrade to. The package has been removed from PyPI.
- Inspect affected systems: On machines that installed the malicious version, check for a running gsocket process, inspect Pastebin API call logs, and look for unexpected outbound connections to
gsocket.io. The encrypted binary path exfiltrated to Pastebin may indicate whether the reverse shell was established.
- Rotate credentials: If dbgpkg was imported in a development or CI/CD environment, assume that environment's credentials and network access have been exposed to the attacker via the gsocket reverse shell.
- Scan your software supply chain: Use Spectra Assure Community to check whether packages in your environment have been flagged.
Indicators of Compromise
Malicious Files
| Filename | SHA256 | Detection |
|---|
| dbgpkg-1.3.7-py3-none-any.whl | 1206840fe50cb492f800c8cb9c3a8880d4b4768c5d5cdb9f4240be0a3d2924a6 | Archive-ZIP.Backdoor.SupplyChain |
| init.py | 92264fb0ac58c51689c0c32019c6b545ae8f3a3d70744b947b9e05ec67c40c6f | Script-Python.Backdoor.SupplyChain |
| PKG-INFO | f1129cb539df49a2d6f3e6ba0e63fcd920da163650aad78707c16f9ec02da1cf | Text.Backdoor.SupplyChain |
| setup.py | 0c99c5b7fcb8aa257830ec7f0977e122db3a331f8f4bec65677bb9edfc59b00d | Script-Python.Backdoor.SupplyChain |
| pyproject.toml | b300606bbda19a52b92b529ce93e65736e5d6cecadf133d6882a918b30de6dd7 | Text.Backdoor.SupplyChain |
Network IOCs
| URL / IP | Purpose |
|---|
| https://pastebin.com/api/api_post.php | RSA public key retrieval and encrypted binary path exfiltration endpoint |
| https://gsocket.io/y | Reverse shell binary download and execution endpoint |
Archive Hashes
| File | SHA256 |
|---|
| dbgpkg-1.3.7.tar.gz | d4a67427eec07f5f7bd7dc05ce3a0419de272f3b667dd011baa6da8b47d78068 |
| dbgpkg-1.3.7.tar | 47c478f8fed3a3e3f1f4131cd7322427a2de90fb1e48f358dfd656830d703c16 |