T09 · Insecure Skill Coding Practices
- Location
scripts/sync_workspace.py:120- Finding
Automatic synchronization may expose workspace secrets to a Git remote
- Content
View full analysis
Vulnerability Details
File Location:
scripts/sync_workspace.py, lines 120-124, 184-206, and 250-276
Vulnerability Type: Sensitive data exposure through allow-by-default synchronization
Risk Level: HighVulnerable Code
python SOURCE_DIR = Path.home() / ".openclaw" / "workspace" TARGET_DIR = Path(target_repo_path).expanduser().resolve() DEFAULT_EXCLUDES = {"skills", ".git", "__pycache__", ".DS_Store", "node_modules", ".clawhub"} if exclude_patterns: DEFAULT_EXCLUDES.update(exclude_patterns)python for item in SOURCE_DIR.iterdir(): # Check exclusion list if item.name in DEFAULT_EXCLUDES: skipped_items.append(item.name) continue dest = TARGET_DIR / item.name try: if item.is_file(): shutil.copy2(item, dest) copied_count += 1 print(f"📄 {item.name}") elif item.is_dir(): # Copy directory and apply exclusion rules def ignore_func(dir, contents): return [c for c in contents if c in DEFAULT_EXCLUDES] shutil.copytree(item, dest, ignore=ignore_func) copied_count += 1 print(f"📁 {item.name}/") except Exception as e: print(f"⚠️ Copy failed {item.name}: {e}")python # git add subprocess.run(["git", "add", "-A"], check=True, capture_output=True) # git commit commit_result = subprocess.run( ["git", "commit", "-m", commit_msg], capture_output=True, text=True, check=True ) # Extract commit hash commit_hash = "" match = re.search(r"\[.*? ([a-f0-9]+)\]", commit_result.stdout) if match: commit_hash = match.group(1)[:7] # git push if sync_strategy == SyncStrategy.FORCE: print(f"⚠️ Using force push (--force-with-lease)") push_cmd = ["git", "push", "--force-with-lease", "origin", branch] else: push_cmd = ["git", "push", "origi ...[truncated 2276 chars]- Remediation
View remediation
Remediation Suggestions
- Replace the allow-by-default copy policy with an explicit allowlist of files and directories suitable for backup.
- Recursively exclude common sensitive patterns, including
.env*,*.pem,*.key, credential files, token stores, memory records, and conversation archives. - Canonicalize and validate all traversed paths, and avoid following symbolic links to data outside the intended workspace.
- Run a secret scanner before staging and again before pushing. Abort when high-confidence credentials are detected.
- Display the complete file list, target remote, branch, and repository visibility before the first push.
- Require explicit user confirmation for a new remote or when potentially sensitive files are detected.
- Support a project-level ignore file with documented recursive glob semantics.
- If exposure has already occurred, rotate affected credentials and purge sensitive objects from Git history and all remote references.
