# GHSA-3244-8mff-w398: Reflected XSS in Gotify's /docs via import of outdated Swagger UI

> Reflected XSS in Gotify's Swagger UI allows attackers to execute arbitrary JavaScript and potentially take over user accounts via malicious links.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 10 Jan 2023
- **Also known as:** GO-2023-1471

## What is GHSA-3244-8mff-w398?

GHSA-3244-8mff-w398 is a cross-site scripting vulnerability in github.com/gotify/server, published on 10 Jan 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

### Impact

Gotify exposes an outdated instance of the [Swagger UI](https://swagger.io/tools/swagger-ui/) API documentation frontend at `/docs` which is susceptible to reflected XSS attacks when loading external Swagger config files.

Specifically, the DOMPurify version included with this version of Swagger UI is vulnerable to a [rendering XSS](https://www.vidocsecurity.com/blog/hacking-swagger-ui-from-xss-to-account-takeovers/) incorporating the mutation payload detailed in [CVE-2020-26870](https://research.securitum.com/mutation-xss-via-mathml-mutation-dompurify-2-0-17-bypass/) which was patched in 2021. This is further tracked in the GitHub Advisory Database as GHSA-QRMM-W75W-3WPX.

An attacker can execute arbitrary JavaScript and potentially take over the account of the user that clicked the link. Keep in mind, the Gotify UI won't natively expose such a malicious link, so an attacker has to get the user to open the malicious link in a context outside of Gotify.

### Patches

The vulnerability has been fixed in version 2.2.3.

### References

https://github.com/gotify/server/pull/541

## Which versions are affected by GHSA-3244-8mff-w398?

4 open source packages ship an affected version, including github.com/gotify/server and github.com/gotify/server/v2.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/gotify/server` | Go | All versions | None |
| `github.com/gotify/server` | Go | All versions | 2.2.3 |
| `github.com/gotify/server` | Go | All versions | 2.2.3 |
| `github.com/gotify/server/v2` | Go | All versions | 2.2.3 |

## How do I fix GHSA-3244-8mff-w398?

Upgrade github.com/gotify/server to 2.2.3 or later.

## Is GHSA-3244-8mff-w398 being exploited?

There is no known exploitation of GHSA-3244-8mff-w398 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-3244-8mff-w398 and fix it if it is affected.

What it is: GHSA-3244-8mff-w398 is a cross-site scripting vulnerability in github.com/gotify/server, published on 10 Jan 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-3244-8mff-w398 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/gotify/server (Go): affected all versions; no fix listed
- github.com/gotify/server (Go): affected all versions; fixed in 2.2.3
- github.com/gotify/server (Go): affected all versions; fixed in 2.2.3
- github.com/gotify/server/v2 (Go): affected all versions; fixed in 2.2.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-3244-8mff-w398/ (Markdown: https://insights.sbomify.com/GHSA-3244-8mff-w398/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-3244-8mff-w398

---
From sbomify Insights: https://insights.sbomify.com/GHSA-3244-8mff-w398/
Summaries are generated and may contain mistakes; the official description above is the record.
