Hackers have been known to target NuGet due to its popularity as a package manager for .NET, widely used by developers to share and consume reusable code. This makes NuGet a prime target for threat actors looking to distribute malicious code to numerous projects by compromising the packages within the ecosystem.
In August 2023, ReversingLabs, a cybersecurity firm specializing in threat detection, identified a malicious campaign against NuGet. What caught their attention was the evolution in tactics employed by the threat actors involved. Previously, these attackers had been utilizing simple initialization scripts in over 700 malicious packages. However, they had now shifted their focus to using *.targets files to exploit NuGet’s MSBuild integrations, demonstrating a more sophisticated approach to their attacks.
The latest variant of this malicious campaign involves obfuscated downloaders that are embedded into genuine PE binaries using IL weaving techniques. To deceive users and appear legitimate, the threat actors have resorted to tactics such as impersonation, typosquatting, and inflating download counts artificially. By employing these methods, the attackers aim to evade detection and increase the chances of successful infiltration into target systems.
This ongoing threat actor has been persistently targeting NuGet for over six months, showcasing advanced skills that have evolved to incorporate IL weaving techniques. By utilizing IL weaving, the attackers can inject malicious module initializers into authentic .NET binaries, making it harder to detect and mitigate their activities. Recent attacks have involved tampering with DLL files from popular packages like Guna.UI2.WinForms and utilizing typosquatting to bypass NuGet’s prefix reservation system, ultimately leading to the download of obfuscated SeroXen RAT malware using the injected code.
Despite the increased complexity introduced by compiled binaries compared to plaintext scripts, tools like ReversingLabs Spectra Assure can still identify suspicious functionalities within altered packages. This dynamic underscores an ongoing challenge faced by the cybersecurity community in combating evolving threats within the .NET ecosystem.
Researchers have noted that the NuGet campaign employs homoglyphs to circumvent prefix reservations, resulting in the creation of packages that appear genuine but are, in fact, malicious. By leveraging IL weaving to modify legitimate DLLs and inject obfuscated module initializers, the threat actors make it difficult for traditional malware detection solutions to identify and thwart their activities.
ReversingLabs identified approximately 60 packages and 290 versions as part of this campaign, all of which had already been removed from NuGet. The emergence of new tactics in supply chain threats, such as binary patches and advanced typosquatting, underscores the need for development organizations to be vigilant and implement advanced detection techniques to counter these stealthy attacks targeting open-source package managers.
In conclusion, the evolving tactics of threat actors within the .NET ecosystem highlight the importance of staying ahead of emerging threats and enhancing cybersecurity measures to protect against malicious activities targeting widely used platforms like NuGet. By remaining vigilant and leveraging advanced detection technologies, organizations can strengthen their defense against sophisticated attacks aimed at compromising the integrity of their code repositories and software supply chains.

