Back to skill

Security audit

Bat Ps1 Dev Publish

Security checks for vulnerabilities and agentic risk

Overview

This skill is a scripting knowledge base, but it includes high-impact guidance for persistence, anti-termination, system modification, and hiding sensitive PowerShell/C# code from security tools.

Only install this in a controlled, authorized security-tool development environment. Treat its self-update rule, anti-termination techniques, service persistence, privileged deletion workflows, and code-concealment advice as review blockers unless they are removed or placed behind explicit human approval and narrow lab-only scope.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (6)

T02 · Agent Memory Poisoning

Error
Location
SKILL.md:15
Finding

Mandatory Cross-Session Self-Modification of Skill Instructions

Content
View full analysis
**This Skill is a living document and must continuously accumulate updates rather than remain a one-time artifact.** > > Update rule 4: After every use of this Skill, if the conversation contains experience worth retaining, proactively add it to the Skill and state “Skill updated” in the response. > > Update rule 7: Every modification to the Skill must update the version, update date, and changelog. ### Technical Analysis The Skill instructs an agent to modify its own persistent instruction source after ordinary use. Conversation-derived material can therefore be promoted into trusted Skill instructions without a separate authorization or review boundary. Although the document requires redaction checks, those checks address sensitive information rather than malicious instruction injection. They do not prevent a user from presenting an unsafe command, behavioral rule, or false “best practice” as experience that should be retained. This behavior is unnecessary for the declared purpose of providing batch and PowerShell development guidance. A reference Skill can answer scripting questions without modifying its own persistent state. ### Attack Path 1. An attacker interacts with an agent that has loaded this Skill. 2. The attacker presents a malicious instruction or unsafe procedure as a newly discovered scripting lesson. 3. The Skill directs the agent to proactively record worthwhile conversational experience. 4. The agent appends the attacker-controlled material to `SKILL.md`. 5. Future sessions load the modified Skill and treat the injected material as trusted persistent guidance. 6. The attacker’s influence survives the original conversation and may affect unrelated future users or tasks. ### Impact Assessment Successful exploitation could persist attacker-controlled r ...[truncated 219 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:698
Finding

Intentional Base64 Concealment of Security-Sensitive Native API Code

Content
View full analysis
**Encode the entire Add-Type C# block in Base64 to avoid antivirus detection**: transform `Add-Type -TypeDefinition @"..."@` and `@'...'@` blocks into: > > `([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('...')))` > > The DllImport and API names are not visible in the source, greatly reducing heuristic detections. > > Delivery checklist: Base64-encode Add-Type C# blocks so that DllImport and sensitive API names do not appear in plaintext. ### Technical Analysis The document explicitly recommends Base64 encoding executable C# source so native API imports are hidden from static inspection and antivirus heuristics. PowerShell can decode the text at runtime and pass it to `Add-Type`, preserving execution while concealing the reviewed source. Base64 is not itself encryption, but using it specifically to make `DllImport` and sensitive APIs invisible is deliberate security-control evasion. It also prevents straightforward code review, source scanning, diff inspection, and policy enforcement. This is particularly dangerous because nearby guidance uses sensitive process, token, memory, service, and native Windows APIs. The concealed block can change while the visible PowerShell wrapper remains substantially unchanged. ### Attack Path 1. An attacker places sensitive or malicious C# P/Invoke code in an `Add-Type` source block. 2. The source is Base64 encoded. 3. Static reviewers and basic endpoint scanners see only the encoded string and runtime decoder. 4. PowerShell invokes `FromBase64String` and decodes the source in memory. 5. `Add-Type` compiles the recovered C# code. 6. The compiled code invokes hidden native Windows APIs with the privileges of the PowerShell process. ### Impact Assessment The decoded payload can exercis ...[truncated 319 chars]
Remediation
View remediation

T06 · System Persistence

Error
Location
SKILL.md:681
Finding

Auto-Starting LocalSystem Guardian Service and Self-Restart Watchdog

Content
View full analysis
Tier 3 uses a hard hook and elevated guardian requiring UAC. > > `spawnGuardian()` uses `ShellExecute("runas")` to start `--guardian --tier 3`. The guardian writes heartbeat files, detects stale main-process heartbeats, resumes suspended threads, and restarts the main process with `--guarded`. > > An optional LocalSystem service is exposed through `toggleGuardianService()`. After GUI confirmation it executes: > > `sc create/delete SilverFoxGuardian binPath=... start= auto` > > The guardian restarts the main process after loss and uses flags and cooldown logic to prevent recursive process spawning. ### Technical Analysis The guidance creates an automatically starting service operating as LocalSystem and combines it with a guardian that restarts a terminated process. This survives user logoff and system reboot and runs at the highest ordinary Windows service privilege level. The behavior substantially exceeds the minimum privileges needed by a scripting knowledge base or a normal on-demand scanner. Confirmation through a GUI reduces accidental installation but does not address excessive privilege, service-path integrity, binary replacement, or abuse by an untrusted caller. The service and watchdog also make termination and cleanup more difficult because one component is designed to restore another. ### Attack Path 1. A user or attacker with administrative approval invokes the Tier 3 service-installation function. 2. The tool registers `SilverFoxGuardian` as an automatically starting service. 3. Windows starts the service across future boots under LocalSystem. 4. The guardian monitors process heartbeat files. 5. If the protected process stops or is suspended, the guardian resumes or restarts it. 6. If the service executable or its configuration can be replaced ...[truncated 435 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:805
Finding

Anti-Termination Hooks, Shutdown Blocking, and System-Crash Behavior

Content
View full analysis
Create a hidden top-level window and return `FALSE` for `WM_QUERYENDSESSION` to reject shutdown, logoff, or restart. > > Tier 3 obtains the addresses of `NtTerminateProcess`, `NtSuspendProcess`, and `NtSuspendThread`, changes memory protection to executable and writable, installs inline jumps, and returns `STATUS_ACCESS_DENIED` for operations targeting itself. > > `/bruteprotect` invokes: > > `NtSetInformationProcess(ProcessBreakOnTermination=29)` > > If the process is then killed from user mode, the system produces bug check `0xDEADDEAD`. > > For a process classified as an unsigned termination tool, actively invoke `TerminateProcess`; elevated integrity can terminate lower-integrity targets. ### Technical Analysis The Skill combines several mechanisms intended to prevent users or administrators from controlling the host: - Blocking ordinary shutdown, logoff, or restart through `WM_QUERYENDSESSION`. - Modifying executable memory to hook native process-control APIs. - Marking a user process as critical so termination can crash Windows. - Automatically terminating other processes based on signature and heuristic classification. - Restarting the protected process through a watchdog. These mechanisms are not necessary for ordinary script development or report-only malware scanning. Signature status and path heuristics do not prove malicious intent, so automatically killing a process can affect legitimate administration, debugging, accessibility, recovery, or incident-response tools. The `ProcessBreakOnTermination` behavior is especially dangerous because a routine termination attempt can cause system-wide denial of service and potential loss of unsaved work. ### Attack Path 1. The tool starts with ...[truncated 893 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:814
Finding

Progressive Escalation to SYSTEM or Sudo for Destructive Deletion

Content
View full analysis
Quarantine/deletion process: > > 1. Stop related processes, matching only the target and excluding the tool itself. > 2. Remove persistence from Registry Run entries, scheduled tasks, and services; on Linux, remove crontab, systemd, and bashrc entries. > 3. Back up the target to quarantine for rollback. > 4. Escalate deletion progressively: > > `Remove-Item` → `takeown + icacls` → SYSTEM scheduled task > > On Linux: > > `rm` → `chattr -ia` → `sudo` ### Technical Analysis This workflow overrides ownership and ACL protections and ultimately schedules deletion as SYSTEM or invokes `sudo`. It also removes startup entries from multiple persistence mechanisms. A backup-first policy reduces accidental loss but does not provide a sufficient authorization boundary. The document does not specify robust target provenance, canonical-path restrictions, protected-path denylists, trusted-signer exclusions, or a mandatory per-target approval process before SYSTEM-level deletion. A false positive or attacker-controlled target path could therefore cause privileged deletion of legitimate software or operating-system files. Clearing scheduled tasks, services, shell startup files, or registry entries can also disable unrelated applications and security controls. ### Attack Path 1. An attacker influences a scan result, target path, rule set, or user selection. 2. The target is classified as malicious or associated with unwanted persistence. 3. The tool stops matching processes and removes related startup configuration. 4. Ordinary deletion fails because of ACLs, ownership, immutable attributes, or active protection. 5. The workflow invokes `takeown`, modifies ACLs, clears immutable attributes, or creates a SYSTEM scheduled task. 6. The protected target is deleted with e ...[truncated 371 chars]
Remediation
View remediation

T06 · System Persistence

Warning
Location
SKILL.md:635
Finding

Low-Visibility HKCU Run-Key Persistence Guidance

Content
View full analysis
Write a startup-management batch file for a third-party GUI application. > > To preserve quotes in the registry value, use: > > `reg add "%KEY%" /v Name /t REG_SZ /d "\"%APP_PATH%\"" /f` > > **The HKCU Run key is preferable to the Startup folder** because a batch file in the Startup folder flashes a console window, while a Run value points directly to the executable without a window. HKCU is writable by the current user and requires no administrator privileges. > > To remove the entry, use `reg delete ... >nul 2>&1`. ### Technical Analysis The guidance explains how to establish login persistence through the current user’s Run key and specifically highlights its lack of a visible console window. The section does recommend using an application’s official startup option first and provides deletion guidance, which reduces severity. Nevertheless, the mechanism enables cross-session execution without elevation. In the context of the same Skill’s watchdog, concealment, and anti-termination guidance, it provides an additional low-friction persistence channel. ### Attack Path 1. An attacker or untrusted script controls `APP_PATH`, the value name, or the batch invocation. 2. The batch file writes the quoted executable path to the current user’s Run key. 3. The value remains after the current process and conversation end. 4. At the next login, Explorer starts the executable automatically without displaying a batch console window. 5. The executable continues running with the affected user’s privileges. ### Impact Assessment This provides persistence for the affected user account across logoff, login, and reboot. It does not inherently grant administrator privileges, but it can execute any program accessible to the user and may be combined with later elevation or credential acc ...[truncated 8 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (9)

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 1)May include surrounding context.

md
---
name: bat-ps1-dev
description: "Windows/Linux batch + PowerShell script dev experience vault — encoding pitfalls, cmd syntax traps, PS 5.1/7 compat, cross-platform gotchas, security tool best practices. 批处理/PowerShell 脚本开发经验库,编码陷阱、cmd 语法坑、PS兼容、跨平台坑、安全工具最佳实践。Keywords: bat, cmd, PowerShell, ps1, pwsh, BOM, CRLF, 闪退, 乱码, Windows scripting"
version: "1.71.0"

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 306)May include surrounding context.

md
---
name: bat-ps1-dev
description: "Windows/Linux batch + PowerShell script dev experience vault — encoding pitfalls, cmd syntax traps, PS 5.1/7 compat, cross-platform gotchas, security tool best practices. 批处理/PowerShell 脚本开发经验库,编码陷阱、cmd 语法坑、PS兼容、跨平台坑、安全工具最佳实践。Keywords: bat, cmd, PowerShell, ps1, pwsh, BOM, CRLF, 闪退, 乱码, Windows scripting"
version: "1.71.0"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
87% confidence
Finding

Although duplicated by the scanner, the flagged content still reflects potentially abusable command usage for immutable flags, chmod-based locking, firewall rule changes, and deletion workflows. These are not inherently malicious, but in this skill they meaningfully expand operator capability to manipulate protected system state and hinder cleanup.

Content

Scanner excerpt · SKILL.md (reported line 708)May include surrounding context.

md
- **v1.6.0 (2026-08-17)**:§8/§5 新增辅助脚本审查与重构经验: ① **正则 `^(.*)$` 贪婪匹配会吞入行尾后缀** → 清单解析必须精确锚定可选后缀: `(.*?)(?:\s+\[[^\]]*\])?(?:\s*\|\s*原隔离区:\s*.*)?$` (防恢复落错文件名/回滚失败); ② **`"" | Out-File -Append` 默认 UTF-16, 后续 Add-Content 按 ANSI/UTF8 追加 → 日志中文乱码混排** → 首行必须显式 `-Encoding UTF8`; ③ 辅助脚本与主引擎的**路径回退必须一致** (Clear-Cache 的 LOCALAPPDATA 回退曾与引擎不同, 清不干净); ④ 多脚本复用的"交互序号选择"逻辑抽公共函数 `Get-Selection` (返回 @(-1) 表示取消), 收敛 8 处重复代码, 注意各处块文本细微差异(变量初始化位置/多行 all 分支/文案不同), 需逐处核对; ⑤ 大工程整块替换用**先 dump repr 对比再替换**, 别猜格式(曾因 LF/CRLF、尾随空格、变量初始化顺序差异匹配失败 3 次)。
- **v1.5.0 (2026-08-17)**:§7 新增自查方法论 + §2/§5 补坑: ① **多 agent 并行代码审查** + 逐个复验(不轻信结论, 用 grep/sed 验证每个发现) 是发现隐蔽 bug 的高效方式; ② **`foreach ($a in $args)` 循环内 `$_` 是空**(foreach 不设 `$_`, 只有 ForEach-Object 管道才设)→ 循环内必须用 `$a`(曾致 /threads=N 永不生效); ③ **cmd 里 `goto 未定义标签` 直接终止整个 bat** → 所有 goto 目标必须存在, 自查时 grep 全部 goto 与标签对比; ④ **SYSTEM 计划任务 cmd /c 拼接路径**: cmd 在双引号内仍展开 `%VAR%`, 必须先 `[Environment]::ExpandEnvironmentVariables` 并拒绝残留 `%` 的路径; ⑤ **可预测 /tmp 文件名 + symlink = root 任意文件写**: 写临时文件用 `[IO.File]::Open(path, CreateNew,...)` (O_EXCL 语义) 防符号链接; ⑥ `Move-Item` 等关键操作在全局 `SilentlyContinue` 下**必须显式 `-ErrorAction Stop` + Test-Path 复核**, 否则假成功; ⑦ 前缀匹配 `StartsWith($dir)` 必须补分隔符防 `FooEvil` 绕过; ⑧ 路径提取用 `(\S+)` 遇空格截断 → 改行末 `(.+)$`; ⑨ 关机守护按进程名 kill 会误杀系统/自身触发的合法 shutdown → **系统路径只记录不 kill**, 非系统路径才拦。
- **v1.4.4 (2026-08-17)**:§5 新增网络封锁实战经验: ① Windows 防火墙封禁: `New-NetFirewallRule -Direction Outbound -Action Block` 按 `-RemoteAddress`(IP) 或 `-Program`(进程路径), 需管理员; 查重用 `Get-NetFirewallRule -DisplayName`; ② Linux iptables: `iptables -C OUTPUT -d IP -j DROP` 查重(退出码0=已存在), `-A` 添加 `-D` 删除; **容器默认有 CAP_NET_ADMIN 可真实测试**, 但规则重启即失(未持久化, 工具定位是实时阻断); ③ Linux iptables 无法按进程过滤(需 owner/cgroup match), 进程路径封锁仅记录清单; ④ 规则名用 IP 转义(`-replace '[.:]','_'`)防重名, 进程规则用路径 MD5 前12位; ⑤ 封锁清单同样用「管道符分隔」+ 去重(查重 key 用目标值); ⑥ `/xxx` 管理模式的通用交互(查看清单→序号选择→解除)已复用第 4 处。
- **v1.4.3 (2026-08-17)**:§5 新增威胁锁定实战经验: ① **PowerShell 管道 0 对象不会触发 Set-Content** → 清空文件用 `Clear-Content`, 否则 `$lines | Set-Content` 空数组时文件保持原样(清
...[truncated 26 chars]

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
87% confidence
Finding

Although duplicated by the scanner, the flagged content still reflects potentially abusable command usage for immutable flags, chmod-based locking, firewall rule changes, and deletion workflows. These are not inherently malicious, but in this skill they meaningfully expand operator capability to manipulate protected system state and hinder cleanup.

Content

Scanner excerpt · SKILL.md (reported line 708)May include surrounding context.

md
- **v1.6.0 (2026-08-17)**:§8/§5 新增辅助脚本审查与重构经验: 1 **正则 `^(.*)$` 贪婪匹配会吞入行尾后缀** → 清单解析必须精确锚定可选后缀: `(.*?)(?:\s+\[[^\]]*\])?(?:\s*\|\s*原隔离区:\s*.*)?$` (防恢复落错文件名/回滚失败); 2 **`"" | Out-File -Append` 默认 UTF-16, 后续 Add-Content 按 ANSI/UTF8 追加 → 日志中文乱码混排** → 首行必须显式 `-Encoding UTF8`; 3 辅助脚本与主引擎的**路径回退必须一致** (Clear-Cache 的 LOCALAPPDATA 回退曾与引擎不同, 清不干净); 4 多脚本复用的"交互序号选择"逻辑抽公共函数 `Get-Selection` (返回 @(-1) 表示取消), 收敛 8 处重复代码, 注意各处块文本细微差异(变量初始化位置/多行 all 分支/文案不同), 需逐处核对; 5 大工程整块替换用**先 dump repr 对比再替换**, 别猜格式(曾因 LF/CRLF、尾随空格、变量初始化顺序差异匹配失败 3 次)。
- **v1.5.0 (2026-08-17)**:§7 新增自查方法论 + §2/§5 补坑: 1 **多 agent 并行代码审查** + 逐个复验(不轻信结论, 用 grep/sed 验证每个发现) 是发现隐蔽 bug 的高效方式; 2 **`foreach ($a in $args)` 循环内 `$_` 是空**(foreach 不设 `$_`, 只有 ForEach-Object 管道才设)→ 循环内必须用 `$a`(曾致 /threads=N 永不生效); 3 **cmd 里 `goto 未定义标签` 直接终止整个 bat** → 所有 goto 目标必须存在, 自查时 grep 全部 goto 与标签对比; 4 **SYSTEM 计划任务 cmd /c 拼接路径**: cmd 在双引号内仍展开 `%VAR%`, 必须先 `[Environment]::ExpandEnvironmentVariables` 并拒绝残留 `%` 的路径; 5 **可预测 /tmp 文件名 + symlink = root 任意文件写**: 写临时文件用 `[IO.File]::Open(path, CreateNew,...)` (O_EXCL 语义) 防符号链接; 6 `Move-Item` 等关键操作在全局 `SilentlyContinue` 下**必须显式 `-ErrorAction Stop` + Test-Path 复核**, 否则假成功; 7 前缀匹配 `StartsWith($dir)` 必须补分隔符防 `FooEvil` 绕过; 8 路径提取用 `(\S+)` 遇空格截断 → 改行末 `(.+)$`; 9 关机守护按进程名 kill 会误杀系统/自身触发的合法 shutdown → **系统路径只记录不 kill**, 非系统路径才拦。
- **v1.4.4 (2026-08-17)**:§5 新增网络封锁实战经验: 1 Windows 防火墙封禁: `New-NetFirewallRule -Direction Outbound -Action Block` 按 `-RemoteAddress`(IP) 或 `-Program`(进程路径), 需管理员; 查重用 `Get-NetFirewallRule -DisplayName`; 2 Linux iptables: `iptables -C OUTPUT -d IP -j DROP` 查重(退出码0=已存在), `-A` 添加 `-D` 删除; **容器默认有 CAP_NET_ADMIN 可真实测试**, 但规则重启即失(未持久化, 工具定位是实时阻断); 3 Linux iptables 无法按进程过滤(需 owner/cgroup match), 进程路径封锁仅记录清单; 4 规则名用 IP 转义(`-replace '[.:]','_'`)防重名, 进程规则用路径 MD5 前12位; 5 封锁清单同样用「管道符分隔」+ 去重(查重 key 用目标值); 6 `/xxx` 管理模式的通用交互(查看清单→序号选择→解除)已复用第 4 处。
- **v1.4.3 (2026-08-17)**:§5 新增威胁锁定实战经验: 1 **PowerShell 管道 0 对象不会触发 Set-Content** → 清空文件用 `Clear-Content`, 否则 `$lines | Set-Content` 空数组时文件保持原样(清
...[truncated 26 chars]

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The document title and nearly all instructional content are in Chinese, while the file does not offer a language/locale choice for users or state that the skill is intentionally restricted to a Chinese-speaking audience. Under the language/locale policy, forcing a specific language without opt-in is a natural-language policy issue.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The markdown defines trigger/update moments such as '踩到新坑、发现新现象、找到新对策' and '用户提出新需求' without explicit scope boundaries or negative examples. These conditions are very broad for a skill and overlap with ordinary script-development conversations, making unintended invocation or forced updates more likely.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill includes actionable procedures for modifying hosts files, firewall rules, IFEO, services, startup entries, and shutdown behavior. These are privileged and security-sensitive system changes that can be abused for persistence, traffic redirection, defense evasion, or user disruption if copied into the wrong context.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This section documents advanced self-protection, anti-termination, watchdog, mitigation-policy, and near-PPL style hardening techniques for a security tool. Even if framed as defensive engineering, these capabilities materially overlap with malware resilience patterns and can be repurposed to make unauthorized software harder to inspect, stop, or remove.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The privacy/intent section says the skill should only capture generalized technical experience and should not record environment-specific information, including machine-specific absolute paths. Later content nevertheless includes a concrete working-directory path example like E:\工具\5\02_升级工作区\work\ as recommended practice, which contradicts the stated de-identification intent rather than merely omitting detail.

Content

No source excerpt is available for this finding.