This article is more than 1 year old

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

More about

TIP US OFF

Send us news


Other stories you might like