# GHSA-26gq-grmh-6xm6: Gogs vulnerable to Stored XSS via Mermaid diagrams

> Attackers can inject malicious scripts via Mermaid diagrams in Markdown files, leading to account takeover or admin compromise when viewed.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 6 Feb 2026
- **Also known as:** GO-2026-4454

## What is GHSA-26gq-grmh-6xm6?

GHSA-26gq-grmh-6xm6 is a cross-site scripting vulnerability in gogs.io/gogs, published on 6 Feb 2026. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

### Summary
Stored XSS via mermaid diagrams due to usage of vulnerable renderer library

### Details
Gogs introduced support for rendering mermaid diagrams in version [0.13.0.](https://github.com/gogs/gogs/releases/tag/v0.13.0)

Currently used version of the library [mermaid 11.9.0](https://github.com/gogs/gogs/tree/main/public/plugins/mermaid-11.9.0) is vulnerable to at least two XSS scenarios with publicly available payloads

Resources:
https://github.com/mermaid-js/mermaid/security/advisories/GHSA-7rqq-prvp-x9jh
https://github.com/mermaid-js/mermaid/security/advisories/GHSA-8gwm-58g9-j8pw

### PoC

1. Create a markdown file eg. `README.md` containing following malicious mermaid diagram (payload based on [CVE-2025-54880](https://github.com/mermaid-js/mermaid/security/advisories/GHSA-8gwm-58g9-j8pw))
```
architecture-beta
    group api(cloud)[API]
    service db "<img src=x onerror=\"alert(document.domain)\">" [Database] in api
```
2. The XSS should pop whenever either repository or file is viewed

#### Demo

https://github.com/user-attachments/assets/98320f62-6c1c-4254-aa61-95598c725235

### Impact
The attacker can potentially achieve account takeover
In a worst case scenario if the victim were an instance admin this could lead to a compromise of the entire deployment

### Proposed remediation steps
1. Upgrade to a patched version of the third party library
https://github.com/mermaid-js/mermaid/releases/tag/v10.9.5
2. Consider running mermaid using `sandbox` level which would mitigate impact of future potential cross-site scripting issues
https://mermaid.js.org/config/usage.html#securitylevel

## Which versions are affected by GHSA-26gq-grmh-6xm6?

3 open source packages ship an affected version, including gogs.io/gogs.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `gogs.io/gogs` | Go | All versions | None |
| `gogs.io/gogs` | Go | All versions | 0.13.4 |
| `gogs.io/gogs` | Go | All versions | 0.13.4 |

## How do I fix GHSA-26gq-grmh-6xm6?

Upgrade gogs.io/gogs to 0.13.4 or later.

## Is GHSA-26gq-grmh-6xm6 being exploited?

There is no known exploitation of GHSA-26gq-grmh-6xm6 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-26gq-grmh-6xm6 and fix it if it is affected.

What it is: GHSA-26gq-grmh-6xm6 is a cross-site scripting vulnerability in gogs.io/gogs, published on 6 Feb 2026. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-26gq-grmh-6xm6 in the wild and no public exploit code.

Affected packages and fixed versions:
- gogs.io/gogs (Go): affected all versions; no fix listed
- gogs.io/gogs (Go): affected all versions; fixed in 0.13.4
- gogs.io/gogs (Go): affected all versions; fixed in 0.13.4

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-26gq-grmh-6xm6/ (Markdown: https://insights.sbomify.com/GHSA-26gq-grmh-6xm6/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-26gq-grmh-6xm6

---
From sbomify Insights: https://insights.sbomify.com/GHSA-26gq-grmh-6xm6/
Summaries are generated and may contain mistakes; the official description above is the record.
