Malicious NPM packages target Amazon, Slack with new dependency attacks

Threat actors are targeting Amazon, Zillow, Lyft, and Slack NodeJS apps using a new ‘Dependency Confusion’ vulnerability to steal Linux/Unix password files and open reverse shells back to the attackers.

Last month, Reported that security researcher Alex Birsan earned bug bounties from 35 companies by utilizing a new flaw in open-source development tools.

This flaw works by attackers creating packages utilizing the same names as a company’s internal repositories or components. When hosted on public repositories, including npm, PyPI, and RubyGems, dependency managers would use the packages on the public repo rather than the company’s internal packages when building the application.

This “dependency confusion” would allow an attacker to inject their own malicious code into an internal application in a supply-chain attack.

Threat actors begin using dependency confusion

While we have seen numerous security researchers impersonate Birsan’s work by creating harmless PoCs to earn bug bounties, we had not seen any malicious activities.

That is until today when open-source security firm Sonatype discovered malicious packages targeting applications related to Amazon, Zillow, Lyft, and Slack to steal passwords and open remote shells.

“I was starting to wonder when we were going to see a malicious actor take advantage of the current situation. Finally, we’ve spotted one.”

These malicious packages are named ‘amzn’, ‘zg-rentals’, ‘lyft-dataset-sdk’, ‘serverless-slack-app’ and utilize similar names as known repositories on GitHub [1, 2] and other projects.

When the threat actors created their malicious NPMs, they used Birsan’s original PoCs as a template but added malicious code.

“They start out with pretty much the same code base as the PoC released by researcher Alex Birsan and they gradually start getting creative,” Aguirre explains.

For example, the ‘amzn’ and ‘zg-rentals’ NPM packages will not only steal the /etc/shadows password file (line 5 below) and send it back to the attackers (line 42) but also open up a remote shell (line 26), giving the threat actors full access to the system.

The ‘lyft-dataset-sdk’ and ‘serverless-slack-app’ appear to be from a different author, and instead steal a Linux profiles .bash_history file and sends it to a remote host under the attacker’s control.

You may be wondering why an attacker would want to steal a .bash_history file?

As the history file contains a list of all the commands you typed in the shell, including passwords passed as arguments, stealing the .bash_history file is a known technique used by attackers to harvest credentials.

With the open and public nature of repositories and the ease of creating dependency confusion attacks, we should expect to see this type of attack continue until application developers secure their configuration files.

Microsoft has created a white paper titled “3 Ways to Mitigate Risk When Using Private Package Feeds” that provides tips on preventing these types of supply-chain attacks.

Sonatype also created a script that Nexus Repository Manager users can use to check if their private dependencies are named after existing packages on public repositories.

NOTE:: This article is copyright by and we are using it for educational or Information purpose only

Best Cyber Security Products & Solutions