Back to skill

Security audit

Batch Files

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a Windows batch scripting reference, but it includes unsafe administrator-access and persistence guidance plus vulnerable starter templates that require careful review.

Install only if you are comfortable reviewing and constraining the generated Windows commands. Do not use the recovery-account, SYSTEM-shell, AutoRun/startup, or plaintext FTP patterns unless you have explicit authorization and a rollback plan, and treat the bundled batch templates as starter material that need input validation before use with untrusted data.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (6)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
references/batch-files-and-functions.md:69
Finding

Pre-Authentication SYSTEM Shell and Administrator Account Creation Technique

Content
View full analysis
Restart, then Troubleshoot > Startup Settings > F4 (safe) or F5 (safe+networking). WinRE: repeatedly power-cycle (hold power 10s, 3 times). WinPE: boot from USB, runs wpeinit automatically. WinPE drive detection script: loop through drive letters A-Z checking for existence of a known file. Create admin account from recovery: rename utilman.exe, copy cmd.exe over it, reboot, click Ease of Access at login to get CMD, `NET user demo-user password1 /add` then `NET localgroup administrators demo-user /add`. ``` ### Technical Analysis The reference explicitly describes replacing the Windows Ease of Access executable with `cmd.exe`. Because Ease of Access can be launched from the sign-in screen under a highly privileged Windows security context, this replacement creates a pre-authentication command shell. The instructions then create a new local user and add it to the local Administrators group. This is not necessary for the declared batch-file authoring functionality and deliberately bypasses normal authentication and authorization boundaries. It also modifies a protected operating-system executable, effectively creating a local backdoor until the original file is restored. ### Attack Path 1. An attacker with physical access or access to a recovery environment boots the machine into WinRE or WinPE. 2. The attacker modifies the offline Windows installation by replacing `utilman.exe` with `cmd.exe`. 3. The machine is rebooted to the Windows sign-in screen. 4. The attacker activates Ease of Access, causing the substituted command shell to launch without authenticating. 5. The commands documented by the Skill create a new local account. 6. The new account ...[truncated 702 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
references/batch-files-and-functions.md:272
Finding

Unsafe SYSTEM-Context Scheduling and Interactive Privileged Shell Guidance

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
assets/task.txt:41
Finding

Command Injection Through Untrusted Arguments in the Scheduled Task Template

Content
View full analysis
>"%_logFileMyTask%" ``` ### Technical Analysis The template copies command-line arguments into variables using immediate `%...%` expansion and later places those values directly into `IF`, `CALL`, and `ECHO` command text. Quoting is not a complete defense in CMD when attacker-controlled input can contain embedded quotes and shell metacharacters such as `&`, `|`, `<`, `>`, `(`, or `)`. The use of `CALL` is especially dangerous because CMD reparses the expanded command line, giving malicious metacharacters or secondary expansion tokens another opportunity to become executable syntax. The primary Skill's security guidance claims that quoting user input is sufficient, but this is inaccurate for arbitrary CMD input containing embedded quotes. The refer ...[truncated 1281 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
assets/executable.txt:40
Finding

Command Injection Through Arguments in the Executable Template

Content
View full analysis
nul ) ``` ### Technical Analysis Arguments are inserted into executable CMD syntax through immediate variable expansion. Values are used in `IF`, `ECHO`, and potentially `COPY` operations without strict character validation. An embedded quote can terminate the intended quoted region. Subsequent CMD metacharacters can then split commands, construct pipelines, or redirect output. The commented copy operation is presented as an implementation example and would remain vulnerable if enabled without stronger validation. The existence check does not sanitize the value and therefore does not prevent parser-level command injection. ### Attack Path 1. A developer copies the template into a callable batch utility. 2. An attacker supplies a crafted input or output argument. 3. Immediate variable expansion places the hostile value into the batch command text. 4. Embedded quotes and metacharacters escape t ...[truncated 556 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
assets/library.txt:53
Finding

Variable-Name and Message Injection in the Reusable Batch Library

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
references/batch-files-and-functions.md:215
Finding

Plaintext FTP Credential Materialization in Temporary Script Files

Content
View full analysis
script.ftp & DEL script.ftp`). Check for errors: redirect FTP output to log file, use `FIND` to search for error messages. Alternatives: WGET (`wget ftp://host/file` for anonymous downloads), WinSCP (SFTP/FTP with scripting interface), ScriptFTP (encrypted scripts, self-contained executables). ``` ### Technical Analysis The recommended unattended FTP workflow writes a username and password into a plaintext command script. Deleting or truncating the file afterward does not protect it while present and is not guaranteed to securely erase its previous disk contents. FTP also transmits credentials and data without transport encryption. Other local users, malware, backup software, indexing services, process-monitoring tools, or improperly permissioned log collectors may capture the credential file or associated command data. This conflicts with the primary Skill's instruction not to store credentials in batch files. ### Attack Path 1. An automation script creates the FTP command file containing a username and password. 2. The file is written to a predictable or insufficiently protected location. 3. Another local process or user reads the file before deletion, recovers it from storage, or captures it through backup or monitoring. 4. The attacker reuses the credentials against the FTP service. 5. If FTP is used over an untrusted network, credentials may also be intercepted in transit. ### Impact Assessment Exposed credentials can permit unauthorized access to re ...[truncated 283 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (16)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
| `batch-files-and-functions.md` | Example scripts, techniques, best practices links |

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · references/batch-files-and-functions.md (reported line 51)May include surrounding context.

md
## System and Configuration

**ANSI Colours** — Available by default in Windows 1909+. Foreground: `Esc[30m` (black) through `Esc[97m` (white). Background: `Esc[40m` through `Esc[107m`. Formatting: `Esc[1m` (bold), `Esc[4m` (underline), `Esc[7m` (reverse). Reset: `Esc[0m`. Save ESC to variable: `for /f %%a in ('echo prompt $E^| cmd') do set "ESC=%%a"`. Supports 24-bit RGB in Win10. Enable on older Win10 via registry: `[HKCU\Console] VirtualTerminalLevel=dword:1`.

**Autoexec and AutoRun** — Autoexec.bat: legacy MS-DOS; under Windows, only SET statements in `C:\autoexec.bat` are parsed at boot. AutoRun commands: set `HKCU\Software\Microsoft\Command Processor\AutoRun` or `HKLM` equivalent to run commands when CMD opens (useful for DOSKEY macros). Startup locations: `%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\`, `HKCU\...\Run`, `HKLM\...\Run`. Machine startup: use Task Scheduler with "When my computer starts". Disable AutoRun on drives: `NoDriveTypeAutoRun` registry key; fully disable with `iniFileMapping` method.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The AutoRun/startup guidance enumerates multiple persistence mechanisms via registry Run keys, Command Processor AutoRun, startup folders, and scheduled tasks. In a general batch-file skill, this meaningfully lowers the barrier to establishing persistence on a Windows host and is not necessary for most scripting assistance.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The document includes explicit security-bypass and account-manipulation procedures, including OOBE bypasses and a recovery-environment technique to replace utilman.exe and create a local administrator account from the login screen. Even in reference material, these steps materially enable unauthorized access and privilege escalation far beyond normal batch-file authoring guidance.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The recovery-environment account-creation steps describe a known unauthorized access technique without any warning about security impact, legality, or authorization requirements. Because the procedure directly yields administrative access, omission of safeguards materially increases risk.

Content

No source excerpt is available for this finding.

Ssd 4

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The utilman.exe replacement and subsequent local admin creation chain is a trust-bypass technique that can grant privileged access from the login screen to anyone with physical or recovery-environment access. This is a concrete offensive procedure, not merely background knowledge, and is especially dangerous in a general-purpose scripting skill.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill description uses very broad trigger phrases such as general Windows automation, shell scripting, and work on any .bat/.cmd files in the workspace. Overly broad activation can cause the agent to invoke this skill in situations where batch scripting is only tangentially related, increasing the chance of unsafe or irrelevant command-generation in a high-risk shell context.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The documentation for :_toLowerMyLib says it converts a variable's value to lowercase, but the loop substitutes each uppercase letter with the same uppercase letter, leaving the string unchanged. The inline note at L79-L81 also describes lowercasing behavior that the code does not implement, so the documented intent contradicts the actual effect.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code performs a destructive filesystem operation with rmdir /S /Q, which recursively removes the temporary directory and its contents. Although cleanup is commented in code, there is no user-facing disclosure in the script output or an interactive confirmation before deletion.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The persistence guidance lacks warning language despite describing registry and startup-based autorun behavior that can silently alter system behavior across logons and reboots. In an agent skill, presenting these mechanisms without cautions increases misuse risk and normalizes persistence techniques.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/batch-files-and-functions.md (reported line 59)May include surrounding context.

md
**Internal Commands** — Commands built into CMD.exe (no external .exe needed): ASSOC, BREAK, CALL, CD, CLS, COLOR, COPY, DATE, DEL, DIR, DPATH, ECHO, ENDLOCAL, ERASE, EXIT, FOR, FTYPE, GOTO, IF, KEYS, MD, MKLINK, MOVE, PATH, PAUSE, POPD, PROMPT, PUSHD, REM, REN, RD, SET, SETLOCAL, SHIFT, START, TIME, TITLE, TYPE, VER, VERIFY, VOL. External commands stored in `C:\WINDOWS\System32`. Arguments can be passed to internal commands; space before argument can be omitted at command line but include it in scripts.

**App Compatibility** — Set via registry at `HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers` (per-user) or `HKLM` (all users). Syntax: `~ [PrivilegeLevel] [Settings] [CompatibilityMode]`. Privilege: `RUNASADMIN`. Settings: `256COLOR`, `16BITCOLOR`, `640X480`, `HIGHDPIAWARE`, `DPIUNAWARE`, `GDIDPISCALING DPIUNAWARE`, `DISABLEDXMAXIMIZEDWINDOWEDMODE`. Modes: `WIN95`, `WIN98`, `WINXPSP2`, `WINXPSP3`, `VISTARTM`, `VISTASP1`, `VISTASP2`, `WIN7RTM`, `WIN8RTM`. Example: `REG ADD "HKCU\...\AppCompatFlags\Layers" /V "%ProgramFiles%\app\app.exe" /T REG_SZ /D "~ RUNASADMIN WINXPSP2" /F`.

**Errorlevel and Exit Codes** — Most commands return 0 for success. Max range: ±2147483647. Detection methods: (1) `IF ERRORLEVEL n` (legacy, means >= n), (2) `IF %ERRORLEVEL% EQU 0` (preferred). Inside loops, use `&&`/`||` conditional operators or enable DelayedExpansion for `!ERRORLEVEL!`. Commands that do NOT affect ERRORLEVEL: BREAK, ECHO, ENDLOCAL, FOR, IF, PAUSE, REM, RD, TITLE. Force ERRORLEVEL 1: `(CALL)`. Reset to 0: `(call )`. Never `SET ERRORLEVEL=...` (creates user variable that shadows the pseudo-variable). .CMD scripts reset ERRORLEVEL after every internal command; .BAT scripts only on error.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The FTP scripting section documents unattended login using usernames and passwords in script files, which encourages insecure credential handling and can leak secrets via files, logs, backups, or process artifacts. This expands the skill from batch syntax help into operationally risky practices that can expose credentials.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
50% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · references/msys2.md (reported line 92)May include surrounding context.

md
- [Re-installing MSYS2](https://www.msys2.org/wiki/MSYS2-reinstallation/)
- [Setting up SSHd](https://www.msys2.org/wiki/Setting-up-SSHd/)
- [Signing Packages](https://www.msys2.org/wiki/Signing-packages/)
- [Do you need Sudo?](https://www.msys2.org/wiki/Sudo/)
- [Terminals](https://www.msys2.org/wiki/Terminals/)
- [Qt Creator](https://www.msys2.org/wiki/GDB-qtcreator/)
- [TODO LIST](https://www.msys2.org/wiki/Devtopics/)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown file is a broad command reference that includes highly destructive or irreversible commands such as disk, volume, registry, backup, and deletion operations, but it provides no warning that following these links may lead users to commands that can erase data or alter system integrity. Under the markdown-specific warning criterion, the description should disclose that the referenced content includes potentially dangerous administrative commands.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

L009 describes multiple ways to run commands with elevated permissions and to bypass elevation behavior, but does not warn that these methods grant administrator-level access and can change system state. In markdown, elevation-related behavior should disclose the integrity and safety implications so users can make an informed choice.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

L041 instructs readers how to delete files older than a threshold, including bulk-deletion methods, but does not include any caution about irreversible data loss or verifying the target scope first. In a markdown skill/reference file, destructive behaviors affecting user data should be accompanied by a warning so users understand the risk before applying the command.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.