Command Injection
Talk it through out loud with your AI coach.
The problem
- medium
- Pro
A tool on your server lets users enter a host name, and the code builds a shell command to ping it by joining strings together. Explain how this can be abused and how you'd rewrite it safely.
What a strong answer covers
- How joining user input into a shell command lets attackers run their own commands.
- Running the program without a shell interpreting the input.
- Accepting only input that looks like a real host name.
- Limiting what the process can do if an attack succeeds.
Common mistake: Escaping a few special characters by hand instead of keeping the shell out of it.
Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.
Practise it out loud