JetBrains IDE detected a trojan in the chalk package: what measures should be taken?
- Should I scan the entire system? What tools should I use and what are the chances of detecting potentially installed malicious programs?
- Should I reinstall Windows? What should I do if other drives are also infected?
- Is the criticism of using operating system functions in this case justified?
JetBrains IDE Detected a Trojan in Chalk Package - Major npm Supply Chain Attack
JetBrains IDE detected a trojan in the chalk package - this is the result of a major attack on the npm supply chain, affecting 18 popular packages with a total of approximately 2 billion weekly downloads. It is necessary to immediately remove malicious package versions and check the system for additional threats, but a complete Windows reinstall will likely not be required. Using operating system functions in this case is standard security practice when detecting malicious code.
Table of Contents
- What happened and which packages are affected
- Do you need to scan the entire system
- Should you reinstall Windows
- Justification for using OS functions
- Steps to eliminate the threat
- Long-term security measures
What happened and which packages are affected
On September 8, 2025, a large-scale attack on the npm supply chain occurred, as a result of which attackers gained control over developer accounts and published malicious versions of popular packages. According to Aikido Security, the attack began at 13:16 UTC and affected 18 widely used JavaScript libraries.
The most affected packages include:
- chalk (~300 million weekly downloads) - for terminal string styling
- debug - one of the most popular packages for debugging
- supports-color - for determining terminal color support
- ansi-styles - for ANSI code styling
- strip-ansi - for removing ANSI codes from strings
- ansi-regex - for regular expressions of ANSI escape sequences
As noted by Sonatype, attackers successfully compromised an npm developer account, which allowed them to publish malicious package versions. Many of the malicious packages were removed from npm less than an hour after discovery.
Important: The malicious code was in specific package versions (for example, in chalk version 5.6.1), so not all versions you installed were affected.
Do you need to scan the entire system
Yes, scanning the entire system is recommended, but with some important caveats. The likelihood of detecting malicious software depends on how exactly the infected package was used.
What malicious code was in the chalk package?
According to GitHub research, the malicious code was on line 11 of the src/index.js file in the chalk package. This code could perform various actions depending on the implementation, but it was mainly aimed at:
- Data theft
- Installation of additional malware
- Modification of system files
System scanning tools
The following tools are recommended:
-
Antivirus programs:
- Kaspersky Total Security (check the official Kaspersky blog)
- ESET NOD32
- Dr.Web
- Microsoft Defender
-
Specialized utilities for finding malware:
- Malwarebytes
- AdwCleaner
- HitmanPro
-
Package manager checks:
bashnpm audit fix yarn audit pnpm audit
Chances of detecting the threat
The chances of detecting potentially installed malicious software depend on:
- Time of infected package installation - the earlier you installed it, the higher the risk
- Package functions used - if you simply imported chalk for output styling, the risk is minimal
- Additional actions - if the package executed system commands, the likelihood of detection increases
Important: Semgrep notes that many malicious packages were quickly removed from npm, but this doesn’t rule out the possibility of them being installed in your projects before removal.
Should you reinstall Windows
A complete Windows reinstall in this case is likely not required, but the decision depends on the specific situation.
When a reinstall might be necessary:
- If the malicious code gained administrator privileges and modified system files
- If you used the infected package in system scripts or services
- If antivirus scanning detected rootkits or complex malware
What to do if other drives are also infected:
- Scan all drives using antivirus software
- Use bootable antivirus disks to scan outside the operating system
- Create backups of important data before removing malware
- Format drives only as a last resort if removal doesn’t help
Alternative reinstall options:
- System restore to a point before the infected package was installed
- Creating a new clean system and transferring data with verification
- Using Windows Sandbox to test potentially infected applications
As noted by Vercel, most users can get by without reinstalling the system if they promptly remove malicious packages and perform scanning.
Justification for using OS functions
Criticism of using operating system functions in this case is not fully justified, as this is standard security practice.
Why IDEs use system functions:
- Threat detection - modern IDEs, including JetBrains, integrate with system security tools to identify potentially dangerous code
- Developer protection - warnings help avoid accidental execution of malicious code
- Dependency analysis - IDEs check package security through vulnerability databases
What is criticized:
- False positives - sometimes IDEs may warn about harmless code
- Excessive warnings - constant notifications can interfere with work
- Insufficient contextual information - warnings may be too general
The real situation:
According to The Hacker News, the attack on chalk and debug packages is catastrophic for the software supply chain, and such warnings from IDEs are a necessary security measure.
Expert opinion: As noted by Ilkka Turunen of Sonatype, “what we’re seeing with npm packages chalk and debug is unfortunately common today in the software supply chain”.
Steps to eliminate the threat
Immediate actions:
-
Check installed package versions:
bashnpm list chalk npm list debug npm list supports-color
-
Remove malicious versions:
bashnpm uninstall chalk@5.6.1 npm uninstall debug@4.3.7
-
Update packages to safe versions:
bashnpm update chalk npm update debug
-
Run a dependency audit:
bashnpm audit fix
Additional security measures:
- Check all projects for infected dependencies
- Use dependency analysis tools like
npm outdatedandnpm outdated --depth=0 - Set up automatic updates via
npm update --save - Use lock files (
package-lock.json,yarn.lock) to lock versions
Preventive measures:
- Regularly update dependencies
- Use security analysis tools like Snyk or Dependabot
- Limit package access rights through
package.json - Check package repositories before installation
Long-term security measures
Strengthening the supply chain:
-
Use vulnerability monitoring tools:
- GitHub Dependabot
- Snyk
- Mend.io
-
Set up CI/CD pipelines for automatic security checking
-
Limit the use of external packages to only what’s necessary
Education and awareness:
- Follow security news in the npm ecosystem
- Train your development team to recognize phishing attacks
- Use secure coding practices
Technical solutions:
- Use private npm registries for internal packages
- Set up package signing and verification
- Use containerization to isolate dependencies
As emphasized by Wiz Security, such attacks are becoming increasingly common, and proactive security measures are becoming necessary for modern software development.
Sources
- Aikido Security - npm debug and chalk packages compromised
- Semgrep Security Alert - chalk, debug and color on npm compromised
- Wiz Blog - Widespread npm Supply Chain Attack
- CodeAnt AI - NPM Supply-Chain Alert
- The Hacker News - 20 Popular npm Packages Compromised
- Sonatype Blog - npm Chalk and Debug Packages Hit
- Kaspersky Blog - Popular npm packages compromised
- Vercel Blog - Critical npm supply chain attack response
- GitHub Chalk Issue - Version 5.6.1 published to npm is compromised
- Hacker News - NPM debug and chalk packages compromised
Conclusion
Detection of a trojan in the chalk package requires immediate but measured actions. It is necessary to remove malicious package versions, scan the system with antivirus software, but a Windows reinstall is only required in extreme cases. Warnings from JetBrains IDE are a justified security measure in the face of growing attacks on the software supply chain. To prevent similar incidents in the future, it is recommended to use vulnerability monitoring tools, regularly update dependencies, and train developers in safe practices for working with external packages.