🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Command Injection and Path Traversal: all 10 questions

Quiz: Command Injection and Path Traversal · Question 1 of 10

What makes subprocess.run("ping -c 1 " + host, shell=True) dangerous?

What makes subprocess.run("ping -c 1 " + host, shell=True) dangerous?

  1. A.ping is a slow program
  2. B.The shell interprets characters like ; and $( ) in host, so an attacker can add commands
  3. C.subprocess cannot run ping
  4. D.It only works on Linux
Answer & explanation

Correct answer: The shell interprets characters like ; and $( ) in host, so an attacker can add commands

With shell=True the whole string is parsed by a shell, including any extra commands in host.

Can you get the rest right without peeking?

Take the timed Quiz: Command Injection and Path Traversal quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →