All quizzesEasy
Common Vulnerabilities
Preview — 3 of 10 questions
What best describes Cross-Site Scripting (XSS)?
javascript
// Dangerous! User input is directly inserted into HTML
const userComment = getUserInput();
document.getElementById("comments").innerHTML = userComment;
// If user enters: <script>alert('Hacked!')</script>
// The script will execute!AA vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users.
BA method for securely executing JavaScript code.
CA technique for preventing SQL injection attacks.
DA way to optimize JavaScript performance.
Which method is safest for inserting user content into a web page?
javascript
const userComment = getUserInput();
element.textContent = userComment; // Safe! Treats as text onlyAelement.innerHTML = userInput;
Belement.textContent = userInput;
CUsing eval() with user input.
Delement.outerHTML = userInput;
What is Cross-Site Request Forgery (CSRF)?
javascript
<form method="POST" action="/transfer">
<!-- CSRF token prevents unauthorized requests -->
<input type="hidden" name="csrf_token" value="unique-token-xyz">
<input type="text" name="amount">
<button type="submit">Transfer</button>
</form>AAn attack where a hacker steals user passwords.
BAn attack where a hacker tricks a user into performing unwanted actions on another website where they're logged in.
CA method to encrypt data in transit.
DA technique for optimizing API requests.
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.