CVE-2026-52798: Gogs has Stored XSS in `.ipynb` Preview
Summary Although .ipynb previews are sanitized on the server side via /-/api/sanitizeipynb, the inserted content is re-rendered on the client side without sanitization using marked() on elements with the .nb-markdown-cell class. During this process, links containing schemes such as javascript: can be regenerated.
Published Jun 22, 2026 · Updated Jul 21, 2026
Affected packages
gogs.io/gogs
- Ecosystem
- Go
- Affected
- <= 0.14.2
- Fixed in
- 0.14.3
- Check
go list -m gogs.io/gogs
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
Although .ipynb previews are sanitized on the server side via /-/api/sanitize_ipynb, the inserted content is re-rendered on the client side without sanitization using marked() on elements with the .nb-markdown-cell class. During this process, links containing schemes such as javascript: can be regenerated.
As a result, when a victim views an attacker-crafted .ipynb file and clicks the link, arbitrary JavaScript is executed in the Gogs origin, leading to a click-based Stored XSS.
Details
After the rendered output of a .ipynb file is sanitized via /-/api/sanitize_ipynb and inserted into the DOM, only the Markdown cell portions are re-rendered using `marked()` and overwritten in the DOM. During this process, links with the javascript: scheme can be regenerated.
templates/repo/view_file.tmpl:42–71
{{else if .IsIPythonNotebook}}
<script>
$.getJSON("{{.RawFileLink}}", null, function(notebook_json) {
var notebook = nb.parse(notebook_json);
var rendered = notebook.render();
$.ajax({
type: "POST",
url: '{{AppSubURL}}/-/api/sanitize_ipynb',
data: rendered.outerHTML,
processData: false,
contentType: false,
}).done(function(data) {
$("#ipython-notebook").append(data);
$("#ipython-notebook code").each(function(i, block) {
$(block).addClass("py").addClass("python");
hljs.highlightBlock(block);
});
// Overwrite image method to append proper prefix to the source URL
var renderer = new marked.Renderer();
var context = '{{.RawFileLink}}';
context = context.substring(0, context.lastIndexOf("/"));
renderer.image = function (href, title, text) {
return `While regular HTML pages (including `.ipynb` preview pages) are served without a Content Security Policy (CSP), CSP headers are applied only to attachment delivery routes.
internal/cmd/web.go:323
c.Header().Set("Content-Security-Policy", "default-src 'none'; style-src 'unsafe-inline'; sandbox")Steps to Reproduce
- As the attacker, add and push/commit a
.ipynbfile containing ajavascript:link in a Markdown cell to a repository.
- Example (PoC):
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[poc](javascript:alert(document.domain))"
]
}
]
}- The victim opens the file on Gogs (e.g.,
/<user>/<repo>/src/<branch>/poc.ipynb).
- When the victim clicks the
poclink displayed in the preview,alert(document.domain)is executed in the same Gogs origin.
Minimum Required Privileges
- Attacker: Ability to place a
.ipynbfile as a regular (non-admin) user
- For example: a general user who can create a public repository and add files.
- Or: write access (collaborator, etc.) to an existing repository that the victim will view.
- Victim: Permission to view the repository (a click is required).
Impact
- Unauthorized actions performed with the victim’s account privileges (e.g., repository settings changes, Issue operations,誘導 to token creation).
- Theft of information accessible to the victim (repository/Issue/Wiki contents, tokens exposed in page context).
- If the victim is an administrator, the impact may escalate to instance-wide configuration changes and user management.
Credited to odgrso.
References
- https://github.com/gogs/gogs/security/advisories/GHSA-jq8v-rmf6-65jw
- https://github.com/gogs/gogs/pull/8319
- https://github.com/gogs/gogs/commit/17b168b11ca759a7550e1f4bbd68bbde14db7785
- https://github.com/gogs/gogs/releases/tag/v0.14.3
- https://nvd.nist.gov/vuln/detail/CVE-2026-52798
- https://github.com/advisories/GHSA-jq8v-rmf6-65jw
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-52800
Gogs Vulnerable to CSRF Leading to Organization Owner Takeover
high8.8Jun 23, 2026CVE-2026-52801
Gogs has the ability to import local repositories via Mirror Settings
high8.1Jun 23, 2026CVE-2026-52802
Gogs has an Open Redirect via redirect_to
medium5.4Jun 23, 2026CVE-2026-52804
Gogs Vulnerable to Privilege Escalation via Collaboration Access Mode Validation
medium5.5Jun 23, 2026CVE-2026-52805
Gogs has a Migration Redirect Bypass that Leads to Internal Repository Theft
high8.7Jun 23, 2026CVE-2026-52806
Gogs vulnerable to RCE via git rebase --exec argument injection in pull request merge
critical9.9Jun 23, 2026
