Which secure coding practice BEST protects against path traversal attacks in a web application that serves user-requested files?
-
A
Encoding all file names with Base64 before storage
-
B
Canonicalizing file paths and validating they remain within an allowed base directory
-
C
Requiring HTTPS for all file download requests
-
D
Logging all file access attempts to a SIEM