Thank You Next Part 1: I'm so Grateful for the XSS
Uncovering DOM-based XSS vulnerabilities infesting 11 Next.js applications: AutoGPT, Dify, Teable AI, Kortix AI CompanyOS (formerly Suna), Homarr, openstatus, Mage AI, and more
In this new three-part series, I will share a bizarre security disclosure adventure I embarked on during the first half of 2026. I had hoped one post would be sufficient, but the complexity and— for lack of a better word— shittiness of this whole debacle begs otherwise.
In this first post, I'll start simple by presenting 12 new CVEs across 11 Next.js applications. In the second post, I’ll be sharing a juicy r̸͖̒͌ͅe̴̪̩͑̏ḏ̸̀ǎ̷͔̃c̴̦̓t̶̼͋͆ḙ̵̈́d̵̥͇̓. Finally, in the third post, I’ll be exploring this convoluted mess with an analytical touch.
So let’s dig into the fun!
Description
A DOM-based Cross-Site Scripting (XSS) vulnerability has been discovered in multiple applications. The root cause is unsanitised data passed to Next.js’ useRouter().push() and useRouter().replace() (hereafter called affected functions or sinks). If the data is an external URL, it will subsequently be passed to window.location.
In the above example, router.push internally calls window.location = "javascript:alert(1)", which will execute the code after the colon and trigger an alert popup. These are called JavaScript URLs, and they are quite useful in the XSS arsenal!
To be clear, the vulnerability only occurs if there is a code path from an attacker-controllable source to the affected functions. For example, using a static path is not vulnerable:
Impact
Potential impacts include session hijacking, internal network pivoting, unauthorised API calls performed on behalf of the victim, and account takeover. Ultimately, the impact of this XSS depends on the individual application and the APIs exposed.
A compromised auth provider may lead to unauthorised config changes and further auth bypasses. A compromised financial application may lead to unauthorised trades and transactions. Et cetera.
Affected Software
The following table lists the open-source libraries I’ve discovered to be affected by the Next.js router XSS.
| Project | Category | CVE-ID | Affected Versions | Report |
|---|---|---|---|---|
| Teable AI | Productivity/AI | CVE-2026-9566 | fixed in 2026.04.23 release | gist |
| Pingvin Share | File Sharing | CVE-2026-9519 | not fixed at time of writing, project is archived, coordinated disclosure expired | gist |
| BlitzJS | Toolkit | CVE-2026-9520 | not fixed at time of writing, coordinated disclosure expired | gist |
| Rallly | Productivity | CVE-2026-6493 | ≤ 4.7.4 | gist |
| Ory Polis | SSO | CVE-2026-33506 | ≤ 1.52.2 | gist |
| openstatus | Uptime and Monitoring | CVE-2026-5808 | ≤ commit 1b678e7 (merged on 2026.03.14) | gist |
| Homarr | Productivity | CVE-2026-33510 | ≤ 1.56.1 | GHSA |
| Dify | Automation/AI | CVE-2026-85021, CVE-2026-85022 | XSS inadvertently fixed in v1.13.3; Open Redirect not yet fixed | gist |
| AutoGPT | Productivity/AI | CVE-2026-55237 | ≤ 0.6.61 | GHSA |
| Kortix AI CompanyOS (formerly Suna) | Productivity/AI | CVE-2026-12811 | silently patched in 0.8.39 | gist |
| Mage AI | Technology/AI | CVE-2026-11436 | not fixed at time of writing, coordinated disclosure expired | gist |
Gallery
Behold! Some artwork to grace these fine corridors:
XSS in Homarr ≤ 1.56.1
XSS in Teable AI < 2026.04.23, demonstrating session hijacking by calling an authenticated API
Examples
Let’s look at two examples of vulnerable applications. I hand-picked these for impact and intellectual curiosity.
Example 1: DOM XSS in Ory Polis (CVE-2026-33506)
Ory Polis is an open-source Enterprise SSO and directory sync application. An attacker could exploit an XSS in Ory Polis ≤ 1.52.2 targeting the administrator of the application to gain administrative privileges. Critically, the attacker could modify the SSO configuration and thus bypass authentication in subsequent applications relying on Polis.
Ory Polis maintainers promptly responded to the security report and issued a patch.
The application improperly trusts a URL parameter (callbackUrl), which is passed to router.push. An attacker can craft a malicious link that, when opened by an authenticated user (or an unauthenticated user that later logs in), performs a client-side redirect and executes arbitrary JavaScript in the victim’s browser.
File: pages/admin/auth/login.tsx, Line 41
As shown, the callbackUrl parameter is taken from the browser's URL query and later passed to router.push without validating against the javascript: protocol, leading to XSS.
Sample Payload:
XSS in Ory Polis ≤ 1.52.2
Example 2: DOM XSS in Dify splash.tsx Layout (CVE-2026-85021)
Dify is an open-source web application that lets users build and deploy AI apps, including workflows, RAG pipelines, agents, and chatbots. The XSS here is very similar to the example above, but it demands a slightly more complicated payload due to additional checks.
Repo: langgenius/dify
Advisory: gist
The application improperly trusts a URL parameter (redirect_url) in the Splash layout, which is used by multiple routes such as /chat, /chatbot, and /workflow. The parameter is subsequently passed to router.replace leading to DOM-based XSS. An attacker can craft a malicious link that, when opened by a user, performs a client-side redirect and executes arbitrary JavaScript in the victim’s browser.
File: web/app/(shareLayout)/components/splash.tsx, Line 48
Initially, the PoC attempted was:
This is the payload which usually works in PoCs. But when I tried this, an error would show up in the console:
This is because it does not pass the new URL(...) parse in getShareCodeFromRedirectUrl.
To actually reach the sink, we need to bypass additional formatting and parsing rules.
These additional rules are specific only to Dify, due to its implementation.
First, we need to understand how the attacker-controlled payload reaches the sink.
The
Splashlayout (which contains therouter.replacesink) is wrapped byWebAppStoreProvider. (source) So let’s look at whatWebAppStoreProvidercalls.WebAppStoreProviderwill attempt to extract a "share code" from the redirect URL. (source)Inside
getShareCodeFromRedirectUrl, the share code will be extracted by grabbing the last segment of the URL path. (source)
As such, the JavaScript payload needs to fulfill two conditions:
- It needs to appear to be a valid URL when prepended by
window.location.origin, due tonew URLinsidegetShareCodeFromRedirectUrl. - It needs to end with a
/{VALID_APP_CODE}, due to later API calls which validate the app code (aka share code). An app code is an identifier generated by Dify when you create a new workflow or bot; something likeogMVd0AemTwZwGuz. To get a valid app code, the attacker must find a way to enumerate it, such as by finding a link which discloses it or finding a Dify API which returns app codes.
To solve the first condition, we can begin the JS payload with a number to trick the URL-parsing into seeing a port. For example, if redirect_url is javascript:80/1;alert(1), then it will attempt to parse the URL http://test.localjavascript:80/1;alert(1), which— for all intents and purposes— is a valid URL! At the same time, 80/1;alert(1) is also valid JavaScript!
To meet the second condition, we can simply append //{APP_CODE}, which will be treated as a comment in the JS context.
The main challenge for the attacker here, is that APP_CODE needs to be known.
Sample Payloads:
The second payload demonstrates session hijacking by calling an authenticated endpoint. It first grabs the CSRF token from cookies, then calls /console/api/account/profile, and finally displays the data in an alert. In an actual attack, the data may be silently exfiltrated or a state-modifying API may be called which wouldn't necessarily require exfiltration.
XSS in Dify < 1.13.3 with a simple alert
XSS in Dify < 1.13.3, proving session hijacking
Remediations
Untrusted redirect URLs should be validated or sanitised. They should be restricted to absolute paths like /a/b/c, possibly with an origin like https://your.site.com/a/b/c. It should not accept dangerous URLs such as javascript URLs or open redirects.
Here are some ways I've recommended the affected libraries to validate their URLs.
Remediation A: Simple String Checking
This approach only allows absolute URL paths such as /abc and protects against open redirects such as //example.com/path.
It is relatively simple, and quite effective.
Remediation B: URL Parsing
This second example is similar to the first, but allows for http:// and https:// scheme in the redirect URL while still protecting against open redirects. To achieve this, it uses the builtin URL JavaScript class.
This correctly handles:
- Relative paths like
/dashboard(resolves tohttps://example.com/dashboard) - Absolute paths within the same origin like
https://example.com/pipelines - Blocks cross-origin and open redirects like
//attacker.site/index.htmlandhttps://attacker.site/ - Blocks dangerous schemes like
javascript:,data:,vbscript:, etc.
Intermission
I should mention that there were others who came across this vulnerability first. Kevin Stubbings (kwstubbs) from GitHub Security Labs has also embarked on this spree before:
As have others:
It goes without saying that this class of Next.js bug has quite the history across the Next ecosystem.
The astute reader may also notice that Dify, among the affected software, was the only one labelled “inadvertently fixed”. What does that mean? And how did it come to this?
In a later post, I will be sharing more details of this, along with more technical funsies.
I’ll end this post with an anecdote and tip on vuln hunting. I initially came across this Next.js bug pattern while pentesting a closed-source app which had a backTo parameter intended for a redirect URL— exact same situation as the other 11 apps above. So I reported the XSS and a couple days later the maintainers said that they fixed it by completely removing the parameter.
Usually in a pentest, I report the finding and move on, because deadlines amirite? But since this was a client-side bug, I used the opportunity to do a bit of white-box analysis by inspecting the JavaScript and root-causing the issue. I understood the issue existed, but I didn’t understand why. After a bit of tracing, I found the URL parameter was passed into router.push, and with a bit of Googling, I realised this was not an isolated issue. And that’s how I ended up in this rabbit hole.
So if you ever get the chance to do root cause analysis, to go deeper, I would encourage you to try it out, because you might just gain new insights in the process.
What AI model did you use?
I used the limited model HMN-LLM v13017295. Access to this premium model is available at 1 USD per I/O token. It comes with a cutting-edge sporadic thinking mode along with a library of over 100 ASMR sounds, including umms, ahhs, and errs. You can find a demo here: HMN LLM AI.
Is this router sink still out there?
“Yes*.”
It’s still out there but changes made by the Next.js team have muddied the situation.
It used to be that when such a taint path was discovered— where untrusted input enters router.push— the security report would be made direct to the Next.js user, rather than the Next.js maintainers. This is because in the past Next.js rejected responsibility for sanitising input entering the affected functions, so responsibility fell to users. It was not ideal, but at least the direction was clear.
Now, if you try to reproduce the vulnerabilities on an app running the latest Next.js versions, you’ll find that the payload is blocked by an error message:
This seems like a fix, but as with a lot of things, the situation is more complicated. And in the next two posts, I’ll be explaining this more thoroughly.
Relevant Links
Comments are back! Privacy-focused; without ads, bloatware 🤮, and trackers. Be one of the first to contribute to the discussion— before AI invades social media, world leaders declare war on guppies, and what little humanity left is lost to time.






