Skip to content

sec (5/9): reject unsafe targets on the Windows host shell#29

Open
jesse-merhi wants to merge 1 commit into
sec/04-benchmark-preflightfrom
sec/05-windows-target-guard
Open

sec (5/9): reject unsafe targets on the Windows host shell#29
jesse-merhi wants to merge 1 commit into
sec/04-benchmark-preflightfrom
sec/05-windows-target-guard

Conversation

@jesse-merhi

@jesse-merhi jesse-merhi commented Jul 23, 2026

Copy link
Copy Markdown
Member

What changes

On the Windows host shell (--sandbox off on Windows), a user-defined
scanner target containing %, ", or ! is now rejected instead of being
interpolated into the cmd.exe command line.

Why it matters

cmd.exe expands %VAR% even inside double quotes, expands !VAR! when delayed
expansion is on, and does not let backslash escape a ". So a target path
containing those characters could break out of the intended argument and inject
host commands. Since a target name/path can come from untrusted skill content,
that is a command-injection vector on Windows. Rejecting those characters closes
it. This affects only the Windows host shell path — the Docker sandbox (the
default) and POSIX hosts pass the target as a positional "$1" argument and are
unaffected.

Before / after

Target on Windows host Before After
skill%PATH%.md interpolated into cmd.exe line — expansion/injection risk scanner result failed, no command run
plain-skill.md runs runs (unchanged)

The guard is unsafeWindowsShellTarget(target); it fires only when the resolved
shell is the Windows host shell, so Docker/POSIX behavior is untouched.

Verify

go test ./internal/runner/ -run 'UnsafeWindowsShellTarget' -count=1

TestUnsafeWindowsShellTargetDetectsInjectionCharacters covers %, ", !
(rejected) and safe targets (allowed). Cross-compiles clean:
GOOS=windows go build ./....

cmd.exe expands %VAR% even inside double quotes, expands !VAR! under delayed
expansion, and does not treat backslash as an escape for ". A target path
containing %, !, or \" could therefore break out of its quoted argument and
inject host commands. Reject such targets on the Windows host shell before
building the command line. The Docker sandbox (a POSIX shell in the container)
is unaffected.
Copilot AI review requested due to automatic review settings July 23, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@clawsweeper

clawsweeper Bot commented Jul 24, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: sec (5/9): reject unsafe targets on the Windows host shell This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants