Question 390
A profile page places input directly into a JavaScript string literal without encoding. Which method should the assessment team select for this precise requirement?
Explanation
Correct Answer
Use JavaScript-context output encoding and defensive templating. This answer directly addresses the described constraint. Encoding suitable for HTML text is not automatically sufficient inside script strings. Successful validation requires: A synthetic quote-bearing value remains inert in the rendered page.
Incorrect Answers
It would address a report generator uses user input inside its server-side template expression parser. The relevant reason in that case is: Template engines may execute operators or expose objects when input is treated as syntax. Here the required success condition is a synthetic quote-bearing value remains inert in the rendered page. The appropriate action is: Use JavaScript-context output encoding and defensive templating.
This action applies to a different case: A customer message displays unsanitized HTML that executes inside another user's browser. Untrusted content can cross the browser's code/data boundary. It does not establish the present requirement, where a synthetic quote-bearing value remains inert in the rendered page. The appropriate action is: Use JavaScript-context output encoding and defensive templating.
That approach concerns a different situation: a login rate limit can be bypassed because it counts only a mutable client-provided header. Untrusted request headers should not control abuse enforcement. The required result is that a synthetic quote-bearing value remains inert in the rendered page. The appropriate action is: Use JavaScript-context output encoding and defensive templating.