Initialization parameters for a servlet are configured in the _________ file.
- config.xml
- initparams.xml
- servlet.xml
- web.xml
Initialization parameters for a servlet are configured in the web.xml file.
What is the significance of using HttpOnly cookies in the context of XSS prevention?
- They are encrypted during transmission
- They can only be accessed via HTTP
- They cannot be accessed by JavaScript
- They have a longer expiration time
HttpOnly cookies cannot be accessed by JavaScript, making them more secure against XSS attacks as malicious scripts won't have access to sensitive cookie information.
What is the key difference between Stored XSS and Reflected XSS attacks?
- Reflected XSS involves non-persistent injection
- Reflected XSS targets the client-side
- Stored XSS involves persistent injection
- Stored XSS targets the server-side
Stored XSS involves the injection of malicious scripts that persist on the target, whereas Reflected XSS involves non-persistent injection and reflects the payload back to the user.
How can input sanitization be ineffective against certain advanced XSS attacks?
- By encoding payloads
- By exploiting browser vulnerabilities
- By using Content Security Policy (CSP)
- By using client-side validation
Advanced XSS attacks may bypass input sanitization through techniques like exploiting browser vulnerabilities, making sanitization ineffective in preventing such attacks.
Describe the role of Subresource Integrity (SRI) in preventing XSS attacks.
- Encrypts sensitive user information
- Enforces Same-Origin Policy
- Ensures secure transmission of data
- Validates and verifies external scripts
Subresource Integrity (SRI) is a security feature that helps prevent XSS attacks by ensuring the integrity of external scripts, validating and verifying that they haven't been tampered with.
To prevent XSS attacks, it is essential to _________ user input and _________ user output.
- decode
- encode
- sanitize
- validate
To prevent XSS attacks, it is essential to sanitize user input and encode user output. Sanitizing helps remove potentially harmful content, and encoding ensures that user data is displayed correctly and safely in the browser.
_________ 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.