Skip to content
XSS Disclosed report Advanced

Prototype Pollution leads to XSS on https://blog.swiftype.com/#__proto__[asd]=alert(document.domain)

The deparam function in a third-party JavaScript file parses the URL fragment without guarding against special property names, so an attacker can pollute Object.prototype. A gadget in the same file passes the polluted value to eval, giving script execution on the affected site.

s1r1u5 Follow

Originally disclosed on HackerOne

  • Triaged in 18 hours
  • Fixed in 21 days
  • Paid in 29 hours
  • Disclosed after 10 months

Summary: deparam function which parses location.hash in https://s.swiftypecdn.com/install/v2/st.js is vulnerable to prototype pollution. There is a script gadget in the same js file which leads to XSS.

Steps To Reproduce:

Visit (Refresh if you don't see a pop up) https://blog.swiftype.com/#__proto__[asd]=alert(document.domain)

Root Cause

https://s.swiftypecdn.com/install/v2/st.js is the vulnerable file. deparam function parses the location.hash incorrectly which leads to Prototype Pollution.


 t.deparam = h = function(e, n) {
            var i = {}
              , r = {
                "true": !0,
                "false": !1,
                "null": null
            };
            return t.each(e.replace(/\+/g, " ").split("&"), function(e, o) {
                var s, a = o.split("="), u = b(a[0]), c = i, h = 0, p = u.split("]["), f = p.length - 1;
                if (/\[/.test(p[0]) && /\]$/.test(p[f]) ? (p[f] = p[f].replace(/\]$/, ""),
                p = p.shift().split("[").concat(p),
                f = p.length - 1) : f = 0,
                2 === a.length)
                    if (s = b(a[1]),
                    n && (s = s && !isNaN(s) ? +s : "undefined" === s ? l : r[s] !== l ? r[s] : s),
                    f)
                        for (; h <= f; h++)
                            u = "" === p[h] ? c.length : p[h],
                            c = c[u] = h < f ? c[u] || (p[h + 1] && isNaN(p[h + 1]) ? {} : []) : s; //pollution here
                    else
                        t.isArray(i[u]) ? i[u].push(s) : i[u] !== l ? i[u] = [i[u], s] : i[u] = s;
                else
                    u && (i[u] = n ? l : "")
            }),
            i
        }

Gadget found in the same js, which is very interesting gadget I found so far :xD


    
        pInstall._convertStringHooksToFunctions = function() {
            var functionHooks = {};
            $.each(this._userServerConfiguration.install.hooks, function(hookName, hookFunction) {
                functionHooks[hookName] = eval(hookFunction) //eval everything in the object
            }),
            this._userServerConfiguration.install.hooks = functionHooks
        }
        

Impact:

XSS

Impact

XSS

The original report as published on HackerOne, by s1r1u5. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The deparam function assigns user-controlled keys from the URL fragment into nested objects without blocking prototype-related property names, and a separate gadget passes the resulting inherited value to eval.

Impact

An attacker could run script in the context of the affected site, which is a cross-site scripting issue.

What the attacker needed

Victim opens a crafted link; site loads the vulnerable script

How it was found

  1. Open the crafted URL containing the prototype pollution payload in the fragment.
  2. Refresh the page if the pop-up does not appear.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A website's address can contain a fragment after the # symbol, and this script reads it to build a settings object. Because it does not block names like __proto__, an attacker can sneak a value into a shared object that every other object inherits from. Another part of the script later runs that value as code, so simply opening a crafted link runs the attacker's script in the victim's browser.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by s1r1u5

View all

2 more disclosed reports, best first.

More from Elastic

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.