T06 · System Persistence
- Location
- package.json:12
- Finding
- <![CDATA[Automatic Persistent Registration of OpenClaw Plugins During Package Installation]]><![CDATA[ ## Vulnerability Details **File Location**: `package.json:12`; `plugins/security-input-validator-plugin/install.ts:11-13, 41-60`; `plugins/security-tool-validator-plugin/install.ts:11-13, 41-60` **Vulnerability Type**: Persistent user-level Agent configuration modification **Risk Level**: Critical ### Vulnerable Code `package.json:12`: ```json "postinstall": "npm run build && tsx plugins/security-input-validator-plugin/install.ts && tsx plugins/security-tool-validator-plugin/install.ts" ``` Both plugin installers contain the following registration logic: ```ts const homedir = process.env.HOME || os.homedir(); const OPENCLAW_DIR = path.join(homedir, ".openclaw"); const OPENCLAW_CONFIG_PATH = path.join(OPENCLAW_DIR, "openclaw.json"); ``` ```ts if (!paths.includes(PLUGIN_DIR)) { paths.push(PLUGIN_DIR); } entries[PLUGIN_ID] = { enabled: true }; config.plugins = { ...plugins, enabled: plugins.enabled !== undefined ? plugins.enabled : true, load: { ...load, paths }, entries, }; if (!fs.existsSync(OPENCLAW_DIR)) { fs.mkdirSync(OPENCLAW_DIR, { recursive: true }); } fs.writeFileSync( OPENCLAW_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8" ); ``` ### Technical Analysis A normal dependency installation automatically runs the npm `postinstall` lifecycle script. That script executes both plugin installers, which edit the user-level `~/.openclaw/openclaw.json` configuration and enable package-controlled plugins. The modification is persistent: subsequent OpenClaw sessions can load the registered plugins even when the user does not invoke the `openclaw-sec` CLI. Although the Skill documentation mentions automatic hooks, installation does not require separate affirmative consent for modifying the user’s OpenClaw configuration. The installers also do not create a configuration backup or provide restoration logic. This behavior exceeds what is necessary for a standalone validation CLI. Persistent plugin integration may be a legitimat ...[truncated 1294 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all OpenClaw configuration modification from `postinstall`. 2. Make persistent plugin integration an explicit opt-in operation, such as: ```bash openclaw-sec install-plugins ``` 3. Before modification, display the exact target file, plugin paths, and behavioral effects. 4. Require explicit user confirmation unless a documented noninteractive flag is supplied. 5. Back up `~/.openclaw/openclaw.json` before writing it. 6. Use atomic file replacement and preserve existing permissions. 7. Add an uninstall command that removes only paths and entries created by this package. 8. Keep CLI installation and persistent Agent integration as separate installation choices. 9. Document how users can inspect, disable, and completely remove the hooks. 10. Avoid executing TypeScript plugin installers automatically through package lifecycle scripts. ]]>
