OS Command Injection
Untrusted input flows into an OS command executed via os/exec, enabling OS command injection (CWE-78/CWE-77).
Standards mapping
Vulnerable vs. safe
_ = exec.Command(name).Run()_ = exec.Command("ls", "-la").Run()Why it matters & how to fix it
Untrusted input flows into an OS command executed via os/exec, enabling OS command injection (CWE-78/CWE-77). The tainted value is either the program name itself or an argument to a shell (`sh -c`). Never invoke a shell with user-controlled data; call exec.Command with a fixed program and pass arguments as separate, non-shell-interpreted parameters. If the program name must be dynamic, validate it against a strict allow-list.
References
Rule ID integsec-go-os-command-injection - 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