Connect with us

Hi, what are you looking for?

SecurityWeekSecurityWeek

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.

Advertisement. Scroll to continue reading.

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.

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.

Trending

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.

In cyber-physical systems (CPS), just one hour of downtime can outweigh an entire annual security budget. Learn how to master the Return on Security Investment (ROSI) to align security goals with the bottom-line priorities.

Register

Delve into big-picture strategies to reduce attack surfaces, improve patch management, conduct post-incident forensics, and tools and tricks needed in a modern organization.

Register

People on the Move

Malwarebytes has named Chung Ip as Chief Financial Officer.

Semperis has appointed John Podboy as Chief Information Security Officer.

Randy Menon has become Chief Product and Marketing Officer at One Identity.

More People On The Move

Expert Insights

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest cybersecurity news, threats, and expert insights. Unsubscribe at any time.