Skip to content
Sharp

Authentication · interview question

How can a developer prevent stored XSS in user-generated content?

Multiple choiceMediumchapter-17-curatedpremiumauthenticationjwt-signatures
Choose one answer
Answer and explanation

Correct answer

B. By encoding HTML entities before storage.

Why

Encoding HTML entities in user-generated content prevents stored XSS attacks by ensuring that any HTML or JavaScript code is not executed when the content is rendered in a browser.

Test yourself on Authentication

A free test with instant, explained results. No account needed.

Start free test
All Authentication questions →