Skip to content

fix(security): 2 improvements across 2 files#149

Open
tomaioo wants to merge 2 commits into
step-security:mainfrom
tomaioo:fix/security/command-injection-via-unsanitized-shell-
Open

fix(security): 2 improvements across 2 files#149
tomaioo wants to merge 2 commits into
step-security:mainfrom
tomaioo:fix/security/command-injection-via-unsanitized-shell-

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 23, 2026

Copy link
Copy Markdown

Summary

fix(security): 2 improvements across 2 files

Problem

Severity: High | File: internal/detector/shellcmd.go:L12

The platformShellQuote function in shellcmd.go attempts to quote strings for shell commands but uses simple string replacement that can be bypassed. On Unix, an attacker can inject commands using $'...' ANSI-C quoting or backtick command substitution. On Windows, the escaping is insufficient against ^ escape sequences and %VAR% expansion. More critically, this function is used to quote user-controlled paths/arguments before passing to exec.Run, creating potential command injection vectors when combined with other unsafe patterns.

Solution

Use exec.Command with separate arguments instead of shell string construction. If shell is required, use syscall.EscapeArg on Windows and proper shlex or strconv.Quote handling on Unix. Never build shell command strings by concatenation.

Changes

  • internal/detector/shellcmd.go (modified)
  • internal/detector/registry_windows.go (modified)

tomaioo added 2 commits June 22, 2026 23:31
- Security: Command Injection via Unsanitized Shell Command in platformShellQuote
- Security: Unsafe Direct Registry Access with Potential TOCTOU in registry_windows.go

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Security: Command Injection via Unsanitized Shell Command in platformShellQuote
- Security: Unsafe Direct Registry Access with Potential TOCTOU in registry_windows.go

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
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.

1 participant