JavaScript Security Best Practices

Learn about preventing XSS,CSRF,and handling sensitive data in JS/TS.

1. Which of the following is a primary method to prevent Cross-Site Scripting (XSS) attacks in JavaScript?
2. Which of the following are secure practices for handling user authentication in JavaScript? (Select all that apply)
3. The 'SameSite' cookie attribute helps mitigate Cross-Site Request Forgery (CSRF) attacks.
4. What does CSP stand for in the context of web security?
5. What is the primary risk of using 'eval()' in JavaScript with untrusted input?
6. Which JavaScript functions are considered unsafe due to potential code injection risks? (Select all that apply)
7. Storing sensitive information like API keys in localStorage is secure because localStorage is only accessible client-side.
8. What HTTP response header specifies which origins are allowed to access a resource, as part of CORS?
9. Which CSP directive restricts the sources from which JavaScript scripts can be loaded?
10. How can DOM-based XSS attacks be mitigated? (Select all that apply)
11. Enabling 'use strict' in JavaScript helps prevent security vulnerabilities by catching unsafe coding practices.
12. What term describes an attack where malicious scripts are injected into web pages viewed by other users?
13. Which npm command identifies security vulnerabilities in installed dependencies?
14. Which are secure practices for form submissions in client-side JavaScript? (Select all that apply)
15. DOM-based XSS occurs when untrusted data is reflected in the DOM without sanitization, processed by client-side JS.
16. What cookie attribute prevents access to the cookie via client-side JavaScript?
17. What is the purpose of Subresource Integrity (SRI) in JavaScript?
18. Which should never be exposed in client-side JavaScript? (Select all that apply)
19. Using 'SameSite=Strict' for cookies allows the cookie to be sent in cross-site requests, enhancing usability.
20. What security practice involves regularly scanning and updating third-party libraries to fix vulnerabilities?
Answered 0 of 0 — 0 correct