Malicious ‘dependency confusion’ packages are stealing password files

The new vulnerability is targeting Amazon, Zillow, Lyft, and Slack code repositories

Security researchers have identified malicious code in JavaScript repositories that could enable hackers to steal password files in Linux and Unix systems.

According to cyber security firm Sonotype, these “dependency confusion” packages are published to the npm ecosystem and named after repositories, namespaces, or components companies commonly use, such as Amazon, Zillow, Lyft, and Slack. These malicious packages include amzn, zg-rentals, lyft-dataset-sdk, and serverless-slack-app.

Hackers created packages using names similar to ones found in a legitimate organization’s internal repositories. In public repositories, such internal names can be found referenced in public code repositories, such as GitHub, in source code files. 

When hosted on a public site, dependency managers use these packages rather than internal ones belonging to a company when creating an application.

This "dependency confusion" enables hackers to insert their malicious code into an internal application to carry out a supply-chain attack. Researchers said many of these packages have no disclaimers or code comments in place that indicate these are linked to any kind of ethical bug bounty program or created for security research purposes. 

While having such a disclaimer is no guarantee a package’s author is working in good faith, a lack of one can surely raise alarm bells, especially when combined with malicious code, said researchers.

“As soon as these packages are installed automatically because they share a name with an internal dependency (thereby exploiting “dependency confusion”), they exfiltrate the user’s .bash_history file and /etc/shadow, and in some cases spawn a reverse shell,” said researchers.

In one example, a package named “amzn” contained code that opened a reverse shell to their server, which would spawn as soon as the `amzn` package infiltrated the vulnerable build. It also displayed the contents of a /etc/shadow file.

The /etc/shadow file is a successor to the /etc/passwd Linux file that maintains hashed password data of user accounts on a system.

“Although the file is typically restricted to “superuser” accounts, there remains a slight chance of a malicious actor, in this case, being able to obtain the file should the infected machine be running npm with elevated privileges,” said researchers.

Sonatype security researcher Juan Aguirre said he was “starting to wonder when we were going to see a malicious actor take advantage of the current situation. Finally, we've spotted one.”

“There is no scenario I can imagine where I'm going to submit a PoC for a bug bounty program that actually harms the organization. Taking their /etc/shadow file is definitely harmful,” he added.

In creating these malicious packages, hackers have used the same code base as the proof-of-concept PoC released by security researcher Alex Birsan, who discovered this flaw. The hackers then got creative.

“These packages stood out because they reflect the behavior of actual malware, a first stage payload to grab a binary which further grabs your bash history,” said Aguirre.

While some malicious packages steal the /etc/shadow password file, some others, such as “lyft-dataset-sdk” and “serverless-slack-app,” steal a .bash_history file and send it to a remote host under the hacker’s control. This file lists all commands typed into a shell, including passwords. This enables hackers to harvest credentials.

Researchers said they only expect this trend to increase, with adversaries abusing dependency confusion to conduct even more sinister activities.

Organizations have been urged to download a “dependency/namespace confusion checker” script from GitHub to check if they have artifacts with the same name between repositories and determine if a dependency confusion attack has impacted them in the past.

Featured Resources

The ultimate guide to business connectivity in field services

A roadmap to increased workplace efficiency

Free download

The definitive guide to migrating to the cloud

Migrate apps to the public cloud with multi-cloud infrastructure solutions

Free download

Transform your network with advanced load balancing from VMware

How to modernise load balancing to enable digital transformation

Free download

How to secure workloads in hybrid clouds

Cloud workload protection

Free download

Recommended

Microsoft to scrap Basic Authentication
Microsoft Windows

Microsoft to scrap Basic Authentication

27 Sep 2021
What is a web filter?
cyber security

What is a web filter?

24 Sep 2021
100 million IoT devices affected by zero-day flaw
Internet of Things (IoT)

100 million IoT devices affected by zero-day flaw

24 Sep 2021
Malware developers create malformed code signatures to avoid detection
malware

Malware developers create malformed code signatures to avoid detection

24 Sep 2021

Most Popular

How to find RAM speed, size and type
Laptops

How to find RAM speed, size and type

17 Sep 2021
What are the pros and cons of AI?
machine learning

What are the pros and cons of AI?

8 Sep 2021
Best MDM solutions 2020
mobile device management (MDM)

Best MDM solutions 2020

17 Sep 2021