OpenClaw Arbitrary Code Execution via Malicious .npmrc File
OpenClaw before 2026.3.24 is vulnerable to arbitrary code execution via local plugin and hook installation, where an attacker can craft a .npmrc file with a git executable override to execute malicious code during npm install.
OpenClaw versions before 2026.3.24 are susceptible to arbitrary code execution. The vulnerability lies in the local plugin and hook installation process. An attacker can exploit this by crafting a malicious .npmrc file that overrides the git executable. During the npm install execution within the staged package directory, the system inadvertently triggers the attacker’s specified programs. This happens because npm leverages git dependencies, and the overridden git path points to a malicious executable. This can allow complete system compromise, depending on the permissions of the user running the npm install command. This vulnerability was reported on April 10, 2026.
Attack Chain
- Attacker identifies a target system running a vulnerable version of OpenClaw (prior to 2026.3.24).
- Attacker crafts a malicious
.npmrcfile. This file contains a configuration that overrides thegitexecutable path to point to a malicious binary under attacker control. For example,git=path/to/malicious/executable. - The attacker places the crafted
.npmrcfile in a location where thenpmcommand will recognize it (e.g., the project directory, user’s home directory, or a global configuration directory). - The attacker triggers an
npm installcommand execution within a project that processes plugins or hooks. - During the
npm installprocess,npmattempts to resolve git dependencies. - Due to the
.npmrcconfiguration,npmexecutes the attacker-controlled “git” executable specified in the .npmrc file instead of the legitimate git binary. - The attacker-controlled executable executes arbitrary code on the system.
- The attacker achieves arbitrary code execution, potentially leading to system compromise, data exfiltration, or other malicious activities.
Impact
Successful exploitation of this vulnerability allows attackers to execute arbitrary code with the privileges of the user running the npm install command. This can lead to complete system compromise, sensitive data leakage, or denial-of-service. While the specific number of victims is unknown, any system running a vulnerable version of OpenClaw is at risk. Sectors most likely to be impacted are those relying on OpenClaw for plugin and hook management.
Recommendation
- Upgrade OpenClaw to version 2026.3.24 or later to patch the vulnerability (CVE-2026-35641).
- Implement file integrity monitoring on
.npmrcfiles to detect unauthorized modifications (file_event log source). - Monitor process executions where
npmspawns child processes from unusual or unexpected paths, especially those outside standard installation directories (process_creation log source). Use the Sigma rule provided below to detect this behavior.
Detection coverage 2
Detect npm spawning git from unusual locations via npmrc
highDetects npm executing 'git' (or a renamed copy) from unexpected paths, which may indicate exploitation of CVE-2026-35641 via a malicious .npmrc file.
Detect .npmrc Modification
mediumDetects modification to .npmrc files, which could indicate an attempt to inject malicious configurations.
Detection queries are kept inside the platform. Get full rules →
Indicators of compromise
1
| Type | Value |
|---|---|
| [email protected] |