<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>CORS on an's security blog</title><link>https://panman4040.github.io/training/portswigger/cors/</link><description>Recent content in CORS on an's security blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 15 Jul 2026 08:36:00 +0700</lastBuildDate><atom:link href="https://panman4040.github.io/training/portswigger/cors/index.xml" rel="self" type="application/rss+xml"/><item><title>CORS vulnerability with trusted insecure protocols | &lt;span style="color:#3498db">Practitioner&lt;/span></title><link>https://panman4040.github.io/training/portswigger/cors/cors_practitioner1/</link><pubDate>Tue, 07 Jul 2026 13:43:16 +0800</pubDate><guid>https://panman4040.github.io/training/portswigger/cors/cors_practitioner1/</guid><description>&lt;p>Just like the &lt;a href="https://panman4040.github.io/training/portswigger/cors/cors_apprentice2/">last lab&lt;/a>, the session cookie has &lt;code>SameSite=None&lt;/code> and there is zero CSRF tokens or anything of the sort while querying for sensitive data on &lt;code>/accountDetails&lt;/code>:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_13-19-50-990.png" alt="">
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_13-20-02-482.png" alt="">
But unlike the last two labs, the web application here controls which origins can get in quite strictly. It withstands parsing errors and the &lt;code>null&lt;/code> check, which would prove exfiltrating victim&amp;rsquo;s data more difficult.&lt;/p>
&lt;p>So naturally, we should probe other functionalities to find an attack surface. Notice the Check Stock add-on, is it rather odd that whenever we want to query stocks, it opens a window to an insecure HTTP subdomain?
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_13-23-50-705.png" alt="">
Plus, this possibly vulnerable subdomain is on the whitelist, maybe this is our attack surface:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_13-51-48-735.png" alt="">
Upon closer inspection, to access stock level we do need to provide two necessary params &lt;code>productId&lt;/code> and &lt;code>storeId&lt;/code>. The site dictates the former must definitely be an integer, what if it isn&amp;rsquo;t?
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_13-28-56-360.png" alt="">
Rather than showing a generic error message, the web application on this subdomain reflects our wrong ID into the HTML. This smells of XSS vulnerabilities, let&amp;rsquo;s test this by adding a harmless &lt;code>h1&lt;/code> tag:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_13-29-12-473.png" alt="">
Surprisingly this works! We can inject arbitrary HTML and the parser &lt;em>will&lt;/em> honor it. Using all these information in mind, we can just paste our old payload into &lt;code>productId&lt;/code> and it will run smooth as butter:&lt;/p></description></item><item><title>CORS vulnerability with trusted null origin | &lt;span style="color:#2ecc71">Apprentice&lt;/span></title><link>https://panman4040.github.io/training/portswigger/cors/cors_apprentice2/</link><pubDate>Tue, 07 Jul 2026 10:39:16 +0800</pubDate><guid>https://panman4040.github.io/training/portswigger/cors/cors_apprentice2/</guid><description>&lt;p>Similar to &lt;a href="https://panman4040.github.io/training/portswigger/cors/cors_apprentice1/">this lab&lt;/a>, the session cookie still has &lt;code>SameSite=None&lt;/code> and sensitive data is still stored at the &lt;code>/accountDetails&lt;/code> endpoint. CORS may still be supported as the &lt;code>Access-Control-Allow-Credentials&lt;/code> is set to True:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_10-19-29-856.png" alt="">
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_10-20-24-697.png" alt="">&lt;/p>
&lt;p>Let&amp;rsquo;s try manipulating the Origin header, for example say &lt;code>evil.com&lt;/code>?
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_10-24-28-762.png" alt="">
The request is accepted? Yet there is no &lt;code>Access-Control-Allow-Origin&lt;/code> header which means the origin is rejected? What does this mean? Turns out that CORS is enforced by the &lt;strong>victim&amp;rsquo;s web browser&lt;/strong>, and not the server.&lt;/p></description></item><item><title>CORS vulnerability with basic origin reflection | &lt;span style="color:#2ecc71">Apprentice&lt;/span></title><link>https://panman4040.github.io/training/portswigger/cors/cors_apprentice1/</link><pubDate>Tue, 07 Jul 2026 09:43:16 +0800</pubDate><guid>https://panman4040.github.io/training/portswigger/cors/cors_apprentice1/</guid><description>&lt;p>Our goal is to obtain the API key of &lt;code>administrator&lt;/code>, so first we have to see how it is returned in the response:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_09-36-05-549.png" alt="">
The web application fetches the endpoint &lt;code>/accountDetails&lt;/code> including the user&amp;rsquo;s credentials. It then queries for &lt;code>apiKey&lt;/code> and reflects it in the HTML. This sounds interesting, let&amp;rsquo;s dive in for more!
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_09-36-48-853.png" alt="">
The backend returns with a clean JSON object containing our apikey &lt;strong>and&lt;/strong> session cookie as well, this smells privacy issues. Not only that the web application responds with the &lt;code>Access-Control-Allow-Credentials&lt;/code> header set to True, meaning CORS may be supported and credentials are included in requests &lt;em>for the same origins at least&lt;/em>. Let&amp;rsquo;s try spoofing the Origin header and see what&amp;rsquo;s up:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_09-37-27-683.png" alt="">
Surprisingly, the backend never bothers validating origin and just appends them blindly into the &lt;code>Access-Control-Allow-Origin&lt;/code> header, not only that but we are also allowed to send credentials into our requests as well. This opens up opportunities for a CORS exploit on the &lt;code>/accountDetails&lt;/code> endpoint, but we forgot to check whether the session cookie is Strict or not. Let&amp;rsquo;s try:
&lt;img src="https://panman4040.github.io/images/viber_image_2026-07-07_09-40-12-824.png" alt="">
Thankfully, the session cookie is set to None, and since our original request does not have CSRF tokens, we can craft the following payload:&lt;/p></description></item></channel></rss>