MugUp logoMugUp
HomeBrowseAboutBlog
LoginSign Up
MugUp

Plan your day, study, read, write and track your habits in one app.

Follow MugUp

Product

  • Features
  • Compare
  • Free Tools
  • Deck Library
  • MugUp for Discord

Community

  • Blog
  • Changelog
  • Feature Requests
  • Deck Requests

Company

  • Home
  • About
  • Contact

© 2026 MugUp. All rights reserved.

Terms of ServicePrivacy PolicyCookie Policy
  1. Browse decks
  2. Application Security: OWASP and Secure Coding
  3. Cross-Site Scripting and Content Security Policy
Public deck

Application Security: OWASP and Secure Coding

The common vulnerability classes in web applications and APIs, such as injection, XSS, CSRF, broken access control and SSRF, how each one works, and how to prevent it in code and in your build pipeline.

Engineering
AShared by Alex Chen
0PlaySign in to clone

You’re reading a free preview. Sign up to see every topic and question — and to play this deck as games.

See the whole deck

Cross-Site Scripting and Content Security Policy

How cross-site scripting gets script into a page, how output encoding and framework escaping stop it, and how a Content Security Policy limits the damage.

Play topicBack to deck

Content

36 total questions

MCQ: 9
Fill-in: 7
Flashcards: 11
Pair match: 9
Cross-Site Scripting and Content Security Policy – Flashcards
Flashcards

Card #1

Cross-site scripting (XSS)

Card #2

Stored XSS

Card #3

Reflected XSS

8 more questions in this game

Showing 3 of 11. Sign up free to see the rest.

Sign up freeLog in
Cross-Site Scripting and Content Security Policy – MCQ
Multiple Choice Questions
  1. 1. A React profile page renders each user's bio with dangerouslySetInnerHTML so that line breaks show. What risk does this add?

    • It turns off React's escaping for that value, so any HTML or script in the bio is inserted as markup
    • It makes React re-render the whole page on every keystroke, which can be used to slow the site down
    • It stores the bio in localStorage, where any other site open in the same browser can then read it
    • It sends the bio to the server unencrypted, so anyone on the network can change it while in transit
  2. 2. A server places a user value inside a JavaScript string in an inline script block and HTML-entity-encodes it first. What is the best fix?

    • Encode the value twice with HTML entities so the browser has to decode it twice before use
    • Serialise the value as JSON into a non-executing data element and read it from script
    • Move the whole inline script block lower in the page so it runs after the DOM has loaded
    • Convert the value to upper case so script keywords no longer match in the JavaScript engine
  3. 3. Users can set a website link on their profile, and the app HTML-encodes it before putting it in an href. What can still go wrong?

    • The link may be too long for the attribute and get cut off by the browser's parser
    • HTML encoding inside an href attribute stops the link from working in any browser
    • The link may point to a site without HTTPS, which lets it read the profile cookies
    • A javascript: URL still runs when clicked, so the scheme must be limited to http or https
6 more questions in this game

Showing 3 of 9. Sign up free to see the rest.

Sign up freeLog in
Cross-Site Scripting and Content Security Policy – Fill-in-the-blank
Fill in the Blank
  1. 1. In a CSP, the ___ directive limits where scripts may be loaded from.

    Answer:script-srcalso: script src, scriptsrc

    Hint: Named after the resource type plus "src".

  2. 2. The CSP directive ___ restricts the URLs that a page's forms can submit to.

    Answer:form-actionalso: form action

    Hint: Named after the form attribute that holds the target URL.

  3. 3. In Vue, the ___ directive inserts raw HTML and skips Vue's escaping.

    Answer:v-htmlalso: vhtml

    Hint: Vue directives start with v-.

4 more questions in this game

Showing 3 of 7. Sign up free to see the rest.

Sign up freeLog in
Cross-Site Scripting and Content Security Policy – Pair match
Pair Match
HTML body text↔Encode < > & as HTML entities
HTML attribute value↔Attribute-encode it and always quote the attribute
JavaScript string literal↔Escape with \xHH or \uXXXX sequences
6 more questions in this game

Showing 3 of 9. Sign up free to see the rest.

Sign up freeLog in