nerdexam
CompTIA

CS0-003 · Question #385

A security analyst found the following vulnerability on the company's website: <INPUT TYPE="IMAGE" SRC="javascript:alert(`test');"> Which of the following should be implemented to prevent this type…

The correct answer is A. Input sanitization. This is a type of web application vulnerability called cross-site scripting (XSS), which allows an attacker to inject malicious code into a web page that is viewed by other users. XSS can be used to steal cookies, session tokens, credentials, or other sensitive information, or…

Submitted by weili_xi· Mar 6, 2026Vulnerability Management

Question

A security analyst found the following vulnerability on the company's website:

<INPUT TYPE="IMAGE" SRC="javascript:alert(`test');"> Which of the following should be implemented to prevent this type of attack in the future?

Options

  • AInput sanitization
  • BOutput encoding
  • CCode obfuscation
  • DPrepared statements

How the community answered

(60 responses)
  • A
    88% (53)
  • B
    2% (1)
  • C
    3% (2)
  • D
    7% (4)

Explanation

This is a type of web application vulnerability called cross-site scripting (XSS), which allows an attacker to inject malicious code into a web page that is viewed by other users. XSS can be used to steal cookies, session tokens, credentials, or other sensitive information, or to perform actions on behalf of the victim. Input sanitization is a technique that prevents XSS attacks by checking and filtering the user input before processing it. Input sanitization can remove or encode any characters or strings that may be interpreted as code by the browser, such as <, >, ", ', or javascript:. Input sanitization can also validate the input against a predefined format or range of values, and reject any input that does not match. Output encoding is a technique that prevents XSS attacks by encoding the output before sending it to the browser. Output encoding can convert any characters or strings that may be interpreted as code by the browser into harmless entities, such as <, >, ", ', or javascript:. Output encoding can also escape any special characters that may have a different meaning in different contexts, such as , /, or ;. Code obfuscation is a technique that makes the source code of a web application more difficult to read and understand by humans. Code obfuscation can use techniques such as renaming variables and functions, removing comments and whitespace, replacing literals with expressions, or adding dummy code. Code obfuscation can help protect the intellectual property and trade secrets of a web application, but it does not prevent XSS attacks.

Topics

#XSS#input sanitization#web security#vulnerability remediation

Community Discussion

No community discussion yet for this question.

Full CS0-003 Practice