T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/cli.js:87
- Finding
- Immediate backup command silently forces a full backup of sensitive OpenClaw data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cli.js:87-95`, `scripts/backup.js:136-157`, `scripts/config.js:27-47` **Vulnerability Type**: Least-privilege violation and unsafe sensitive-data backup default **Risk Level**: High ### Vulnerable Code ```js // scripts/cli.js:87-95 async cmdBackupNow(args) { const output = []; output.push('🔄 开始执行备份...'); output.push(''); try { const options = { full: args.full !== false, targets: args.targets }; const result = await this.backupManager.execute(options); ``` ```js // scripts/backup.js:136-157 async prepareTargets(options) { const openclawRoot = OPENCLAW_ROOT; const targets = []; // 检查备份模式 if (this.config.backup.mode === 'full' || options.full) { // 全量备份 targets.push({ path: openclawRoot, name: '.openclaw', isRoot: true }); } else { // 选择性备份 const targetNames = options.targets || this.config.backup.targets || []; for (const name of targetNames) { const targetPath = path.join(openclawRoot, name); ``` ```js // scripts/config.js:27-47 backup: { mode: "partial", // ← 修改默认为选择性备份 targets: [], // ← 改为空数组,首次加载时动态检测 // 默认排除(仅临时文件) exclude: ["logs", "cache", "tmp", "node_modules"], excludePatterns: ["*.log", "*.tmp", ".DS_Store", "Thumbs.db"], // 敏感文件排除建议列表(默认不启用,仅建议) sensitiveExcludeSuggestion: [ "*.key", "*.pem", "*.p12", "*.pfx", ".env", ".env.local", ".env.*.local", "credentials.json", "secrets.json", "*.token", "*.secret", "*_key.json", "*_token.json", "id_rsa", "id_dsa", "*.ppk" ], sensitiveExcludeDirectories: [ "credentials", "secrets", ".ssh", ".gnupg" ], // 默认不启用敏感文件排除 enableSensitiveExclude: false }, ``` ### Technical Analysis The expression `args.full !== false` evaluates to `true` whenever the caller omits the `full` property. Consequently, an ordinary `/backup_now` invocation overrides the configured `partial` mode and enters the ful ...[truncated 1951 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace the implicit full-backup default with an explicit opt-in: ```js const options = { full: args.full === true, targets: args.targets }; ``` 2. When no override is supplied, honor `config.backup.mode`. 3. Require explicit user confirmation before a full backup. 4. Enable sensitive-file and sensitive-directory exclusions by default. 5. Present an itemized warning before archiving credential stores, tokens, environment files, or private keys. 6. Default to encrypted archives when sensitive content is included. 7. Add automated tests confirming that `/backup_now` with empty arguments uses selective mode. 8. Report the effective backup scope before starting compression so that the caller can verify it. ]]>
