High severityGoInjectionHIGH confidence
Command Injection Shell Concatenation
A shell command is built with string concatenation or fmt.Sprintf and passed to `sh -c` (CWE-78/CWE-77).
Standards mapping
Vulnerable vs. safe
Flagged by this check
_ = exec.Command("sh", "-c", "ls "+dir).Run()Passes - the safe pattern
_ = exec.Command("ls", "-la", dir).Run()Why it matters & how to fix it
A shell command is built with string concatenation or fmt.Sprintf and passed to `sh -c` (CWE-78/CWE-77). Any special shell metacharacters in the interpolated data allow arbitrary command execution. Do not spawn a shell: run the target binary directly via exec.Command("prog", arg1, arg2) so the arguments are never re-parsed by a shell.
References
Rule ID integsec-go-command-injection-shell-concat - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - InjectionCode Injection Tainted Input
- JavaScript / TypeScript - InjectionEval Dynamic Argument
- JavaScript / TypeScript - InjectionNoSQL Query From Request
- JavaScript / TypeScript - InjectionNoSQL Where Operator
- JavaScript / TypeScript - InjectionOS Command Injection Tainted Input
- JavaScript / TypeScript - InjectionSQL Injection String Concatenation