Mystery of industry-targeting backdoored NPM JavaScript packages solved

Yup, 'the intern' did it

Malicious packages in the NPM Registry that security researchers for weeks believed were being used to stage supply-chain attacks against prominent industrial companies in Germany turned out to be part of a penetration test run by a cybersecurity company.

Researchers at Snyk in late April published a blog post about a JavaScript package that stood out among others they had found because it contained both encrypted and obfuscated files.

More recently, software maker JFrog and cybersecurity firm ReversingLabs this week released their own findings about the multiple malicious libraries in the NPM Registry that all used the same payload and belonged to the same malware family as the one analyzed by Snyk. The goal appeared to be to launch dependency-confusion attacks in which applications within German companies end up using, through a misconfiguration or something like that, malicious npm modules rather than legitimate packages with similar or plausible names. If successful, developers within specific corporations would be fooled into introducing backdoors into their code bases.

JFrog researchers in their blog post wrote that "compared with most malware found in the npm repository, this payload seems particularly dangerous: a highly-sophisticated, obfuscated piece of malware that acts as a backdoor and allows the attacker to take total control over the infected machine. Furthermore, this malware seems to be an in-house development and not based on publicly-available tools."

What none of the researchers could figure out was the identity of the maker of the malicious packages.

Owning up

However, soon after JFrog's blog post appeared, pen-testing and threat intelligence company Code White took responsibility for the malicious packages. In tweets directed at Snyk, the Ulm, Germany-based company said the suspected malicious actor was actually an intern assigned to research dependency-confusion attacks as part of its "continuous attack simulations for clients."

Code White wrote that "to clarify your questions: we're trying to mimic realistic threat actors for dedicated clients as part of our Security Intelligence Service and we brought our 'own' package manager that supports yarn and npm."

It's not unusual for security researchers to pull together their own packages for testing purposes. In its report, the Snyk threat hunters said they detected these npm packages as part of a larger effort to look into what they said has been a constant increase in the number of malicious dependencies showing up in disparate ecosystems and that the large majority of them are benign.

By that they mean the code is used to collect information but doesn't harm the infected machine. The researchers referred to these as "softly malicious" packages that have varied tasks, including machine-related information exfiltration through DNS lookups that don't perform any other actions, or cryptocurrencies miners that siphon compute power from compromised systems but not are terribly malicious.

Other dodgy modules are "other researchers' 'softly-malicious' packages that are mainly for tests," Team Snyk wrote.

'Not very normal'

However, Shachar Menashe, senior director of security research at JFrog, told The Register the way White Code ran their tests was "not very normal and it could have problematic implications."

The malicious packages created by Code White had a more significantly malicious vibe, according to an analysis of them. The JFrog analysts wrote that when researching the payload in the malicious packages, "we were surprised to discover that this attack seems to be highly targeted against a number of prominent companies based in Germany" and that they detected four maintainer profiles created to oversee the packages. They reported all the packages related to three of the maintainers as malware to the npm registry maintainers and noted that those related to the fourth had already been removed.

Menashe said it was unclear how Code White got hold of internal packages names from which to name the malicious copycats; we presume Code White was doing work for the identified German businesses.

"I don't know how it happened in this specific case and I also don't know for a fact that these are the 'correct' internal package names," he said.

"It could happen in many ways. For example, if your build logs are written to some publicly-available location, then these package names can be there. It's definitely a security concern if someone gets your internal package names, since that enables a dependency confusion attack in many scenarios."

Though the threat intelligence teams at JFrog, Snyk and ReversingLabs spent weeks analyzing the malicious practices, Menashe said pen-testing companies don't concern themselves too much with companies like the aforementioned trio.

"I worry about the client's PSIRT [product security incident response team] that might have caught this attack, not knowing what it is (because there is no way to distinguish this from a real attack) and scrambling like we did," he added. "I also worry about the possible scenario where this backdoor payload is hijacked by a real threat actor and used to cause real damage."

That said, even after digging into the malicious packages and before Code White's admission, the JFrog researchers were unsure exactly what they were looking at, though they said they had "some concrete leads."

There were details that suggested a sophisticated real threat actor was behind the malicious packages, such as the use of custom code, the attack being highly targeted and relying on "difficult to get" insider information, such the private package names. In addition, the payload was extremely capable, contained features like dynamic configuration parameters that aren't needed for a simple pen-test and lacked descriptions or indications that they were used for pen-tests.

However, there also were indicators that it was part of what they described as a "very aggressive" penetration test, including that the usernames created in the npm registry didn't try to hide the targeted company and the obfuscator used was a public one, which can be easily detected and reversed.

The incident involving Code White came the same week a security consultant, to alert the JavaScript community that the security of NPM Registry – bought by GitHub two years ago – needs more scrutiny, bought the expired email domain used by a maintainer of a widely used package. He said the move backs up an argument he had made for years that it is too easy to take over the NPM account of a popular project to run a software supply-chain attack.

ReversingLabs analysts wrote in a blog post they had been looking at exploitable flaws and misconfigurations on platforms like NPM and GitHub as potential fuel for a growth in dependency-confusion attacks, recognizing that most they saw have been proofs-of concept. What made what Snyk found in late April notable was that "dependency attacks moved from hypothetical to actual," they wrote. ®

Broader topics

Other stories you might like

  • Stolen university credentials up for sale by Russian crooks, FBI warns
    Forget dark-web souks, thousands of these are already being traded on public bazaars

    Russian crooks are selling network credentials and virtual private network access for a "multitude" of US universities and colleges on criminal marketplaces, according to the FBI.

    According to a warning issued on Thursday, these stolen credentials sell for thousands of dollars on both dark web and public internet forums, and could lead to subsequent cyberattacks against individual employees or the schools themselves.

    "The exposure of usernames and passwords can lead to brute force credential stuffing computer network attacks, whereby attackers attempt logins across various internet sites or exploit them for subsequent cyber attacks as criminal actors take advantage of users recycling the same credentials across multiple accounts, internet sites, and services," the Feds' alert [PDF] said.

    Continue reading
  • Big Tech loves talking up privacy – while trying to kill privacy legislation
    Study claims Amazon, Apple, Google, Meta, Microsoft work to derail data rules

    Amazon, Apple, Google, Meta, and Microsoft often support privacy in public statements, but behind the scenes they've been working through some common organizations to weaken or kill privacy legislation in US states.

    That's according to a report this week from news non-profit The Markup, which said the corporations hire lobbyists from the same few groups and law firms to defang or drown state privacy bills.

    The report examined 31 states when state legislatures were considering privacy legislation and identified 445 lobbyists and lobbying firms working on behalf of Amazon, Apple, Google, Meta, and Microsoft, along with industry groups like TechNet and the State Privacy and Security Coalition.

    Continue reading
  • SEC probes Musk for not properly disclosing Twitter stake
    Meanwhile, social network's board rejects resignation of one its directors

    America's financial watchdog is investigating whether Elon Musk adequately disclosed his purchase of Twitter shares last month, just as his bid to take over the social media company hangs in the balance. 

    A letter [PDF] from the SEC addressed to the tech billionaire said he "[did] not appear" to have filed the proper form detailing his 9.2 percent stake in Twitter "required 10 days from the date of acquisition," and asked him to provide more information. Musk's shares made him one of Twitter's largest shareholders. The letter is dated April 4, and was shared this week by the regulator.

    Musk quickly moved to try and buy the whole company outright in a deal initially worth over $44 billion. Musk sold a chunk of his shares in Tesla worth $8.4 billion and bagged another $7.14 billion from investors to help finance the $21 billion he promised to put forward for the deal. The remaining $25.5 billion bill was secured via debt financing by Morgan Stanley, Bank of America, Barclays, and others. But the takeover is not going smoothly.

    Continue reading

Biting the hand that feeds IT © 1998–2022