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.

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

Related Content

Malware & Threats

A new Android trojan named Brokewell can steal user’s sensitive information and allows attackers to take over devices.

Malware & Threats

A North Korea-linked threat actor hijacked the update mechanism of eScan antivirus to deploy backdoors and cryptocurrency miners.

Malware & Threats

A threat actor tracked as CoralRaider has been using multiple infostealers to harvest credentials from users worldwide.

Malware & Threats

Russia-linked APT28 deploys the GooseEgg post-exploitation tool against numerous US and European organizations.

Malware & Threats

Checkmarx warns of a new attack relying on GitHub search manipulation to deliver malicious code.

Malware & Threats

Human Security identifies 28 VPN applications for Android and an SDK that turn devices into proxies.

Malware & Threats

A suspicious NuGet package likely targets developers working with technology from Chinese firm Bozhon.

Malware & Threats

More than 100 organizations in the US and EU have been targeted in recent StrelaStealer infostealer campaigns.

Copyright © 2024 SecurityWeek ®, a Wired Business Media Publication. All Rights Reserved.

Exit mobile version