Malicious NuGet Packages Abuse MSBuild Integrations for Code Execution


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.

Advertisement. Scroll to continue reading.

“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



Source link