Threats, Vulnerabilities, and Attacks

A filter rejects filename parameters containing "../", yet logs show /etc/hosts returned for requests using "%2e%2e%2f". Which control BEST fixes this?

Show the answer

Correct answerC. Canonicalize the path and confirm it stays in the web root

AWhy not this: A blocklist covers only the listed encodings; attackers can use double encoding or other variants.

BWhy not this: A length cap stops oversized input, not short encoded traversal strings.

CWhy this is right: Resolving the decoded path and checking it sits inside the web root blocks all encoded variants.

DWhy not this: Anti-forgery tokens stop forged cross-site requests, not traversal in a legitimate request.

The encoded sequence decodes to ../ after the filter has checked it. Canonicalizing the final path and verifying it stays inside the web root defeats every encoding. Extending the blocklist is tempting but misses other encodings.