T09 · Insecure Skill Coding Practices
- Location
scripts/scrub.py:66- Finding
Unredacted Secrets Persist in Plaintext Backup Files
- Content
View full analysis
Vulnerability Details
File Location:
scripts/scrub.py, lines 66-69
Vulnerability Type: Plaintext retention of sensitive data
Risk Level: HighVulnerable 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
.bakfile 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
.bakare explicitly excluded from subsequent scans at line 48:python if f.endswith('.bak'): continueConsequently, 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
- A target file under
memory,logs, orMEMORY.mdcontains a credential matching one of the configured patterns. - A user runs the scrubber without
--dry-run. - The script copies the complete original file, including its credentials, to
<filename>.bak. - The original file is overwritten with its redacted version.
- Future scans skip the
.bakfile. - 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 workspaceMEMORY.mdfile.The vulnerability does not itself grant new operating-system privileges, but exposed credentials may grant access to e ...[truncated 95 chars]
- A target file under
- Remediation
View 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
.bakfiles and warn users that they may contain unredacted credentials. - Prefer an atomic replacement strategy using a securely created temporary file containing only redacted content.
