<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Cross Site Scripting (XSS) - Cyber Security				            </title>
            <link>https://www.hacktheforum.com/cyber-security/cross-site-scripting-xss/</link>
            <description>Hack The Forum Discussion Board</description>
            <language>en</language>
            <lastBuildDate>Sat, 18 Apr 2026 18:15:20 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>Cross Site Scripting (XSS)</title>
                        <link>https://www.hacktheforum.com/cyber-security/cross-site-scripting-xss/#post-19900</link>
                        <pubDate>Mon, 27 Oct 2025 16:58:14 +0000</pubDate>
                        <description><![CDATA[XSS is a broad class of web application vulnerabilities where an attacker injects attacker-controlled script (usually JavaScript) into pages viewed by other users. That script runs in the vi...]]></description>
                        <content:encoded><![CDATA[<p>XSS is a broad class of web application vulnerabilities where an attacker injects attacker-controlled script (usually JavaScript) into pages viewed by other users. That script runs in the victim’s browser with the site’s origin privileges and can steal cookies/session tokens, perform actions on behalf of the user, or modify page content.</p>
<h2 data-start="405" data-end="420"><span style="font-size: 12pt">Types of XSS</span></h2>
<ol data-start="421" data-end="1053">
<li data-start="421" data-end="633">
<p data-start="424" data-end="633"><strong data-start="424" data-end="454">Reflected (non-persistent)</strong><br data-start="454" data-end="457" />Malicious input is embedded in a URL or request and immediately reflected in the server response (e.g., search results, error message). Usually exploited via a crafted link.</p>
</li>
<li data-start="635" data-end="830">
<p data-start="638" data-end="830"><strong data-start="638" data-end="661">Stored (persistent)</strong><br data-start="661" data-end="664" />Attacker input is saved server-side (comments, profile fields, message boards) and served to other users later — more dangerous because it can affect many victims.</p>
</li>
<li data-start="832" data-end="1053">
<p data-start="835" data-end="1053"><strong data-start="835" data-end="848">DOM-based</strong><br data-start="848" data-end="851" />The vulnerability exists in client-side code: JavaScript reads user-controlled data (URL fragment, query, or window.location) and writes it into the DOM unsafely. No server-side reflection necessary.</p>
</li>
</ol>
<h2 data-start="1699" data-end="1741">Core defenses (high level, prioritized)</h2>
<ol data-start="1742" data-end="3120">
<li data-start="1742" data-end="2135">
<p data-start="1745" data-end="1919"><strong data-start="1745" data-end="1773">Output encoding/escaping</strong> — Always encode user data for the context where it’s inserted: HTML body, attribute, URL, JavaScript, or CSS contexts. Use established libraries.</p>
<ul data-start="1923" data-end="2135">
<li data-start="1923" data-end="1984">
<p data-start="1925" data-end="1984">HTML body: escape <code data-start="1943" data-end="1946">&lt;</code>, <code data-start="1948" data-end="1951">&gt;</code>, <code data-start="1953" data-end="1956">&amp;</code>, <code data-start="1958" data-end="1961">"</code> and <code data-start="1966" data-end="1969">'</code> (as required).</p>
</li>
<li data-start="1988" data-end="2063">
<p data-start="1990" data-end="2063">HTML attribute: additionally encode quotes and handle attribute contexts.</p>
</li>
<li data-start="2067" data-end="2135">
<p data-start="2069" data-end="2135">JavaScript context: use safe APIs instead of string concatenation.</p>
</li>
</ul>
</li>
<li data-start="2136" data-end="2396">
<p data-start="2139" data-end="2396"><strong data-start="2139" data-end="2197">Use safe templating frameworks / avoid raw <code data-start="2184" data-end="2195">innerHTML</code></strong><br data-start="2197" data-end="2200" />Frameworks and templating engines that auto-escape (React, Angular, Twig, Mustache) reduce risk. When you must insert HTML, sanitize it with a well-maintained sanitizer (DOMPurify for browser).</p>
</li>
<li data-start="2397" data-end="2614">
<p data-start="2400" data-end="2614"><strong data-start="2400" data-end="2433">Content Security Policy (CSP)</strong><br data-start="2433" data-end="2436" />A strong CSP (e.g., disallow inline scripts, specify script-src) mitigates impact by blocking inline/external scripts. CSP is defense-in-depth, not a replacement for escaping.</p>
</li>
<li data-start="2615" data-end="2766">
<p data-start="2618" data-end="2766"><strong data-start="2618" data-end="2648">HTTP-only &amp; Secure cookies</strong><br data-start="2648" data-end="2651" /><code data-start="2654" data-end="2664">HttpOnly</code> prevents client JavaScript from reading cookie values; <code data-start="2720" data-end="2728">Secure</code> ensures cookies sent only over HTTPS.</p>
</li>
<li data-start="2767" data-end="2974">
<p data-start="2770" data-end="2974"><strong data-start="2770" data-end="2805">Input validation (as secondary)</strong><br data-start="2805" data-end="2808" />Validate input shape and length (whitelisting where appropriate). But <strong data-start="2881" data-end="2891">do not</strong> rely on input validation alone for XSS prevention — escaping on output is primary.</p>
</li>
<li data-start="2975" data-end="3120">
<p data-start="2978" data-end="3120"><strong data-start="2978" data-end="3002">Avoid dangerous APIs</strong><br data-start="3002" data-end="3005" />Avoid <code data-start="3014" data-end="3020">eval</code>, <code data-start="3022" data-end="3038">new Function()</code>, <code data-start="3040" data-end="3051">innerHTML</code> with untrusted strings, <code data-start="3076" data-end="3092">document.write</code>, <code data-start="3094" data-end="3114">setTimeout(string)</code>, etc.</p>
</li>
</ol>]]></content:encoded>
						                            <category domain="https://www.hacktheforum.com/cyber-security/">Cyber Security</category>                        <dc:creator>kajal</dc:creator>
                        <guid isPermaLink="true">https://www.hacktheforum.com/cyber-security/cross-site-scripting-xss/#post-19900</guid>
                    </item>
							        </channel>
        </rss>
		