🎙 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 6 of 10

What does this print? (code)

What does this print?

import posixpath
print(posixpath.normpath(posixpath.join("/srv/docs", "a/../../secret.txt")))
  1. A./srv/docs/secret.txt
  2. B./srv/docs/a/secret.txt
  3. C./srv/secret.txt
  4. 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 →