How do you set a response header to indicate the content should be downloaded as a file?

  • response.setHeader("Content-Disposition", "attachment; filename=example.txt");
  • response.setHeader("Content-Encoding", "gzip");
  • response.setHeader("Content-Transfer-Encoding", "binary");
  • response.setHeader("Content-Type", "application/octet-stream");
To indicate that the content should be downloaded as a file, you can use the response.setHeader("Content-Disposition", "attachment; filename=example.txt"); method.

In the context of XSS prevention, what does the acronym CSP stand for?

  • Content-Security-Policy
  • Content-Security-Protocol
  • Cookie-Security-Protocol
  • Cross-Site Policy
In the context of XSS prevention, CSP stands for Content-Security-Policy. It is a security header that helps prevent XSS attacks by specifying which content can be executed on a web page.

Which JavaScript framework automatically escapes output to prevent XSS attacks?

  • AngularJS
  • React
  • Vue.js
  • jQuery
AngularJS automatically escapes output to prevent XSS attacks by default, helping developers build more secure web applications.

How does a Content Security Policy (CSP) help in preventing XSS attacks?

  • It allows only inline scripts
  • It encrypts the communication
  • It filters HTTP headers
  • It restricts the sources of content
A Content Security Policy (CSP) helps prevent XSS attacks by restricting the sources of content, reducing the risk of malicious script execution from unauthorized sources.

To maintain a separation of concerns, servlets in MVC should not directly manipulate the __________.

  • Controller
  • Database
  • Model
  • View
To maintain a separation of concerns, servlets in MVC should not directly manipulate the Controller.

_________ is a security standard that prevents the browser from interpreting user input as script.

  • CORS
  • CSP
  • CSRF
  • HTTPS
Content Security Policy (CSP) is a security standard that prevents the browser from interpreting user input as a script. It helps mitigate the risk of XSS attacks by defining and enforcing a set of rules for how resources should be loaded on a web page.

When implementing CSP, the _________ directive is crucial in restricting resources the page can load.

  • connect-src
  • img-src
  • script-src
  • style-src
When implementing CSP, the connect-src directive is crucial in restricting resources the page can load. It controls which URLs the document is allowed to make requests to, helping prevent unwanted network requests that could pose security risks.

In an XSS attack, the _________ method of XSS involves the attacker injecting a script that is stored on the server.

  • DOM-based
  • Persistent
  • Reflected
  • Stored
In a stored XSS attack, the injected script is stored on the server and served to users, making it more dangerous.

_________ encoding is a common technique to prevent XSS by converting special characters into HTML entities.

  • Base64
  • HTML
  • URL
  • UTF-8
HTML encoding is a common technique to prevent XSS by converting special characters into HTML entities, making it difficult for attackers to inject malicious scripts.

To mitigate DOM-based XSS attacks, one should avoid using _________ directly with user input.

  • document.write()
  • getElementById()
  • innerHTML
  • setAttribute()
Mitigating DOM-based XSS involves avoiding direct use of the innerHTML property with user input, as it can be exploited to execute malicious scripts within the DOM.