Slaying the Dragons: A Security Professional's Guide to Malicious Packages
This talk explores the landscape of malicious packages within open-source ecosystems, detailing techniques such as typosquatting, code repository abuse, and multi-stage malware delivery. It highlights how threat actors leverage automated tools and AI to scale attacks, infiltrate registries, and exfiltrate sensitive data from developer environments. The presentation provides actionable threat hunting opportunities and defensive strategies for security professionals to identify and mitigate these supply chain risks. Real-world examples, including attacks on Go and Python ecosystems, are analyzed to demonstrate the sophistication of these threats.
Beyond Typosquatting: How Malicious Packages Are Weaponizing Developer Workflows
TLDR: Modern supply chain attacks have evolved far beyond simple typosquatting. Attackers are now using AI-generated code, legitimate cloud services like Gmail for exfiltration, and complex multi-stage payloads to compromise developer environments. Pentesters must treat third-party dependencies as untrusted execution environments and implement strict vetting processes for all incoming packages.
Open-source ecosystems are the backbone of modern software, but they have become a massive, poorly defended attack surface. We no longer write software from scratch. We assemble it from thousands of building blocks, and the security of our entire infrastructure now depends on the integrity of these dependencies. Threat actors have realized that the bar for publishing a package to npm, PyPI, or RubyGems is incredibly low. They are not just waiting for developers to make a typo; they are actively infiltrating these ecosystems with sophisticated, multi-stage malware designed to bypass static analysis and exfiltrate sensitive data.
The Evolution of the Malicious Package
Traditional typosquatting—registering a package name like chalk-node to mimic the popular chalk library—is still common, but it is now just the entry point. The real danger lies in what happens after the package is installed. Modern malicious packages often include post-install scripts that execute immediately upon installation. These scripts are frequently obfuscated using tools like javascript-obfuscator to hide their true intent from automated scanners.
During a recent analysis of malicious campaigns, we observed attackers using PyInstaller to bundle malicious binaries within packages. Once a developer installs the package, the binary executes, often performing credential theft or establishing a reverse shell. The sophistication here is not in the exploit itself, but in the delivery mechanism. By hiding the payload inside a seemingly benign dependency, attackers gain execution context within the developer's machine, which often has access to production secrets, cloud credentials, and internal source code.
Weaponizing Legitimate Infrastructure
Attackers are increasingly using legitimate services to mask their C2 traffic. We have seen campaigns that use Gmail as an exfiltration relay. By hardcoding SMTP credentials into the malicious package, the malware can send stolen data—such as browser cookies, SSH keys, or cryptocurrency wallet seeds—directly to an attacker-controlled inbox. This is a brilliant move because the traffic looks like standard, encrypted mail traffic, which is rarely blocked by corporate firewalls.
Another alarming trend is the use of Ethereum smart contracts for decentralized command and control. By storing C2 instructions on the blockchain, the attacker avoids the need for a traditional, easily sinkholed domain or IP address. The malware simply queries the smart contract to receive its next set of instructions. This makes the infrastructure incredibly resilient and difficult to track.
Threat Hunting for Pentesters
When you are on a red team engagement or performing a security assessment, you need to look at the package.json, requirements.txt, or Gemfile with the same scrutiny you apply to a web application's input fields. If you see a dependency that has a massive spike in downloads but no clear history, or one that includes suspicious post-install scripts, flag it.
Look for these indicators during your reconnaissance:
- Unusual Network Activity: Monitor for connections to unknown endpoints or unexpected services like SMTP or blockchain nodes.
- Obfuscated Code: If a dependency contains a single, massive, unreadable line of code, it is almost certainly malicious.
- Unexpected Binaries: Check if the package is dropping executable files into the system path.
- OAST Usage: Attackers are co-opting Out-of-Band Application Security Testing (OAST) tools to exfiltrate data. If you see traffic going to services like
castify.comorcast.funfrom a build server, investigate immediately.
Defensive Strategies
Defending against these threats requires a shift in how we manage dependencies. You cannot rely on automated scanners to catch everything, especially when attackers are using AI to generate unique, polymorphic code for every new package version.
- Implement an Allow-List: Do not allow developers to pull arbitrary packages from public registries. Use a private repository manager to proxy and vet all dependencies.
- Static Analysis: Integrate tools that scan for suspicious patterns, such as the use of
eval(),base64decoding, or network calls within install scripts. - Least Privilege: Run build processes and development environments with the minimum necessary permissions. A build script should never have access to your production AWS keys.
- Monitor Behavior: Use runtime security tools to monitor the behavior of your build processes. If a build script suddenly tries to access
/etc/shadowor initiate a network connection, kill the process.
The supply chain is the new perimeter. If you are not auditing your dependencies, you are leaving the front door wide open. Start by mapping your dependencies and identifying which ones are critical to your build process. Then, treat every single one of them as a potential vector for compromise. The next time you see a package with a name that is "almost" right, don't just ignore it—decompile it and see what it is actually doing. You might be surprised by what you find.
Vulnerability Classes
Target Technologies
Attack Techniques
OWASP Categories
All Tags
Up Next From This Conference
Similar Talks

Unmasking the Snitch Puck: The Creepy IoT Surveillance Tech in the School Bathroom

Cracking the Lens: Exploiting HTTP's Hidden Attack Surface




