0
0
Cybersecurityknowledge~10 mins

Cross-site scripting (XSS) in Cybersecurity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the type of attack shown in the script.

Cybersecurity
alert('This is an example of [1] attack');
Drag options to blanks, or click blank then click option'
ASQL Injection
BPhishing
CCross-site scripting (XSS)
DDenial of Service
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing XSS with SQL Injection
Thinking this is a phishing attack
2fill in blank
medium

Complete the sentence to explain how XSS attacks occur.

Cybersecurity
XSS attacks happen when a website [1] user input without proper validation.
Drag options to blanks, or click blank then click option'
Aignores
Bfilters
Cencrypts
Ddisplays
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'filters' which would prevent XSS
Choosing 'encrypts' which is unrelated here
3fill in blank
hard

Complete the code that allows XSS by completing the blank.

Cybersecurity
document.getElementById('output').innerHTML = [1];
Drag options to blanks, or click blank then click option'
AuserInput
Bsanitize(userInput)
CescapeHTML(userInput)
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing sanitized versions which would fix the issue
Choosing null which would not display anything
4fill in blank
hard

Fill both blanks to create a safe way to display user input and prevent XSS.

Cybersecurity
const safeInput = [1](userInput);
document.getElementById('output').textContent = [2];
Drag options to blanks, or click blank then click option'
AescapeHTML
BsafeInput
CuserInput
Dsanitize
Attempts:
3 left
💡 Hint
Common Mistakes
Using innerHTML instead of textContent
Not processing the input before display
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters and safely processes user inputs to prevent XSS.

Cybersecurity
safeInputs = { [1]: [2] for user, input in inputs.items() if '[3]' not in input }
Drag options to blanks, or click blank then click option'
Auser
BescapeHTML(input)
C<script>
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Not escaping the input
Not filtering out dangerous tags