{"id":54280,"date":"2025-09-09T03:30:31","date_gmt":"2025-09-09T07:30:31","guid":{"rendered":"https:\/\/www.kaspersky.com\/blog\/?p=54280"},"modified":"2025-09-10T04:24:07","modified_gmt":"2025-09-10T08:24:07","slug":"npm-packages-trojanized","status":"publish","type":"post","link":"https:\/\/www.kaspersky.com\/blog\/npm-packages-trojanized\/54280\/","title":{"rendered":"Popular npm packages compromised"},"content":{"rendered":"<p>Several popular npm packages used in a number of web projects <a href=\"https:\/\/www.bleepingcomputer.com\/news\/security\/hackers-hijack-npm-packages-with-2-billion-weekly-downloads-in-supply-chain-attack\/\" target=\"_blank\" rel=\"nofollow noopener\">have been compromised and trojanized<\/a> by unknown attackers. The attackers, through a phishing attack on maintainers, were able to gain access to at least one repository and injected the packages with malicious code used to hunt for cryptocurrency. Thus, all web applications that used trojanized versions of the packages were turned into cryptodrainers. And there can be quite a few of them \u2014 as the compromised packages had more than two billion downloads per day (<a href=\"https:\/\/www.aikido.dev\/blog\/npm-debug-and-chalk-packages-compromised\" target=\"_blank\" rel=\"nofollow noopener\">according to Aikido Security<\/a>).<\/p>\n<h2>What are the dangers of the trojanized packages used in this attack?<\/h2>\n<p>Obfuscated JavaScript was added to all affected packages. If the compromised package is used in a web application, the malicious code is activated on the devices that were used to access this application. Acting at the browser level, malware intercepts network traffic and API requests, and changes data associated with Ethereum, Bitcoin, Solana, Litecoin, Bitcoin Cash, and Tron cryptocurrency wallets. The malware spoofs their addresses and redirects transactions to the attackers\u2019 wallets.<\/p>\n<p>About three hours after the attack began, the npm administration started to remove the infected packages, but it\u2019s not known exactly how many times they were downloaded during this time.<\/p>\n<h2>How the attackers managed to gain access to the repositories<\/h2>\n<p>The attackers used a rather banal technique \u2014 they created a phishing email in which maintainers were urged to update their two-factor authentication credentials at the first opportunity. Otherwise, they were threatened with account lockout starting September 10, 2025. The emails were sent from a mailbox on the domain <em>npmjs[.]help<\/em>, similar to the legitimate <em>npmjs.com<\/em>. The same domain also hosted a phishing site that mimicked the official npm registry page. Credentials entered on this site immediately fell into the hands of the attackers.<\/p>\n<p>The attack was successful against at least <a href=\"https:\/\/bsky.app\/profile\/bad-at-computer.bsky.social\/post\/3lydioq5swk2y\" target=\"_blank\" rel=\"nofollow noopener\">one maintainer<\/a>, compromising the npm packages color, debug, ansi-regex, chalk, and several others. However, the phishing attack appears to have been more extensive, because other maintainers and developers received similar phishing emails, so the full list of trojanized packages may be longer.<\/p>\n<div style=\"background-color: #e5f0ec; padding: 10px 25px; margin-bottom: 10px;\"><br>\n<strong>Leonid Bezververenko, Senior Security Researcher with the Global Research &amp; Analysis Team (GReAT) comments:<\/strong>\n<p>The attack on npm packages with billions of downloads per week clearly demonstrates the vulnerability of supply chains in the open-source ecosystem. While the malicious payload in this case was limited \u2014 the attackers only managed to steal tens of dollars \u2014 the situation could have been much more serious.<\/p>\n<p>Infected packages could have been used to compromise corporate servers, introduce backdoors into business process management systems, or steal sensitive data from customers and partners. In such a scenario, we could have seen a large-scale compromise similar to the XZ attack: companies that integrated malicious libraries into internal services or SaaS products could have passed the infection on to hundreds or thousands of corporate customers.<\/p>\n<p>As with XZ case, the key factor of this incident was not a technical vulnerability, but the human factor \u2014 a developer of popular npm packages fell victim to a phishing email. Experience shows that maintainers of widely used open-source software remain an attractive target for attackers, because compromising one project can jeopardize thousands of other systems.<\/p>\n<p>This \u201cdomino effect\u201d can turn a single mistake or instance of carelessness into an industry-wide problem.<br>\n<\/p><\/div>\n<h2>Which packages were compromised?<\/h2>\n<p>At the time of writing this post, the following packages are known to be compromised:<\/p>\n<ul>\n<li>ansi-regex<\/li>\n<li>ansi-styles<\/li>\n<li>backslash<\/li>\n<li>chalk<\/li>\n<li>chalk-template<\/li>\n<li>color-convert<\/li>\n<li>color-name<\/li>\n<li>color-string<\/li>\n<li>debug<\/li>\n<li>error-ex<\/li>\n<li>has-ansi<\/li>\n<li>is-arrayish<\/li>\n<li>simple-swizzle<\/li>\n<li>slice-ansi<\/li>\n<li>strip-ansi<\/li>\n<li>supports-color<\/li>\n<li>supports-hyperlinks<\/li>\n<li>wrap-ansi<\/li>\n<\/ul>\n<p>However, as we have already written above, the list may grow. You can keep an eye on the <a href=\"https:\/\/github.com\/advisories?page=1&amp;query=type%3Amalware\" target=\"_blank\" rel=\"nofollow noopener\">GitHub<\/a> advisory page for updates.<\/p>\n<h2>How to stay safe<\/h2>\n<p>Kaspersky products, including <a href=\"https:\/\/www.kaspersky.com\/next?icid=gl_kdailyplacehold_acq_ona_smm__onl_b2b_kdaily_wpplaceholder_sm-team___knext____a8c0f733e524af27\" target=\"_blank\" rel=\"noopener nofollow\">Kaspersky NEXT<\/a>, detect this threat with the verdicts <em>Trojan-Banker.Script.Osthereum<\/em> with various prefixes <em>(HEUR, UDS, VHO)<\/em> and modifications, such as <em>HEUR:Trojan-Banker.Script.Osthereum.gen<\/em>, and as <em>Trojan.JS.Agent.exf<\/em> with various prefixes.<\/p>\n<p>You can search for them using masks:<\/p>\n<ul>\n<li><em>*Trojan-Banker.Script.Osthereum*<\/em><\/li>\n<li><em>*Trojan.JS.Agent.exf*<\/em><\/li>\n<\/ul>\n<p>The phishing domain <em>npmjs[.]help<\/em>, which was used to hijack the maintainer accounts, is also detected by our products. In particular, all requests to this domain are detected by our network security solutions such as <a href=\"https:\/\/www.kaspersky.com\/enterprise-security\/anti-targeted-attack-platform?icid=gl_kdailyplacehold_acq_ona_smm__onl_b2b_kasperskydaily_wpplaceholder____kata___\" target=\"_blank\" rel=\"noopener nofollow\">Kaspersky Anti Targeted Attack Platform<\/a>.<\/p>\n<p>Information about malicious packages has also been added to the <a href=\"https:\/\/www.kaspersky.com\/open-source-feed?icid=gl_kdailyplacehold_acq_ona_smm__onl_b2b_kasperskydaily_wpplaceholder____\" target=\"_blank\" rel=\"noopener nofollow\">Open-Source Software Threats Data Feed<\/a> (and we continue to add new data as new malicious packages are discovered). Also, our analysts report the detection of infected packages to clients of the <a href=\"https:\/\/www.kaspersky.com\/enterprise-security\/managed-detection-and-response?icid=gl_kdailyplacehold_acq_ona_smm__onl_b2b_kasperskydaily_wpplaceholder____\" target=\"_blank\" rel=\"noopener nofollow\">Kaspersky Managed Detection and Response<\/a> service. <\/p>\n<p>Developers are advised to audit the dependencies in their projects, and if one of the compromised packages was used there, pin the safe version using the overrides function in <em>package.json<\/em>. You can find more detailed instructions <a href=\"https:\/\/jdstaerk.substack.com\/p\/we-just-found-malicious-code-in-the\" target=\"_blank\" rel=\"nofollow noopener\">here<\/a>.<\/p>\n<p>Maintainers and developers with access to open source software repositories are advised to be doubly careful when receiving emails urging them to log into their accounts. Better yet \u2014 also use <a href=\"https:\/\/www.kaspersky.com\/next?icid=gl_kdailyplacehold_acq_ona_smm__onl_b2b_kdaily_wpplaceholder_sm-team___knext____a8c0f733e524af27\" target=\"_blank\" rel=\"noopener nofollow\">security solutions<\/a> with an anti-phishing engine.<\/p>\n<input type=\"hidden\" class=\"category_for_banner\" value=\"kaspersky-next\">\n","protected":false},"excerpt":{"rendered":"<p>Unknown attackers have compromised several popular npm packages in a supply-chain attack. <\/p>\n","protected":false},"author":2698,"featured_media":54281,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1999,3051,3052],"tags":[36,4361,2893],"class_list":{"0":"post-54280","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-business","8":"category-enterprise","9":"category-smb","10":"tag-malware-2","11":"tag-npm","12":"tag-supply-chain-attack"},"hreflang":[{"hreflang":"x-default","url":"https:\/\/www.kaspersky.com\/blog\/npm-packages-trojanized\/54280\/"},{"hreflang":"en-in","url":"https:\/\/www.kaspersky.co.in\/blog\/npm-packages-trojanized\/29528\/"},{"hreflang":"en-ae","url":"https:\/\/me-en.kaspersky.com\/blog\/npm-packages-trojanized\/24633\/"},{"hreflang":"en-gb","url":"https:\/\/www.kaspersky.co.uk\/blog\/npm-packages-trojanized\/29460\/"},{"hreflang":"ru","url":"https:\/\/www.kaspersky.ru\/blog\/npm-packages-trojanized\/40446\/"},{"hreflang":"ru-kz","url":"https:\/\/blog.kaspersky.kz\/npm-packages-trojanized\/29642\/"},{"hreflang":"en-au","url":"https:\/\/www.kaspersky.com.au\/blog\/npm-packages-trojanized\/35388\/"},{"hreflang":"en-za","url":"https:\/\/www.kaspersky.co.za\/blog\/npm-packages-trojanized\/35016\/"}],"acf":[],"banners":"","maintag":{"url":"https:\/\/www.kaspersky.com\/blog\/tag\/supply-chain-attack\/","name":"supply-chain attack"},"_links":{"self":[{"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts\/54280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/users\/2698"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/comments?post=54280"}],"version-history":[{"count":8,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts\/54280\/revisions"}],"predecessor-version":[{"id":54300,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts\/54280\/revisions\/54300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/media\/54281"}],"wp:attachment":[{"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/media?parent=54280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/categories?post=54280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaspersky.com\/blog\/wp-json\/wp\/v2\/tags?post=54280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}