AWS Targeted by a Package Backfill Attack
Table of Contents
On April 28 and April 30, respectively, Supply Chain Defender identified, blocked, and reported two packages we deemed were malicious versions of original Amazon Web Services (AWS) packages. Mend security experts have reached out to contacts at Amazon to notify them of our findings.
This discovery may point to a new takeover method that targets packages of well-known origins, in this case, AWS. At this time, it appears as though malicious actors are scanning AWS projects for dependencies that are not registered in the public npmjs registry and using their names in order to upload the unregistered packages, injected with malicious content.
Why Is AWS Targeted by Malicious Actors?
As AWS is the biggest provider of cloud infrastructure in the world, with a 33 percent market share, it is also a big contributor to the open-source community. A quick search of the term ‘AWS’ on the most popular JavaScript package manager – npm – returns about 13,000 results.
How Did the Package Backfill Attack Unfold?
Thirteen months ago, the package hl7.fhir.r3.core was referenced by AWS as an open-source package. Four months ago, at the beginning of 2022, AWS also published the package @aws-cdk-example-dynamic-web-config/shared. The two packages above were officially authored by AWS before they were removed by a legitimate author, whatever the reasoning was.
Once the packages were removed, their names became available to use in the open-source wilderness. The two packages were then populated with malicious code that was uploaded using their names.
What’s in the Malicious Versions of the AWS Packages?
The first package named hl7.fhir.r3.core only contained a package.json file and no actual malicious content. This package was probably uploaded as a test by the malicious actor to see if he was able to use a name previously used by AWS. This might explain why the name is not a ‘classic’ @aws-… naming.
The more interesting package is, which uses AWS name straightforward, and contains malicious code that exfiltrates user information such as env variables, operating system, and hostname.
Additionally, other information about the machine was collected, such as CPU architecture, total memory available, amount of free memory, network interfaces that contain IP addresses, netmask, MAC address, and more sensitive information.
Figure 1 – Collecting User Information
Figure 2 – Sending the Information Out Using Pipedream:
What Do We Know About the Package Backfill Attack Method So Far?
We do not know for sure that the malicious packages above targeted AWS specifically, but it seems likely considering their actions:
- The actors have located unregistered package names referenced from other AWS projects by discovering which package used to be a dependency of other projects and is no longer in use
- They implemented a name takeover using the name of the original, unused, package and published it to npm with reconnaissance code
How To Avoid Package Backfill Attacks?
One way to prevent such name takeovers is to use a checksum-based lockfile. At the same time, it is important to mention that users often ignore them, assuming that those are just errors.
Mend’s automated malware detection platform, Supply Chain Defender, checks to make sure you’re only using verified package sources and prevents you from importing any malicious package into your organization or personal machine. Mend Supply Chain Defender is free to use. Sign up here >>