← Quiz: Command Injection and Path Traversal: all 10 questions
Quiz: Command Injection and Path Traversal · Question 6 of 10
What does this print? (code)
What does this print?
import posixpath
print(posixpath.normpath(posixpath.join("/srv/docs", "a/../../secret.txt")))
- A./srv/docs/secret.txt
- B./srv/docs/a/secret.txt
- C./srv/secret.txt
- D./secret.txt
Answer & explanation
Correct answer: /srv/secret.txt
a/.. cancels out, and the second .. leaves /srv/docs, so the file is outside the docs folder.
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 →