ReversingLabs researchers recently discovered more than a dozen malicious packages published to the npm open source repository that appear to target application end users while also supporting email phishing campaigns targeting Microsoft 365 users. Some key takeaways from our report:
- The discovery may be the first ‘dual use’ campaign in which malicious open source packages power both commodity phishing attacks and higher end software supply chain compromises.
- The malicious npm packages were discovered in two tranches: One supported phishing attacks that harvested user data with phony Microsoft.com login forms launched from malicious email attachments. The other was intended to implant credential harvesting scripts in applications that inadvertently incorporate the npm packages.
- The malicious packages were posted to npm between May 11th and June 13th. They mimic legitimate npm modules, notably jquery, which has close to 7 million weekly downloads.
- The malicious packages were downloaded around 1,000 times in total, but were removed from npm shortly after their discovery. ReversingLabs has dubbed the campaign “Operation Brainleeches,” based on malicious infrastructure used to facilitate the theft of victim data.
- With npm used to support malicious campaigns, organizations should check their exposure to these malicious modules, which may indicate a broader, malicious campaign.
At ReversingLabs, our researchers’ time is dedicated to combing through public code repositories in search of malicious packages. These range from primitive infostealers that exfiltrate information from infected machines (some of which are probably benign and related to red team activities); to malicious modules that are designed to steal user credentials, access tokens and other sensitive information. When we find a malicious package, we report it to the affected repository’s administrators to remove the package, if they haven’t already done so.
Recently, our researchers came across a malicious campaign on the npm open source repository that encompassed more than a dozen files designed to steal sensitive user credentials. As we’ll discuss later, there were a number of “red flags'' that indicated these packages were malicious. They were analyzed in depth using ReversingLabs Software Supply Chain Security. What follows is our threat research team's findings and an analysis of the malicious campaign, which we’re dubbing “Operation Brainleeches.”
More red flags wave on npm
This most recent campaign caught our attention because of a number of features and characteristics in related npm packages that correlate with malicious intent. In many of the packages that make up the Operation Brainleeches campaign, our researchers noted the presence of new and relatively unsophisticated npm packages, maintained by relatively new and cursory maintainer accounts. Finally, many of these packages contained files that were obfuscated.
New files and sketchy maintainer accounts don’t obviously signal “malicious intent.” But obfuscation of code in ostensibly open source packages - together with those other characteristics - is a tell-tale sign that something is amiss. There is the obvious question: ‘Why do you need to shield code in a software module that is public property?’ There is also the high correlation between open source modules that use obfuscation and open source modules that are found to be malicious. We have noted this previously in our research on nodejs-encrypt-agent (see “RATs found hiding in the npm attic”). You can also hear ReversingLabs researcher Karlo Zanki talk about this correlation in an episode of the ConversingLabs podcast.
A double threat
Ultimately, our inquiry into the suspicious characteristics revealed 13 malicious packages that we’ve grouped into two tranches with similar contents, but different purposes.
The first group includes six packages: different versions of npm packages named standforusz and react-vuejs (version 3.0.10). These were published in the middle of May and, based on our analysis, were used exclusively for hosting files used in widespread phishing campaigns, which were likely derived from “turn-key” phishing kits sold on the cyber underground. These packages contain the following files:
Figure 1: Content of packages used in phishing campaigns
The second group of packages, seven in all, includes versions of npm packages named tetusdgsudgs, jqueryoffline, vueofflinez, jquerydownloadnew and react-vuejs (version 10.21.30).They were published in early June and can be used both for hosting files used in email phishing campaigns and performing supply chain attacks targeted at application end users, based on our analysis.
Figure 2: Content of packages used in supply chain campaigns
In the following sections, we’ll detail the characteristics of these dual attacks and what they say about the rapid evolution of supply chain threats.
Phase 1: Phishing the supply chain
In our experience, malicious packages found on public repositories such as npm or PyPI target developers - the people who directly use them. As in campaigns like those targeting SolarWinds and 3CX, these supply chain attacks sit at the “sophisticated” end of the scale. They are long-term plays in which skilled cyber actors quietly infiltrate development pipelines and slip malicious code or dependencies into legitimate application updates. Patience pays off: they reap the bounty of hundreds or thousands of victims as unsuspecting users of those applications download and install the signed, but compromised update.
However, after unpacking and deobfuscating files from this first tranche of malicious npm packages, it became very apparent (to us) that we were looking at a new manifestation of supply chain risk. Specifically: our analysis revealed that these malicious packages were being used as supporting infrastructure for a phishing campaign targeting Microsoft 365 customers.
Standforusz: Microsoft 365 phishing made easy
A key to this realization was the npm package standforusz, which contained the files DEMO.txt, jquery.js, jquery.min.js and package.json. ReversingLabs researchers observed malicious email attachments containing the jquery.js paired with phishing emails. When the malicious attachments are opened by victims in a browser, jquery.js was observed fetching jquery.min.js from the content delivery network (CDN) jsDelivr and writing the content of that file to a dynamically created “document". The jquery.min.js's content fetches DEMO.txt also from CDN jsDelivr and writes its content to the same "document".
The DEMO.txt file contains HTML code that mimics the login for Microsoft.com. It also includes the URL of a remote server, hxxp://ourwhite.brainleeches.xyz, to which harvested credentials from the form are sent. The diagram below (Figure 3) shows the flow of the activity once the malicious attachment is opened in their web browser.
Figure 3: Flow of the activity when malicious attachment is opened in web browser
Evidence of turnkey attacks
Observing this campaign in action was challenging, as the malicious domain used in it was taken offline by the time our analysis was conducted. However, our researchers were able to identify examples of the malicious email attachments containing files from these modules in the wild. They contained vestiges of the original attack, including a page displaying a background image identical to the background image used with the Microsoft login. By and large, these appeared to be part of ‘turnkey’ attacks spawned by phishing kits that are sold and licensed to unsophisticated malicious actors.
Figure 4: Real Microsoft login form
To show what the victim would actually have seen when the domain was active, we made a few tweaks. Figures 4 and 5 serve as a comparison between the actual Microsoft login form (Figure 4) and the fake one presented to unsuspecting end users (Figure 5).
Figure 5: Fake Microsoft login form
The fake Microsoft.com login wasn’t the only trick up the attackers' sleeves. Our analysis revealed another phishing page geared to gather Microsoft 365 credentials. Unlike the previous pages, this displayed a blurred document overlaid with what appears to be a Microsoft login screen. The implication is that the document can be viewed only if logged in to a Microsoft account.
As it turns out, the ”blurred document” is actually just a picture formatted as a background that is intentionally blurred to entice the end user to enter their Microsoft account credentials (Figure 6). Passwords entered into this form were sent to a different location, a server located at the address 18.104.22.168.
Figure 6: Malicious form presented to end users
The malicious actors behind these phishing attacks took steps to make it more likely that the victim would enter their Microsoft credentials, also. Those included attempting to disable right mouse button functions on the web page and disabling the ability of users to open developer tools with a hot-key. Those steps made the malicious intent less likely to be discovered.
Figure 7: HTML attachment used in phishing campaign found in the wild
As we noted, npm in this phase of the campaign is used primarily as a host for a malicious component of the attack, rather than a platform to target developers (or end users as in the case of Phase 2 packages) with malicious, open source modules. Our open source research uncovered both remnants of Operation Brainleeches, as well as a very large number of similar email phishing attachments spawned by slightly different, but closely related phishing kits. That suggests that the modules identified in Phase 1 of the attack were likely not unique, but part of a broader wave of attacks orchestrated by low level actors outfitted with powerful and automated tooling.
Phase 2: Developers in the crosshairs
As we noted, Operation Brainleeches comprised two phases and two, distinct tranches of malicious npm packages. While the first was clearly intended to support indiscriminate and automated phishing email attacks, the second group of npm packages had a different flavor, and appeared more in line with other software supply chain attacks we have analyzed.
Specifically: the purpose of the second phase of the Brainleeches campaign appears to have been tricking developers into incorporating the malicious packages into legitimate applications.
As was the case in the first phase of the attack, the ultimate objective here, also, was phishing credentials. In other words, as in Phase 1, the target of the malicious code embedded in these npm packages was not developers or development organizations, but end users of the developed applications (and their data).
In the following sections we’ll discuss some of our findings from an analysis of the files contained in this group of malicious npm packages: tetusdgsdgs, jqueryoffline, vueofflinez, and jquerydownloadnew.
Jqueryoffline: Designed to confuse
Unlike the packages standforusz and react-vuejs, it appeared to us that jqueryoffline was intended, at least in part, to achieve a supply chain compromise of an established application. Partially, that conclusion is derived from the choice of package name, which invokes jquery, a play on the name of a popular npm package, jquery, which is downloaded nearly 7 million times weekly.
Upon viewing the package contents, we also noted the presence of two files that were not present in packages used in the first phase of the attack: index.js and index.html. index.js is specified as the main inside the package.json file found within the jqueryoffline package.
Figure 8: Content of the main.js file containing malicious code bundled with webpack
A broad campaign
This same pattern was observed in the other npm packages identified in Phase 2 of this campaign: tetusdgsudgs, vueofflinez, and jquerydownloadnew.
Figure 9: Packages containing DEMO.txt found using ReversingLabs A1000
Given the similarities of each of these packages, it’s likely they were created by the same actor. Each of the above packages had a file - or multiple files - that somehow incorporated jquery.min.js or DEMO.txt from standforusz, version 1.0.3. Additionally, we observed that passwords collected by the forms spawned from those packages were sent to the same domain, which was included in the DEMO.txt file. Finally, in each case, the name of the maintainer account in each case was identical to the name of the package.
Is this IconBurst re-loaded?
As we noted above: the target of the Brainleeches supply chain attack wasn’t developers or development organizations so much as end users. In that sense, this new campaign recalls another malicious campaign that ReversingLabs discovered nearly a year ago and dubbed “IconBurst.”
In that incident, ReversingLabs’ researcher Karlo Zanki identified around two dozen packages on npm that were “designed to steal form data entered by end users of infected web applications or websites where the malicious packages had been deployed.” In that attack, the malicious packages we discovered were likely used by hundreds, if not thousands of downstream mobile and desktop applications as well as websites. The attack relied on typo-squatting, with attackers impersonating high-traffic npm modules like umbrellajs and packages published by ionic.io.
As with the current campaign, IconBurst was also leveraged to further phishing attacks. Specifically, the threat actor behind IconBurst promoted it as a phishing script for PUBG users. (PUBG is a massively multiplayer online game.)
So was the campaign we uncovered a reboot of IconBurst? There are similarities between the campaigns, including the deployment of information-stealing forms, the use of the .xyz top level domain with command and control infrastructure and similarly structured npm packages. However, there are differences as well. An analysis of IconBurst revealed evidence of a significant effort by threat actors to make the malicious npm packages resemble popular, legitimate packages. That included copying the look and feel of the targeted npm packages on “typosquatted” fake domains created to fool developers. Similarly, considerable effort was made by attackers in the IconBurst campaign to make the finished packages both functional and trustworthy to avoid attracting the attention of developers.
That was not the case with the latest campaign. Instead, many key elements of the new campaign suggest that the malicious modules identified in this campaign were either the byproducts of a large-scale email phishing campaign conducted by low-skill (or at least low effort) actors, or a hastily conducted supply chain attack that leveraged many elements of the phishing campaign. For example, consistent use of default file names like index.html and DEMO.TXT suggest that the attack may have originated in a standard phishing kit and was minimally altered before being launched, even when targeting end users.
As we have shown in prior research, malicious actors are turning to attacks on software supply chains to facilitate compromises of software makers and, by extension, their customers and end users. Historically, the vast majority of supply chain attacks have developers and development infrastructure in their cross hairs.
Campaigns like IconBurst, the July 2022 campaign discovered by ReversingLabs, show that open source modules and infrastructure can be leveraged for a variety of malicious ends. In that incident, malicious npm modules facilitated attacks on end users by inserting info-stealing forms into legitimate applications. That obviated the more common route of launching attacks directly on deployed applications or web sites and risking detection.
Operation Brainleeches, the latest campaign discovered by ReversingLabs, highlights a wrinkle in the already complex picture around software supply chains: the role open source platforms and modules play in supporting both targeted hacks and low skill, broad brush attacks like email based phishing campaigns.
Details of the attack suggest that the malicious packages and libraries that make up this campaign served multiple purposes: supporting automated email phishing attacks likely derived from a phishing kit, and facilitating more subtle attacks designed to fool developers into incorporating malicious npm modules into their applications.
How did this play out in real life? ReversingLabs researchers obtained malicious email attachments identical to the byproducts of this campaign in the wild, which gives credence to the idea that the malicious npm modules played a role in active phishing attacks, likely carried out by a low skill actor or actors.
The picture regarding supply chain attacks is less clear. As we noted: the malicious actors invoked the name of popular packages like jquery, and relied on obfuscation to hide the contents of files within the malicious packages. However, much of the supporting infrastructure for the campaign, including command and control servers, were taken down soon after this campaign was revealed, and before any application compromises were registered.
Regardless, this campaign further underscores the need for organizations to be on the lookout for signs that open source packages could be malicious or compromised. Often, these attacks hinge on developer inattention to small details in naming, but that’s not all. The use of obfuscated code is a major warning sign. So too: suspicious naming and package versioning, new packages with sketchy histories; smaller than expected downloads and dependencies and more.
When using packages from public repositories in their projects, developers should keep an eye peeled for these small, but telling details to avoid a malicious package being introduced as a dependency in some larger project. Development organizations also need to scrutinize the features and behaviors of the open source, third-party and commercial code they are relying on in order to track dependencies and detect potential malicious payloads in them. ReversingLabs technology, including our A1000 and Software Supply Chain Security platforms, deliver the visibility teams need to discover malware.
Indicators of Compromise (IOCs)
|Command & Control
|Command & Control