# Command injection: definition and example

URL: https://mcpservercybersecurity.com/glossary/command-injection/
Updated: 2026-11-16

Command injection is a flaw in which text from an untrusted source ends up interpreted by a shell or operating system call. In MCP the text can come from a model's tool arguments or from a server, such as an OAuth authorization URL. The usual fix is to avoid the shell and validate input against an allowlist.

## Example

The MCP security best practices say clients must not use shell commands such as cmd.exe, sh or PowerShell to open URLs, and must only allow http and https schemes for authorization URLs.

## Sources

- [MCP Security Best Practices, 2026-07-28 revision](https://modelcontextprotocol.io/specification/2026-07-28/basic/security_best_practices) (modelcontextprotocol.io), read 2026-11-16

## Related pages

- [Path traversal](/glossary/path-traversal/)
- [SSRF](/glossary/ssrf/)
- [Tool schema](/glossary/tool-schema/)
- [All glossary terms](/glossary/)
- [Typosquatted server](/glossary/typosquatted-server/)
- [DNS rebinding](/glossary/dns-rebinding/)
- [Guides](/guides/)
