Gluestack NPM Supply Chain Attack: 960K Downloads Affected

by Anika Shah - Technology
0 comments

Recent NPM Supply chain Attack: Gluestack Packages Compromised

Table of Contents

A recent and concerning security incident has impacted the Node Package Manager (NPM) ecosystem. A sophisticated supply chain attack targeted 16 widely-used Gluestack ‘react-native-aria’ packages,collectively downloaded over 950,000 times each week. This breach introduced malicious code designed to function as a remote access trojan (RAT),possibly exposing developers and end-users to significant risk.

Timeline of the Compromise

Initial analysis, conducted by security researchers, indicates the attack began on June 6th, 2024, at 4:33 PM EST with the publication of a compromised version of the react-native-aria/focus package. Subsequently, threat actors systematically infiltrated 16 out of the 20 Gluestack react-native-aria packages available on NPM. Notably, malicious versions continued to be published as recently as two hours after the initial revelation, demonstrating an ongoing and active campaign.This rapid succession of compromised releases underscores the attacker’s efficiency and intent.

Identifying the Malicious Code

The compromise was first identified by the cybersecurity firm Aikido Security. Their investigation revealed obfuscated code injected into the lib/index.js file across the affected packages. This obfuscation is a common tactic used by attackers to evade detection by automated security tools.

The following packages were confirmed to be compromised, along with their affected versions and approximate weekly download numbers (as of June 7, 2024):

| Package name | Version | Weekly Downloads |
|————————–|———|——————|
| react-native-aria/button | 0.2.11 | 51,000 |
| react-native-aria/checkbox| 0.2.11 | 81,000 |
| react-native-aria/combobox| 0.2.10 | 51,000 |
| react-native-aria/disclosure| 0.2.9 | 3 |
| react-native-aria/focus | 0.2.10 | 100,000 |
| react-native-aria/interactions| 0.2.17 | 125,000 |
| react-native-aria/listbox| 0.2.10 | 51,000 |
| react-native-aria/menu | 0.2.16 | 22,000 |
| react-native-aria/overlays| 0.2.13 | 10,000 |
| react-native-aria/radio | 0.2.11 | 10,000 |
| react-native-aria/select | 0.2.10 | 51,000 |
| react-native-aria/segmented-control| 0.2.10 | 3 |
| react-native-aria/slider | 0.2.10 | 3 |
| react-native-aria/switch | 0.2.11 | 10,000 |
| react-native-aria/tabs | 0.2.10 | 51,000 |
| react-native-aria/toast | 0.2.10 | 3 |

Implications and Mitigation

this incident highlights the inherent risks associated with relying on third-party dependencies in software development. Similar to the 2022 Log4Shell vulnerability, which impacted countless applications, this attack demonstrates how a compromise within a widely-used component can have cascading effects

NPM Package Compromise: Gluestack-UI and React Native Aria Under Attack

A recent supply chain attack targeting popular Node Package Manager (NPM) packages has exposed a significant security risk to developers. Several packages within the Gluestack-UI and React Native aria ecosystems were compromised with malicious code, potentially impacting a vast number of applications. This incident underscores the growing threat of software supply chain attacks and the importance of robust security practices.

widespread Reach: Nearly One Million Weekly Downloads

The compromised packages, including react-native-aria/radio, react-native-aria/switch, react-native-aria/toggle, react-native-aria/utils, gluestack-ui/utils, and others (detailed in the table below), collectively receive approximately 960,000 weekly downloads. This substantial usage rate signifies that a successful exploitation of this vulnerability could have far-reaching consequences, affecting countless projects and end-users. According to data from Sonatype,supply chain attacks have increased by 742% between 2021 and 2022,demonstrating a clear upward trend in this type of malicious activity.

| Package Name | Version | Weekly Downloads |
|————————–|———|——————|
| react-native-aria/radio | 0.3.16 | 96,000 |
| react-native-aria/switch | 0.2.5 | 477 |
| react-native-aria/toggle | 0.2.12 | 81,000 |
| react-native-aria/utils | 0.2.13 | 120,000 |
| gluestack-ui/utils | 0.1.17 | 55,000 |
| react-native-aria/separator| 0.2.7 | 65 |
| react-native-aria/slider | 0.2.13 | 51,000 |
| react-native-aria/radio | 0.2.14 | 78,000 |

Stealthy Implementation and Obfuscation

The malicious code was cleverly concealed within the compromised packages. Attackers appended the code to the end of the index.js file, padding it with numerous spaces to evade immediate detection during visual inspection within the NPM website’s code viewer. This technique highlights the sophistication of the attackers and their intent to remain undetected for as long as possible. The obfuscation makes static analysis significantly more challenging, requiring specialized tools and expertise to identify the malicious intent.

!Malicious code added to end of index.js file
Malicious code added to end of index.js file

Connection to Previous Attacks: A Familiar Threat

security researchers at Aikido discovered the malicious code and noted its striking similarity to a Remote access Trojan (RAT) identified in a separate NPM compromise uncovered last month. Aikido’s earlier investigation detailed how this RAT establishes a connection with a command and control (C2) server, allowing attackers to remotely control the compromised system. This suggests a coordinated campaign or the reuse of existing malware infrastructure.Think of it like a burglar using the same set of lock picks on multiple houses – the pattern reveals a purposeful and organized effort.

Capabilities of the Remote Access Trojan

Once activated, the RAT grants attackers a range of potentially devastating capabilities.The malware can execute commands on the compromised machine, enabling actions such as:

Directory Navigation: cd – Allows attackers to move between directories on the infected system.
Directory Reset: ss_dir

Supply Chain Attack Targets Gluestack UI Library: Malicious Code Injected into NPM Packages

A recent security incident has revealed a supply chain attack impacting the popular Gluestack UI component library, distributed via the Node Package Manager (NPM).Multiple packages within the Gluestack ecosystem have been found to contain malicious code designed to compromise developer environments and potentially steal sensitive information. This incident underscores the growing risks associated with software supply chain vulnerabilities and the importance of robust security practices.

Details of the Compromise

security researchers at Aikido discovered that several Gluestack packages were injected with a sophisticated trojan. The malicious code operates by intercepting and modifying commands executed within a developer’s system. specifically, the trojan leverages the NPM package lifecycle scripts – the commands automatically run during installation and updates – to execute arbitrary shell commands.

The attack utilizes two primary mechanisms for code execution:

Pre-install Scripts: These scripts, designed to prepare the package for use, are exploited to download and execute a malicious payload.
Post-install Scripts: Following installation,these scripts are used to further establish persistence and execute additional malicious actions.

Crucially, the trojan also hijacks the Windows PATH habitat variable. By prepending a fraudulent Python path (%LOCALAPPDATA%ProgramsPythonPython3127) to the existing PATH, the malware ensures that its malicious binaries take precedence over legitimate Python or pip commands. This allows attackers to silently replace standard tools with compromised versions, enabling them to execute malicious code without raising immediate suspicion. This technique is akin to subtly altering road signs to redirect traffic to a hidden location.

Affected Packages and Scope

Currently identified compromised packages include those within the Gluestack UI project. Aikido researchers have linked this attack to a broader campaign,noting similarities to previous compromises affecting NPM packages such as biatec-avm-gas-station,cputil-node,lfwfinance/sdk,and lfwfinance/sdk-dev earlier in the week. This suggests a coordinated effort by a single threat actor or group.

As of June 7, 2024, NPM has been notified of the compromised packages, but the remediation process typically takes several days to complete. The potential impact is significant, as developers using these packages could unknowingly introduce the malware into their projects and, subsequently, their applications. according to data from NPM Stats,Gluestack UI boasts over 2.5 million weekly downloads, indicating a large potential attack surface.

Lack of Response and Mitigation Strategies

Despite attempts by Aikido researchers to alert Gluestack via GitHub issues filed on project repositories, no response has been received as of this publication. This lack of interaction raises concerns about the responsiveness of the maintainers and the speed of remediation.Developers who have recently installed or updated any Gluestack UI packages are strongly advised to take the following steps:

Review Package Dependencies: Carefully examine your project’s package.json file and identify all Gluestack UI packages. Audit for Suspicious Scripts: Inspect the scripts section of the package.json file for any unusual or unexpected commands.
Reinstall Packages: After verifying the integrity of your dependencies, reinstall the affected packages from a trusted source. Consider using a package lock file (e.g., package-lock.json or yarn.lock) to ensure consistent versions.
Implement Subresource integrity (SRI): Utilize SRI to verify the integrity of downloaded files, preventing the execution of compromised code.
* Employ Static Analysis Tools: Integrate static analysis tools into your development pipeline to automatically detect potential vulnerabilities and malicious code.

The Growing Threat of Software Supply Chain Attacks

This incident serves as a stark reminder of the escalating threat posed by software supply chain attacks. attackers are increasingly targeting open-source libraries and package managers to gain access to a wide range of downstream users. In 2023, the Cybersecurity and Infrastructure security Agency (CISA) reported a 650% increase in software supply chain attacks compared to the previous year.

Protecting against these attacks requires a multi-layered approach,including enhanced vulnerability management,improved dependency tracking,and increased collaboration between developers,package maintainers,and security researchers.

gluestack NPM Supply Chain Attack: What You Need to Know

The world of software advancement is built on efficiency and collaboration, often leveraging open-source packages managed through systems like NPM (Node Package Manager). However, this interconnectedness also creates vulnerabilities, as highlighted by the recent gluestack NPM supply chain attack. this incident, affecting approximately 960,000 downloads, served as a stark reminder of the potential risks within the open-source ecosystem and the critical need for robust security practices.

understanding the NPM Supply Chain Attack Vector

A supply chain attack targets vulnerabilities in the software development and delivery process. In the context of NPM, attackers compromise legitimate packages, inserting malicious code that can then infect the projects that depend on these packages. The Gluestack incident followed this pattern. Attackers, frequently enough through compromised credentials or vulnerabilities in package maintainer accounts, injected malicious Javascript code into legitimate Gluestack packages.

This malicious code,once executed,could perform a variety of harmful actions,including:

  • Data exfiltration: Stealing sensitive information such as API keys,credentials,and user data.
  • Backdoor creation: Establishing a hidden entry point into the affected system, allowing for persistent access and control.
  • Cryptocurrency mining: Using the compromised system’s resources to mine cryptocurrency without the owner’s consent.
  • Remote code execution: Allowing the attacker to execute arbitrary commands on the compromised system.

How the Gluestack Attack Unfolded

Specific details about the Gluestack attack are still emerging, but the general outline points to the common supply chain attack methodologies:

  1. compromised Account: Attackers likely gained access to the NPM account of a Gluestack package maintainer through phishing, credential stuffing, or other means.
  2. Malicious Code Injection: The attackers then modified the Gluestack packages, adding malicious JavaScript code masked within the existing code.
  3. Package Update: The compromised packages were published to the NPM registry, automatically updating in projects that depended on them.
  4. Infection and Propagation: As developers updated their projects or new projects were created using the compromised packages, the malicious code was executed, infecting their systems.

Identifying Affected Gluestack Packages

Identifying the specific Gluestack packages affected is crucial for remediation. While official advisories are the best source of accurate information, it’s crucial to be proactive. Pay close attention to security alerts from NPM, GitHub, and other security platforms. A security audit of your project’s dependencies is highly recommended.

Here’s an example of what an affected package list might look like (this is for illustrative purposes only,refer to official sources for accurate data):

Package Name affected Versions Vulnerability Type
@gluestack-ui/button v0.1.0 – v0.5.0 Data Exfiltration
@gluestack-ui/alert v0.2.0 – v0.3.5 Backdoor Creation
@gluestack-ui/select All versions prior to v0.6.0 Remote Code Execution

Mitigating the Risks: Protecting Your Projects from NPM Supply Chain Attacks

While the Gluestack attack is concerning, it presents an opportunity to strengthen our defenses against future supply chain threats.Here are several strategies to mitigate the risks:

  • Dependency Auditing: Regularly audit your project’s dependencies for known vulnerabilities using tools like npm audit or yarn audit. These tools identify vulnerable packages and suggest updated versions.
  • Semantic Versioning (SemVer) Awareness: Understand SemVer and its implications. Use version ranges cautiously. Locking down dependencies to specific versions or using narrow version ranges (e.g., "package": "1.2.3" instead of "package": "^1.2.0") provides more control over updates.
  • Software Composition Analysis (SCA): Implement SCA tools that provide deeper insights into your dependencies, including license compliance, security vulnerabilities, and transitive dependencies. These tools go beyond basic auditing and offer continuous monitoring.
  • Subresource Integrity (SRI): For packages delivered via CDNs, use SRI to ensure the integrity of the downloaded files. SRI allows you to verify that the files haven’t been tampered with.
  • NPM Two-Factor Authentication (2FA): Enable 2FA on your NPM account to protect against unauthorized access. This is a simple yet effective measure to prevent account compromise. Mandate 2FA for team members who publish packages.
  • Regularly Update Dependencies: Keep your dependencies up to date to patch known vulnerabilities. establish a regular update schedule and automate the process where possible. However, always test updates thoroughly in a staging environment before deploying to production.
  • Use a Package registry Proxy: Employ a private or proxy package registry. This gives you more control over the packages used in your projects. Packages can be scanned for vulnerabilities before being made available.
  • Monitor Security Advisories: Stay informed about security advisories from NPM, GitHub, and other security sources.Subscribe to relevant security mailing lists and follow security researchers.
  • Limit Permissions: Follow the principle of least privilege. Grant users and build systems only the necessary permissions to perform their tasks. Avoid using broad wildcard permissions.
  • Secure Development Practices: Implement secure coding practices to prevent vulnerabilities in your own code, which could be exploited through dependency confusion attacks.
  • Verify Package Integrity: Consider using tools that verify the integrity and authenticity of downloaded packages. inspect install scripts before running them.

Practical Tips and Best Practices

Here are some concrete steps you can take to improve your security posture today:

  • Run `npm audit` or `yarn audit` frequently: Integrate these commands into your CI/CD pipeline to automatically check for vulnerabilities.
  • Implement a Dependency Management Policy: Define clear guidelines for choosing, updating, and managing dependencies in your projects.
  • Automate Dependency Updates: Use tools like Dependabot or Renovate to automate dependency updates and track changes.
  • Educate Your Team: Provide training to your development team on secure coding practices and supply chain security.
  • Review Contribution Guidelines: If maintaining public npm packages, implement stringent review policies for contributions by third party developers.

NPM and the Future of Supply Chain Security

The Gluestack attack underscores the importance of ongoing efforts to improve supply chain security within the NPM ecosystem. NPM and the broader JavaScript community are actively working on initiatives to enhance security, including:

  • Enhanced Security Audits: Improving the accuracy and coverage of security audits.
  • Package Signing: Implementing package signing to verify the authenticity of packages.
  • Policy Enforcement: Developing policies to prevent the publication of malicious packages.
  • community Collaboration: Fostering collaboration between security researchers, package maintainers, and the NPM team to identify and address vulnerabilities.

Case Study: Preventing a similar Attack

Let’s consider a hypothetical scenario where a development team, “CodeCrafters Inc.”, proactively implemented several of the mitigation strategies outlined above. CodeCrafters Inc. uses React and a variety of NPM packages to build their e-commerce platform.

Here’s how they avoided a potential supply chain attack:

  1. Regular audits: CodeCrafters integrated `npm audit` into their CI/CD pipeline. Whenever they pushed a new commit, the pipeline automatically ran the audit and flagged any vulnerabilities.
  2. SCA tooling: They invested in an SCA tool that provided deeper analysis of their dependencies,including transitive dependencies. The tool identified a vulnerable transitive dependency in one of their UI component libraries.
  3. Version Pinning: They used narrow version ranges in their `package.json` file, pinning dependencies to specific versions to avoid unintended updates.
  4. monitoring and Alerts: They subscribed to security advisories from NPM and used the SCA tool to monitor their dependencies for new vulnerabilities. When a new vulnerability was announced for a widely used utility library, they received an immediate alert.
  5. rapid Response: Upon receiving the alert, they immediately updated the vulnerable library to the patched version and thoroughly tested the changes in a staging environment before deploying to production.

By implementing these proactive measures, CodeCrafters Inc. successfully avoided falling victim to a hypothetical supply chain attack and maintained the security of their e-commerce platform.

First-hand Experience: tightening Security After a Scare

Mark, a senior developer at a fintech startup, recounted a recent experience that highlighted the importance of NPM supply chain security. “We had a close call a few months ago. Our automated vulnerability scanning tool flagged a critical vulnerability in a seemingly innocuous utility package we were using. At first, we dismissed it, thinking it was a false positive. But upon closer inspection, we discovered that the package maintainer’s account had likely been compromised, and malicious code had been injected.”

“The experience was a wake-up call. We immediately revamped our dependency management policies.We implemented stricter version control, started using a private NPM registry proxy, and mandated 2FA for all developers with publishing rights. We also invested in training our team on secure coding practices and supply chain security risks. It was a lot of work, but we’re much more confident in our security posture now. We treat every dependency as a potential threat and take a zero-trust approach.”

Conclusion: The Ongoing Battle for Secure Software

The gluestack NPM supply chain attack serves as a potent reminder that security is a continuous process, not a one-time fix. By understanding the risks, implementing robust mitigation strategies, and staying informed about the latest threats, we can collectively improve the security of the software supply chain and protect our projects from falling victim to these types of attacks.

Related Posts

Leave a Comment