← Quiz: SQL Injection: all 10 questions
Quiz: SQL Injection · Question 5 of 10
Which subprocess call is safest for running ping on a user-supplied host?
Which subprocess call is safest for running ping on a user-supplied host?
- A.os.system("ping -c 1 " + host)
- B.subprocess.run(["ping", "-c", "1", host]) after validating host
- C.subprocess.run("ping -c 1 " + host, shell=True)
- D.eval("ping " + host)
Answer & explanation
Correct answer: subprocess.run(["ping", "-c", "1", host]) after validating host
A list of arguments with no shell means the host can't add extra commands like ; rm -rf.
Can you get the rest right without peeking?
Take the timed Quiz: SQL Injection quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →