T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/scrub.py:66
- Finding
- Unredacted Secrets Persist in Plaintext Backup Files## Vulnerability Details **File Location**: `scripts/scrub.py`, lines 66-69 **Vulnerability Type**: Plaintext retention of sensitive data **Risk Level**: High ### Vulnerable Code ```python # Create backup shutil.copy2(path, path + ".bak") with open(path, 'w', encoding='utf-8') as f: f.write(new_content) ``` The script copies each original file to a `.bak` file before writing the redacted version. Because the backup is created from the original content, it retains every API key, password, token, or other secret that the scrubber detected. Files ending in `.bak` are explicitly excluded from subsequent scans at line 48: ```python if f.endswith('.bak'): continue ``` Consequently, the sensitive backup is neither redacted nor reported during future executions. This conflicts with the stated security objective of preventing secrets from remaining in plaintext memory and log files. ### Attack Path 1. A target file under `memory`, `logs`, or `MEMORY.md` contains a credential matching one of the configured patterns. 2. A user runs the scrubber without `--dry-run`. 3. The script copies the complete original file, including its credentials, to `<filename>.bak`. 4. The original file is overwritten with its redacted version. 5. Future scans skip the `.bak` file. 6. A local user, malicious process, backup service, synchronization process, or later workspace export accesses the backup and recovers the original credential. ### Impact Assessment Successfully detected credentials remain recoverable in plaintext. Anyone who can read the workspace or its archived copies may obtain API keys, tokens, passwords, and other sensitive information. The affected scope includes every modified file beneath `/root/.openclaw/workspace/memory`, `/root/.openclaw/workspace/logs`, and the workspace `MEMORY.md` file. The vulnerability does not itself grant new operating-system privileges, but exposed credentials may grant access to e ...[truncated 95 chars]
- Remediation
- ## Remediation Suggestions - Do not create unredacted backups by default. - Make backup creation an explicit opt-in operation with a clear warning that backups may contain secrets. - If recovery copies are required, encrypt them using a key stored outside the workspace. - Store backups outside directories that may be synchronized, indexed, exported, or processed as logs. - Apply restrictive permissions, such as owner-only read and write access, when creating backup files. - Establish and enforce a short retention period followed by secure deletion. - Detect existing `.bak` files and warn users that they may contain unredacted credentials. - Prefer an atomic replacement strategy using a securely created temporary file containing only redacted content.
