Question 20
A developer working in a governed organization reports, the following condition is confirmed: A generated file upload handler trusts extension alone and writes to a public directory. What should the team do first?
Explanation
Correct Answer
Given that A generated file upload handler trusts extension alone and writes to a public directory, choose "Validate content and size, sanitize paths, and isolate uploads". Filename metadata alone does not prevent malicious content or path traversal. This targets the identified problem rather than a neighboring issue.
Incorrect Answers
The action "Preserve authorization and use isolated test identities instead" is useful when A suggested web endpoint disables authentication to simplify testing. Temporary authentication bypasses can become exploitable production paths. Under the stated condition A generated file upload handler trusts extension alone and writes to a public directory, instead choose "Validate content and size, sanitize paths, and isolate uploads". Filename metadata alone does not prevent malicious content or path traversal.
The alternative "Use safe argument passing and reject unexpected input" fits another situation: A script executes a user-supplied shell argument through a command string. Shell interpolation can turn data into unintended commands. Here the condition is A generated file upload handler trusts extension alone and writes to a public directory; use "Validate content and size, sanitize paths, and isolate uploads" instead. Filename metadata alone does not prevent malicious content or path traversal.
The alternative "Replace concatenation with parameterized SQL statements" addresses A generated SQL query concatenates an untrusted username into a string. Parameter binding separates untrusted values from SQL syntax. It does not resolve A generated file upload handler trusts extension alone and writes to a public directory; the correct choice is "Validate content and size, sanitize paths, and isolate uploads". Filename metadata alone does not prevent malicious content or path traversal.