<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>SpellBook</title>
    <link>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/</link>
    <description>Recent content on SpellBook</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title></title>
      <link>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/content-security-policies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/content-security-policies/</guid>
      <description>&lt;h2 id=&#34;content-security-policies&#34;&gt;Content Security Policies&lt;a class=&#34;anchor&#34; href=&#34;#content-security-policies&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;A CSP:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Is configured in the &lt;code&gt;Content-Security-Policy&lt;/code&gt; response header&lt;/li&gt;&#xA;&lt;li&gt;Consists of multiple directives. Each directive allows one or more values.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;For instance, the &lt;code&gt;script-src&lt;/code&gt; directive defines where JavaScript can be loaded and executed from:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-http&#34; data-lang=&#34;http&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;Content-Security-Policy: script-src &amp;#39;self&amp;#39; https://benignsite.htb&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This CSP instructs the browser to load JavaScript only from the same origin as the page itself and the external origin &lt;code&gt;https://benignsite.htb&lt;/code&gt;. Therefore, if an attacker injects the following JavaScript code in an XSS payload, the victim&amp;rsquo;s browser will not load the script and thus not execute it:&lt;/p&gt;</description>
    </item>
    <item>
      <title></title>
      <link>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/dompurify/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/dompurify/</guid>
      <description>&lt;!-- raw HTML omitted --&gt;</description>
    </item>
    <item>
      <title></title>
      <link>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/httponly-cookie-attribute/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/httponly-cookie-attribute/</guid>
      <description>&lt;h2 id=&#34;httponly-cookie-attribute&#34;&gt;HttpOnly Cookie Attribute&lt;a class=&#34;anchor&#34; href=&#34;#httponly-cookie-attribute&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;When this attribute is set to &lt;code&gt;True&lt;/code&gt;, will prevent &lt;strong&gt;client&lt;/strong&gt; from access cookie (via JavaScript). Specifically, when calling &lt;code&gt;document.cookie&lt;/code&gt;, it will just return nothing&lt;/p&gt;&#xA;&lt;h2 id=&#34;bypass-httponly&#34;&gt;Bypass HTTPOnly&lt;a class=&#34;anchor&#34; href=&#34;#bypass-httponly&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;h3 id=&#34;header-reflection&#34;&gt;Header Reflection&lt;a class=&#34;anchor&#34; href=&#34;#header-reflection&#34;&gt;#&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;If the page is &lt;strong&gt;sending the cookies as the response&lt;/strong&gt; of a requests (for example in a &lt;strong&gt;PHPinfo&lt;/strong&gt; page), it’s possible to abuse the XSS to send a request to this page and &lt;strong&gt;steal the cookies&lt;/strong&gt; from the response&lt;/p&gt;</description>
    </item>
    <item>
      <title></title>
      <link>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/same-origin-policy/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/same-origin-policy/</guid>
      <description>&lt;h2 id=&#34;same-origin&#34;&gt;Same-Origin&lt;a class=&#34;anchor&#34; href=&#34;#same-origin&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Same-Origin policy is a security mechanism implemented in web browsers to prevent cross-origin access to websites. In particular, &lt;code&gt;JavaScript&lt;/code&gt; code running on one website cannot access a different website.&lt;/p&gt;&#xA;&lt;p&gt;The origin is defined as the &lt;code&gt;scheme&lt;/code&gt;, &lt;code&gt;host&lt;/code&gt;, and &lt;code&gt;port&lt;/code&gt; of a URL. eg:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;http://localhost:80&lt;/code&gt; is the same as &lt;code&gt;http://localhost&lt;/code&gt;, but not the same as &lt;code&gt;http://localhost:8080&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;But &lt;code&gt;http://localhost&lt;/code&gt; is not the same as &lt;code&gt;http://127.0.0.1&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;And &lt;code&gt;http://localhost&lt;/code&gt; is also not the same as &lt;code&gt;https://localhost&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt; in browser can only send requests to the same origin.&lt;/p&gt;</description>
    </item>
    <item>
      <title></title>
      <link>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/waf/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://ag2s.ca/spellbook/2.-web-pentesting/2.2-common-attacks/xss---cross-site-scripting/waf/</guid>
      <description>&lt;h2 id=&#34;waf&#34;&gt;WAF&lt;a class=&#34;anchor&#34; href=&#34;#waf&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;a WAF ( Web application firewall) blocks certain request based on a list of rules. For example, if request contains the string &lt;code&gt;&#39; OR 1=1-- -&lt;/code&gt; then block&lt;/p&gt;&#xA;&lt;p&gt;It blocks certain words in certain places like &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; in the URL, or &lt;code&gt;alert&lt;/code&gt;, etc.&lt;/p&gt;&#xA;&lt;p&gt;Some are easy to bypass, some are hard&lt;/p&gt;&#xA;&lt;h2 id=&#34;bypass-waf&#34;&gt;Bypass WAF&lt;a class=&#34;anchor&#34; href=&#34;#bypass-waf&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Use OWASP&amp;rsquo;s &lt;a href=&#34;https://cheatsheetseries.owasp.org/cheatsheets/XSS_Filter_Evasion_Cheat_Sheet.html&#34;&gt;XSS Filter Evasion Cheat Sheet&lt;/a&gt;. Furthermore, there are collections of XSS payloads for different types of filters. For instance, if we are unable to use any parentheses, we may refer to the &lt;a href=&#34;https://github.com/RenwaX23/XSS-Payloads/blob/master/Without-Parentheses.md&#34;&gt;XSS without Parentheses&lt;/a&gt; payload collection&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
