Fundamentals of InfoSecadvanced
Which response is recommended when untrusted text must be included in an HTML page?
Answer
Escape it for the context where it is displayed
Explanation
### Why this is right
Escaping converts characters so untrusted input is displayed as data rather than interpreted as page markup or script. The material advises keeping untrusted content out of unsafe locations and escaping it when it must be included.
### The concept
Cross-site scripting occurs when attacker-controlled content is inserted into a page delivered to a client. Context matters: content placed in scripts, comments, attribute names, tag names, or CSS can be unsafe. Proper sanitization libraries and correctly used JavaScript frameworks can also help.
### The other options
- **Place it directly inside a script element**: the material explicitly warns against putting untrusted content there.
- **Treat it as a trusted attribute name**: attacker-controlled data should not determine markup structure.
- **Disable all input validation**: this removes a useful protective layer.
### Terms
- **Cross-site scripting (XSS)**: inserting attacker-controlled content into a page received by a client.
- **Escape**: transform characters so they are treated as data in a particular context.
### Remember
Treat untrusted page content as data, never as trusted markup or code.
Related Questions
- Explain why computer security is described as a process rather than a product. Include the roles of technology, people, and environment.(intermediate)
- Select ALL items the review identifies as possible security risks or losses.(intermediate)
- Arrange these broad security activities in a sensible cycle, beginning with identifying what needs protection.(intermediate)
- A security product can replace the continuing work of managing people, technology, and the operating environment.(intermediate)
- Which statement best captures the course review’s view of computer security?(intermediate)
Want to practice more questions like this?
Join myBenkio free and practice past questions for your Nigerian university courses with AI explanations for every answer.
Start Practicing Free