Information Security Basics

A bulletin-board web application had a vulnerability in which scripts contained in text posted by users were executed in other visitors' browsers. Which combination correctly gives the name of this vulnerability and its fundamental countermeasure?

  1. ASQL injection. Lengthen the password used to connect to the database
  2. BCross-site scripting (XSS). Escape characters with special meaning, such as < and >, when outputting posted text as HTML
  3. CCross-site scripting (XSS). Encrypt communication between the server and the browser with HTTPS
Show answer and explanation

Answer: B. Cross-site scripting (XSS). Escape characters with special meaning, such as < and >, when outputting posted text as HTML

Cross-site scripting (XSS) is a vulnerability in which a web application outputs user input into HTML as is, so a script contained in the input runs in visitors' browsers as part of the page. Because the script runs as a page of that site, it may steal the visitor's session information (cookies) or display fake input fields. The fundamental countermeasure is to escape characters with special meaning, such as <, >, & and quotation marks, according to where they are output (for example, converting < to &lt;) so they are displayed as plain characters. Supplementary measures include giving cookies the HttpOnly attribute so scripts cannot read them, and restricting which scripts may run with a Content Security Policy. HTTPS protects the communication channel and cannot prevent a script embedded in a legitimate page from running.

  • A. Scripts running in the browser is not SQL injection, and lengthening the connection password is irrelevant.
  • B. Correct. The cause is outputting input as is, so escaping on output is the fundamental countermeasure.
  • C. The name is correct, but HTTPS protects the communication channel and cannot stop a script embedded in a legitimate page from running.
Practice this topic Back to topic

Related calculators

Books on Information Security Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Information Security Basics questions

  1. A web application has a vulnerability in which, if a logged-in user opens a trap page prepared by an attacker, the user's browser sends requests to the legitimate site that the user did not intend, such as transferring money or changing settings. Which is an appropriate countermeasure?
  2. A web application reads and displays a file by joining a file name given in a URL parameter to the name of its public folder. If a value containing ../ is given as the file name, configuration files and other files outside the public folder can be read. Which combination correctly gives the name of this attack and a countermeasure?
  3. If a web application keeps using the same session ID before and after login, an attacker may get the user to use a session ID the attacker prepared in advance and then, after the user logs in, impersonate the user with that ID. What is the most appropriate countermeasure against this attack?
  4. Which statement correctly describes a DDoS attack?
  5. Which statement correctly describes a zero-day attack?