{"id":53383,"date":"2014-07-14T08:03:54","date_gmt":"2014-07-14T08:03:54","guid":{"rendered":"https:\/\/www.checkmarx.com\/?post_type=glossary&#038;p=8773"},"modified":"2026-04-10T17:59:07","modified_gmt":"2026-04-10T15:59:07","slug":"cross-site-scripting-xss-attacks","status":"publish","type":"glossary","link":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/","title":{"rendered":"Cross-Site Scripting (XSS) Attacks: Types, Examples &amp; Prevention"},"content":{"rendered":"<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-1\"><strong>Definition (developer\u2011friendly)<\/strong><\/h2>\n\n\n\n<p>Cross\u2011site scripting (XSS) is a client\u2011side injection flaw where untrusted input is rendered in the browser without proper contextual output encoding or policy controls, allowing attacker\u2011supplied scripts to execute in a victim\u2019s session. That execution can hijack sessions, alter DOM, exfiltrate data, or pivot to additional attacks.<\/p>\n\n\n\n<p>&nbsp;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png\" alt=\"Cross-Site Scripting (XSS) Attack Example\" class=\"wp-image-95383\"><figcaption class=\"wp-element-caption\">Cross-Site Scripting (XSS) Attack Example<\/figcaption><\/figure>\n<\/div>\n\n\n<p><span style=\"color: #333333;\"><\/span><wp-block data-block=\"core\/more\"><\/wp-block><b><\/b><\/p>\n\n\n\n<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-2\">How XSS works (and why Devs still hit it)<\/h2>\n\n\n\n<p>IAt a high level, XSS happens when data from a request, database, message queue, template, or third\u2011party library reaches a <strong>dangerous sink<\/strong> (e.g., <code>innerHTML<\/code>, inline event handlers, <code>document.write<\/code>, JS string concatenation inside <code>&lt;script&gt;<\/code>, or URL\/attribute contexts) without context\u2011appropriate encoding. Common XSS classes: <strong>Reflected<\/strong> (non\u2011persistent), <strong>Stored<\/strong> (persistent), and <strong>DOM\u2011based<\/strong> (client\u2011side routing\/DOM manipulation).<\/p>\n\n\n\n<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-3\">Types of XSS (with quick developer cues)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Reflected XSS<\/strong><\/h3>\n\n\n\n<p><br><em>Symptom:<\/em> Unsanitized input reflected immediately in a response.<br><em>Where it hides:<\/em> Search results, error messages, query\u2011param echoes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Stored XSS<\/strong><\/h3>\n\n\n\n<p><br><em>Symptom:<\/em> Payload persists in data stores and is served later to other users.<br><em>Where it hides:<\/em> Comments, user profiles, CMS fields, issue descriptions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>DOM\u2011based XSS<\/strong><\/h3>\n\n\n\n<p><br><em>Symptom:<\/em> Client\u2011side code reads untrusted data and injects it into the DOM or JS context at runtime (no server\u2011side template involvement).<br><em>Where it hides:<\/em> SPA routers, client\u2011side templating, ad hoc DOM updates.<\/p>\n\n\n\n<p><br><strong>Harden with CSP and Trusted Types<\/strong> to break common DOM injection paths.<\/p>\n\n\n\n<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-4\">Preventing XSS (defense\u2011in\u2011depth)<\/h2>\n\n\n\n<p><strong>1) Encode on output (by context).<\/strong><br>Always apply context\u2011aware encoding for HTML body, attribute, URL, CSS, and JS contexts &#8211; ideally via your framework\u2019s auto\u2011escaping. Avoid blacklist \u201cfilters.\u201d Encode late (right before render).<\/p>\n\n\n\n<p><strong>2) Prefer safe DOM APIs.<\/strong><br>Use <code>textContent<\/code>\/<code>setAttribute<\/code> over <code>innerHTML<\/code>, avoid inline event handlers, and never concatenate untrusted data into <code>&lt;script&gt;<\/code> blocks. For rich HTML, use a vetted sanitizer and keep allowed tags minimal.<\/p>\n\n\n\n<p><strong>3) Enforce <strong>Content Security Policy (CSP)<\/strong>.<\/strong><br>Start with <code>default-src 'self'<\/code>, forbid <code>unsafe-inline<\/code> by using nonces\/hashes, and disable legacy features like <code>object-src 'none'<\/code>. CSP drastically reduces the blast radius of missed encodings and blocks many injected scripts.<\/p>\n\n\n\n<p><strong>4) Add <strong>Trusted Types<\/strong> for DOM XSS.<\/strong><br>Trusted Types block assignments to risky sinks (e.g., <code>innerHTML<\/code>) unless values come from a registered policy. Combine with CSP\u2019s <code>require-trusted-types-for 'script'<\/code> to stop entire classes of DOM\u2011based XSS.<\/p>\n\n\n\n<p><strong>5) Harden cookies &amp; session handling.<\/strong><br>Use <code>HttpOnly<\/code>, <code>Secure<\/code>, and <code>SameSite<\/code> cookies to limit token theft paths; pair with short\u2011lived tokens and strict authorization checks. (Best practice that complements CSP\/encoding.)<\/p>\n\n\n\n<p><strong>6) Test continuously across SDLC.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\n<a href=\"https:\/\/checkmarx.com\/cxsast-source-code-scanning\/\"><strong>SAST<\/strong> <\/a>finds server\u2011 and client\u2011side flows that route untrusted input to XSS sinks before runtime.<\/li>\n\n\n\n<li>\n<a href=\"https:\/\/checkmarx.com\/checkmarx-dast\/\"><strong>DAST<\/strong> <\/a>exercises the running app to uncover exploitable XSS in real environments (including auth\u2019d areas and APIs).<br><br>Combining both yields the best coverage.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-5\">Code snippets (pragmatic examples)<\/h2>\n\n\n\n<p><strong>Safer DOM updates (browser)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u274c Avoid\nnode.innerHTML = userInput;\n\n\/\/ \u2705 Do\nnode.textContent = userInput; \/\/ encodes by design\n<\/code><\/pre>\n\n\n\n<p><strong>CSP + Trusted Types headers (Node\/Express with Helmet)<\/strong><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import helmet from \"helmet\";\nimport express from \"express\";\nconst app = express();\n\napp.use(\n  helmet({\n    contentSecurityPolicy: {\n      useDefaults: true,\n      directives: {\n        \"default-src\": &#91;\"'self'\"],\n        \"script-src\": &#91;\"'self'\"],      \/\/ add nonces\/hashes for inline scripts if needed\n        \"object-src\": &#91;\"'none'\"],\n        \"base-uri\": &#91;\"'self'\"],\n        \"frame-ancestors\": &#91;\"'none'\"],\n        \"require-trusted-types-for\": &#91;\"'script'\"],\n        \"trusted-types\": &#91;\"app-policy\"] \/\/ define policy in the client\n      },\n    },\n  })\n);\n<\/code><\/pre>\n\n\n\n<p>On the client, register a <strong>Trusted Types<\/strong> policy and ensure any HTML creation routes through it. Pair with CSP nonces\/hashes to remove <code>unsafe-inline<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-6\">How Checkmarx helps reduce XSS risk<\/h2>\n\n\n\n<p><br><strong>See Cross Site Scripting (XSS) Cheat Sheet, Attack Examples &amp; Protection at <a href=\"https:\/\/devhub.checkmarx.com\/advisories\/\">Vulnerability Knowledge Base<\/a>.<\/strong><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<ul class=\"wp-block-list\">\n<li>\n<strong>SAST<\/strong> (Static Application Security Testing) to catch XSS flows as code is written\u2014across languages, frameworks, and templates. \u2192 <em>See:<\/em> <strong><a href=\"https:\/\/checkmarx.com\/learn\/sast\/static-application-security-testing-sast\/\">Static Application Security Testing (SAST)<\/a><\/strong> (glossary) and <strong><a href=\"https:\/\/checkmarx.com\/cxsast-source-code-scanning\/\">Checkmarx SAST Engine<\/a><\/strong>.<\/li>\n\n\n\n<li>\n\n\n\n<\/li>\n<li>\n<strong>DAST<\/strong> (Dynamic Application Security Testing) to validate exploitability in staging or pre\u2011prod, including auth flows and APIs. \u2192 <em>See:<\/em> <strong><a href=\"https:\/\/checkmarx.com\/cxsast-source-code-scanning\/\">Checkmarx DAST<\/a><\/strong> (product) and docs.<\/li>\n\n\n\n<li>\n\n\n\n<\/li>\n<li>\n<strong>SCA<\/strong> to flag vulnerable JS\/templating libraries that can re\u2011introduce XSS class bugs (e.g., DOM sanitizers, widgets). \u2192 <em>See:<\/em> <strong><a href=\"https:\/\/checkmarx.com\/cxsca-open-source-scanning\/\">Checkmarx SCA<\/a><\/strong>.<\/li>\n\n\n\n<li>\n\n\n\n<\/li>\n<li>\n<strong>Secrets Detection<\/strong> to prevent leaked tokens that magnify the impact of XSS session hijacking. \u2192 <em>See:<\/em> <strong><a href=\"https:\/\/checkmarx.com\/product\/secrets-detection\/\">Secrets Detection<\/a><\/strong>.<\/li>\n\n\n\n<li>\n\n\n\n<\/li>\n<li>\n<strong>Codebashing<\/strong> developer training with hands\u2011on lessons covering XSS and secure patterns. \u2192 <em>See:<\/em> <strong><a href=\"https:\/\/checkmarx.com\/product\/codebashing-secure-code-training\/\">Codebashing<\/a><\/strong>.<\/li>\n\n\n\n<li>\n\n\n\n<\/li>\n<li>\n<strong>Checkmarx One<\/strong> unifies these in a single platform for shared policies, results, and governance. \u2192 <em>See:<\/em> <a href=\"https:\/\/checkmarx.com\/product\/application-security-platform\/\"><strong>Checkmarx One<\/strong>.<\/a>\n<\/li>\n\n\n\n<li>\n<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading article-anchor\" id=\"article-anchor-7\">Quick XSS FAQ<\/h2>\n\n\n\n<section class=\"section-faq js--gsap-faq light-theme\">\n    <div class=\"main-wrapper\">\n        <h2 class=\"section-faq__title js--gsap-faq-title article-anchor\" id=\"article-anchor-8\">Quick XSS FAQ<\/h2>\n        <ul class=\"section-faq__wrapper js--faq-wrapper\">\n                            <li class=\"section-faq__item js--faq-item js--gsap-faq-item\">\n                    <button class=\"section-faq__btn js--faq-btn\">\n                        <span class=\"section-faq__btn-span\">Is CSP alone enough to stop XSS?<\/span>                        <svg viewbox=\"0 0 10 10\" fill=\"none\" class=\"section-faq__btn-icon\" stroke=\"currentColor\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <path d=\"M0.40625 5.04883H9.23256\" stroke-width=\"1.52413\"><\/path>\n                            <path d=\"M4.82031 0.632812L4.82031 9.45912\" stroke-width=\"1.52413\"><\/path>\n                        <\/svg>\n                    <\/button>\n                    <p class=\"section-faq__body text_1 js--faq-body\">No. CSP reduces exploitability and provides telemetry, but you still need strict output encoding and safe DOM APIs. Combine CSP with Trusted Types for DOM\u2011based XSS.<\/p>                <\/li>\n                                <li class=\"section-faq__item js--faq-item js--gsap-faq-item\">\n                    <button class=\"section-faq__btn js--faq-btn\">\n                        <span class=\"section-faq__btn-span\">What\u2019s the fastest first fix for a DOM XSS hotspot?<\/span>                        <svg viewbox=\"0 0 10 10\" fill=\"none\" class=\"section-faq__btn-icon\" stroke=\"currentColor\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <path d=\"M0.40625 5.04883H9.23256\" stroke-width=\"1.52413\"><\/path>\n                            <path d=\"M4.82031 0.632812L4.82031 9.45912\" stroke-width=\"1.52413\"><\/path>\n                        <\/svg>\n                    <\/button>\n                    <p class=\"section-faq__body text_1 js--faq-body\">Replace innerHTML with textContent (or a framework\u2019s auto\u2011escaping render) and move any unavoidable HTML generation behind a Trusted Types policy.<\/p>                <\/li>\n                                <li class=\"section-faq__item js--faq-item js--gsap-faq-item\">\n                    <button class=\"section-faq__btn js--faq-btn\">\n                        <span class=\"section-faq__btn-span\">Which tests should run in CI?<\/span>                        <svg viewbox=\"0 0 10 10\" fill=\"none\" class=\"section-faq__btn-icon\" stroke=\"currentColor\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                            <path d=\"M0.40625 5.04883H9.23256\" stroke-width=\"1.52413\"><\/path>\n                            <path d=\"M4.82031 0.632812L4.82031 9.45912\" stroke-width=\"1.52413\"><\/path>\n                        <\/svg>\n                    <\/button>\n                    <p class=\"section-faq__body text_1 js--faq-body\">Run SAST on every PR and scheduled full scans; run DAST against test\/stage pre\u2011release; track open\u2011source exposure with SCA continuously.<\/p>                <\/li>\n                        <\/ul>\n    <\/div>\n<\/section>\n\n<script type=\"application\/ld+json\">{\"@context\":\"https:\/\/schema.org\",\"@type\":\"FAQPage\",\"url\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"Is CSP alone enough to stop XSS?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. CSP reduces exploitability and provides telemetry, but you still need strict output encoding and safe DOM APIs. Combine CSP with Trusted Types for DOM\u2011based XSS.\"}},{\"@type\":\"Question\",\"name\":\"What\u2019s the fastest first fix for a DOM XSS hotspot?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Replace innerHTML with textContent (or a framework\u2019s auto\u2011escaping render) and move any unavoidable HTML generation behind a Trusted Types policy.\"}},{\"@type\":\"Question\",\"name\":\"Which tests should run in CI?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Run SAST on every PR and scheduled full scans; run DAST against test\/stage pre\u2011release; track open\u2011source exposure with SCA continuously.\"}}]}<\/script>\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Definition (developer\u2011friendly) Cross\u2011site scripting (XSS) is a client\u2011side injection flaw where untrusted input is rendered in the browser without proper contextual output encoding or policy controls, allowing attacker\u2011supplied scripts to execute in a victim\u2019s session. That execution can hijack sessions, alter DOM, exfiltrate data, or pivot to additional attacks. &nbsp; How XSS works (and why [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"template":"","glossary-tags":[],"class_list":["post-53383","glossary","type-glossary","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Cross\u2011Site Scripting (XSS): Types &amp; Prevention - Checkmarx<\/title>\n<meta name=\"description\" content=\"Understand cross\u2011site scripting (XSS)\u2014reflected, stored, and DOM\u2011based\u2014and prevent it with output encoding, CSP, Trusted Types, and SAST\/DAST. Developer\u2011first guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cross\u2011Site Scripting (XSS): Types &amp; Prevention - Checkmarx\" \/>\n<meta property=\"og:description\" content=\"Understand cross\u2011site scripting (XSS)\u2014reflected, stored, and DOM\u2011based\u2014and prevent it with output encoding, CSP, Trusted Types, and SAST\/DAST. Developer\u2011first guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/\" \/>\n<meta property=\"og:site_name\" content=\"Checkmarx\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-10T15:59:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@checkmarx\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/\",\"url\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/\",\"name\":\"Cross\u2011Site Scripting (XSS): Types & Prevention - Checkmarx\",\"isPartOf\":{\"@id\":\"https:\/\/checkmarx.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png\",\"datePublished\":\"2014-07-14T08:03:54+00:00\",\"dateModified\":\"2026-04-10T15:59:07+00:00\",\"description\":\"Understand cross\u2011site scripting (XSS)\u2014reflected, stored, and DOM\u2011based\u2014and prevent it with output encoding, CSP, Trusted Types, and SAST\/DAST. Developer\u2011first guide.\",\"breadcrumb\":{\"@id\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#primaryimage\",\"url\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png\",\"contentUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Glossary\",\"item\":\"https:\/\/checkmarx.com\/glossary\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cross-Site Scripting (XSS) Attacks: Types, Examples &amp; Prevention\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/checkmarx.com\/#website\",\"url\":\"https:\/\/checkmarx.com\/\",\"name\":\"Checkmarx\",\"description\":\"The world runs on code. We secure it.\",\"publisher\":{\"@id\":\"https:\/\/checkmarx.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/checkmarx.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/checkmarx.com\/#organization\",\"name\":\"Checkmarx\",\"url\":\"https:\/\/checkmarx.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg\",\"contentUrl\":\"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg\",\"width\":1,\"height\":1,\"caption\":\"Checkmarx\"},\"image\":{\"@id\":\"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis\",\"https:\/\/x.com\/checkmarx\",\"https:\/\/www.youtube.com\/user\/CheckmarxResearchLab\",\"https:\/\/www.linkedin.com\/company\/checkmarx\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cross\u2011Site Scripting (XSS): Types & Prevention - Checkmarx","description":"Understand cross\u2011site scripting (XSS)\u2014reflected, stored, and DOM\u2011based\u2014and prevent it with output encoding, CSP, Trusted Types, and SAST\/DAST. Developer\u2011first guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/","og_locale":"en_US","og_type":"article","og_title":"Cross\u2011Site Scripting (XSS): Types & Prevention - Checkmarx","og_description":"Understand cross\u2011site scripting (XSS)\u2014reflected, stored, and DOM\u2011based\u2014and prevent it with output encoding, CSP, Trusted Types, and SAST\/DAST. Developer\u2011first guide.","og_url":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/","og_site_name":"Checkmarx","article_publisher":"https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis","article_modified_time":"2026-04-10T15:59:07+00:00","og_image":[{"url":"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@checkmarx","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/","url":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/","name":"Cross\u2011Site Scripting (XSS): Types & Prevention - Checkmarx","isPartOf":{"@id":"https:\/\/checkmarx.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#primaryimage"},"image":{"@id":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#primaryimage"},"thumbnailUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png","datePublished":"2014-07-14T08:03:54+00:00","dateModified":"2026-04-10T15:59:07+00:00","description":"Understand cross\u2011site scripting (XSS)\u2014reflected, stored, and DOM\u2011based\u2014and prevent it with output encoding, CSP, Trusted Types, and SAST\/DAST. Developer\u2011first guide.","breadcrumb":{"@id":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#primaryimage","url":"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png","contentUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2021\/06\/Picture1-2.png"},{"@type":"BreadcrumbList","@id":"https:\/\/checkmarx.com\/glossary\/cross-site-scripting-xss-attacks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Glossary","item":"https:\/\/checkmarx.com\/glossary\/"},{"@type":"ListItem","position":2,"name":"Cross-Site Scripting (XSS) Attacks: Types, Examples &amp; Prevention"}]},{"@type":"WebSite","@id":"https:\/\/checkmarx.com\/#website","url":"https:\/\/checkmarx.com\/","name":"Checkmarx","description":"The world runs on code. We secure it.","publisher":{"@id":"https:\/\/checkmarx.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/checkmarx.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/checkmarx.com\/#organization","name":"Checkmarx","url":"https:\/\/checkmarx.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/","url":"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg","contentUrl":"https:\/\/checkmarx.com\/wp-content\/uploads\/2024\/02\/logo-dark.svg","width":1,"height":1,"caption":"Checkmarx"},"image":{"@id":"https:\/\/checkmarx.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Checkmarx.Source.Code.Analysis","https:\/\/x.com\/checkmarx","https:\/\/www.youtube.com\/user\/CheckmarxResearchLab","https:\/\/www.linkedin.com\/company\/checkmarx"]}]}},"_links":{"self":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/glossary\/53383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/users\/11"}],"version-history":[{"count":0,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/glossary\/53383\/revisions"}],"wp:attachment":[{"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/media?parent=53383"}],"wp:term":[{"taxonomy":"glossary-tags","embeddable":true,"href":"https:\/\/checkmarx.com\/wp-json\/wp\/v2\/glossary-tags?post=53383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}