Connect with us

Hi, what are you looking for?


Malware & Threats

Malicious NuGet Packages Abuse MSBuild Integrations for Code Execution

Threat actors are constantly publishing malicious NuGet packages to automatically execute code on developers’ machines.

As part of an ongoing and coordinated campaign, threat actors have been continuously publishing malicious NuGet packages with hidden code execution capabilities, threat detection firm ReversingLabs reports.

The campaign has been ongoing since at least the beginning of August, with several hundred malicious packages published to the NuGet repository to date.

The threat actor behind the campaign has been observed updating tactics in response to disruptions and taking more sophisticated approaches to code execution, including exploiting NuGet’s MSBuild integrations feature.

Just as in similar attacks targeting the NPM, PyPI and RubyGEMS ecosystems, typosquatting is used to trick developers into downloading the malicious packages.

However, while previously seen malicious NuGet packages would place code inside the initialization and post installation PowerShell scripts, the recently identified ones placed the malicious functionality inside the .targets file in the ‘build’ directory.

The technique is borrowed from the IAmRoot package that was published in 2019 to demonstrate the execution of arbitrary code using NuGet packages that contain .targets files with an inline task containing executable code.

If a package containing such a .targets file is added to other packages, the code would be automatically executed when any of those packages is built.

“Based on our research, this is the first known example of malware published to the NuGet repository exploiting this inline tasks feature to execute malware,” ReversingLabs says.

Advertisement. Scroll to continue reading.

The security firm initially identified four NuGet packages with this capability, which were removed from the repository in mid-October. A week later, a new set of similar packages was published and their download counts inflated, to increase their visibility.

Imitating popular packages, the campaign appears to have strong links to two previously reported attacks, one delivering the SeroXen RAT and another leading to Impala Stealer infections. The same delivery mechanism was used in hundreds of malicious packages that were identified in August.

“The threat actors behind [this ongoing campaign] are tenacious in their desire to plant malware into the NuGet repository, and to continuously publish new malicious packages. As soon as the previous packages are removed from the repository, ReversingLabs detects newly published packages on a daily basis,” the security firm notes.

Related: Hundreds Download Malicious NPM Package Capable of Delivering Rootkit

Related: Thousands of Code Packages Vulnerable to Repojacking Attacks

Related: Developers Warned of Malicious PyPI, NPM, Ruby Packages Targeting Macs

Written By

Ionut Arghire is an international correspondent for SecurityWeek.

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest threats, trends, and technology, along with insightful columns from industry experts.

Join us as we delve into the transformative potential of AI, predictive ChatGPT-like tools and automation to detect and defend against cyberattacks.


As cybersecurity breaches and incidents escalate, the cyber insurance ecosystem is undergoing rapid and transformational change.


Expert Insights

Related Content


The changing nature of what we still generally call ransomware will continue through 2023, driven by three primary conditions.


A recently disclosed vBulletin vulnerability, which had a zero-day status for roughly two days last week, was exploited in a hacker attack targeting the...

Malware & Threats

The NSA and FBI warn that a Chinese state-sponsored APT called BlackTech is hacking into network edge devices and using firmware implants to silently...


No one combatting cybercrime knows everything, but everyone in the battle has some intelligence to contribute to the larger knowledge base.

Application Security

Virtualization technology giant VMware on Tuesday shipped urgent updates to fix a trio of security problems in multiple software products, including a virtual machine...

Malware & Threats

Unpatched and unprotected VMware ESXi servers worldwide have been targeted in a ransomware attack exploiting a vulnerability patched in 2021.


The recent ransomware attack targeting Rackspace was conducted by a cybercrime group named Play using a new exploitation method, the cloud company revealed this...

Malware & Threats

Threat actors are increasingly abusing Microsoft OneNote documents to deliver malware in both targeted and spray-and-pray campaigns.