Back to skill

Security audit

WorkBuddy Expert Sync

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly aligned with syncing WorkBuddy experts, but it installs a recurring Windows scheduled task that can repeatedly overwrite all local account expert registries.

Install only if you want ongoing local automation, not just a one-time repair. Before running it, confirm the exact WorkBuddy accounts affected, keep an independent backup of experts.json files, and be prepared to remove the WorkBuddy_SyncMyExperts scheduled task and deployed script if the recurring mirror behavior is not desired.

Vulnerability Patterns
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T06 · System Persistence

Error
Location
SKILL.md:47
Finding
Recurring Scheduled Task Creates Cross-Session Persistence<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 47-55 **Vulnerability Type**: Persistent scheduled-task registration **Risk Level**: High ### Vulnerable Code Snippet ```markdown ### 4. 自动同步部署(面向未来新账号) 1. 部署同步脚本到 `%USERPROFILE%\.workbuddy\scripts\sync-my-experts.ps1`(本技能包内 `scripts/sync-my-experts.ps1` 为同一脚本副本)。脚本每次运行时实时枚举 marketplace 文件夹内容,把所有账号注册表**镜像**为该清单(内容有变化时先自动备份原文件再覆盖),写日志 `sync-my-experts.log`;脚本顶部 `$marketplaceName` 变量可切换其他本地专家仓库。 2. 注册计划任务 `WorkBuddy_SyncMyExperts`:触发器 = 用户登录时 + 每 30 分钟重复。 - 必须用 PowerShell `Register-ScheduledTask` 创建;**沙箱环境可能拦截 `schtasks.exe`,不要使用**。 - PowerShell 工具的 stdout 常被吞:验证时用 `Set-Content` 把 `Get-ScheduledTask`/`Get-ScheduledTaskInfo` 结果写入状态文件,再用 Read 工具读取确认。 ### 5. 验证与移除 ``` The associated invocation documented at `SKILL.md:60-62` is: ```powershell powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/sync-my-experts.ps1 ``` ### Technical Analysis The Skill directs the Agent to copy a PowerShell script into the user's profile and register `WorkBuddy_SyncMyExperts` as a scheduled task. The task executes at every user login and repeats every 30 minutes, surviving both the original Skill invocation and subsequent sessions. This behavior meets the definition of system persistence. Although recurring synchronization supports the declared future-account auto-sync feature, it is not necessary for the core operation of synchronizing currently existing account registries. A manual, user-initiated synchronization would accomplish that core function without installing a durable execution mechanism. The instruction to use `Register-ScheduledTask` because a sandbox may block `schtasks.exe` is particularly concerning. A sandbox restriction is a security boundary or policy signal; selecting an alternative registration interface to achieve the same persistent effect may circumvent that restriction. The documented use of `-ExecutionPolicy Bypass` also removes a PowerShell execution-policy safe ...[truncated 1907 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Make synchronization manual and user-initiated by default. 2. Treat scheduled automation as a separate optional feature requiring explicit, informed consent. 3. Before registration, disclose: - The exact task name. - The executable and script path. - Trigger frequency. - User identity and privilege level. - Files that will be modified. - Exact removal commands. 4. Do not attempt to work around sandbox or policy restrictions. If task registration is blocked, stop and report the failure. 5. Remove `-ExecutionPolicy Bypass`. Use a signed script and a policy-compatible invocation where possible. 6. Register the task only for the current user and never request elevation unless independently justified and explicitly approved. 7. Reduce trigger frequency and prefer an application-specific event over an unconditional 30-minute schedule. 8. Restrict modification permissions on the deployed script and verify its cryptographic hash before each execution. 9. Offer a dry-run mode and require confirmation before changing multiple account registries. 10. Provide and test an uninstall operation that deletes both the task and deployed script. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/sync-my-experts.ps1:5
Finding
Suppressed Backup Errors Permit Registry Overwrite Without Recovery<![CDATA[ ## Vulnerability Details **File Location**: `scripts/sync-my-experts.ps1`, lines 5-40 **Vulnerability Type**: Unverified backup followed by destructive overwrite **Risk Level**: Medium ### Vulnerable Code Snippet ```powershell $ErrorActionPreference = 'SilentlyContinue' $marketplaceName = 'my-experts' # local marketplace holding self-created experts $workbuddyRoot = Join-Path $env:USERPROFILE '.workbuddy' $pkgRoot = Join-Path $workbuddyRoot ("plugins\marketplaces\" + $marketplaceName + "\plugins") $regRoot = Join-Path $workbuddyRoot 'experts\custom' $bkRoot = Join-Path $workbuddyRoot 'experts\custom-backup-auto' $log = Join-Path $workbuddyRoot 'scripts\sync-my-experts.log' # Build the canonical list from what the folder actually contains if (-not (Test-Path $pkgRoot)) { exit 0 } $names = @(Get-ChildItem -Path $pkgRoot -Directory | Select-Object -ExpandProperty Name | Sort-Object) if ($names.Count -eq 0) { exit 0 } $expertJson = ConvertTo-Json -InputObject $names -Compress $utf8NoBom = New-Object System.Text.UTF8Encoding($false) if (-not (Test-Path $regRoot)) { exit 0 } $changed = @() Get-ChildItem -Path $regRoot -Directory | ForEach-Object { $f = Join-Path $_.FullName 'experts.json' $current = '' $hasBom = $false if (Test-Path $f) { $current = (Get-Content $f -Raw).Trim() $bytes = [System.IO.File]::ReadAllBytes($f) if ($bytes.Length -ge 3 -and $bytes[0] -eq 0xEF -and $bytes[1] -eq 0xBB -and $bytes[2] -eq 0xBF) { $hasBom = $true } } # Mirror: rewrite when content differs OR the file carries a UTF-8 BOM if ($current -ne $expertJson -or $hasBom) { if (Test-Path $f) { if (-not (Test-Path $bkRoot)) { New-Item -ItemType Directory -Path $bkRoot -Force | Out-Null } Copy-Item -Path $f -Destination (Join-Path $bkRoot ($_.Name + '-experts.json.pre-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))) -Force } [System.IO.File]::WriteAllText($f, $expertJson, $utf8NoBom) ``` ### Technical Analysis The script global ...[truncated 2970 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace global error suppression with fail-closed behavior: ```powershell $ErrorActionPreference = 'Stop' ``` 2. Put backup and replacement operations inside `try`/`catch` blocks and abort processing for the affected account on any failure. 3. After copying, verify that the backup exists, is readable, and matches the source file's length or cryptographic hash. 4. Never overwrite the source registry unless backup verification succeeds. 5. Write the new JSON to a temporary file in the same directory, validate that it parses correctly, and then use an atomic replacement operation. 6. Preserve the original file if validation or replacement fails. 7. Record failures in the log with timestamps and non-sensitive account placeholders. 8. Return a nonzero exit code when any account cannot be safely synchronized so scheduled-task monitoring can detect the failure. 9. Apply retention controls to backups while ensuring cleanup never removes the only valid recovery copy. 10. Add tests covering unwritable backup directories, full disks, malformed source JSON, interrupted writes, and concurrent WorkBuddy access. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (2)

Description-Behavior Mismatch

Medium
Confidence
91% confidence
Finding
The manifest description frames the skill as making local experts visible across accounts and troubleshooting missing experts, which naturally implies inspecting and updating local registration files. However, the documented implementation also deploys a PowerShell script and registers a recurring scheduled task that runs at logon and every 30 minutes, introducing ongoing persistence rather than only performing the described sync/repair action.

Context-Inappropriate Capability

Medium
Confidence
88% confidence
Finding
Creating a scheduled task is a privileged persistence mechanism and is not inherently required to diagnose or repair cross-account expert visibility issues. While auto-sync for future accounts is mentioned, the code documentation prescribes a system-level recurring task as the required mechanism, which is a stronger capability than the user-facing purpose itself justifies.

Static analysis

No suspicious patterns detected.