/

CVE-2026-52798

Severity:

HIGH RISK

(8.9)

Stored XSS (CWE-79) in Gogs .ipynb Markdown Preview

CVE-2026-52798

Deferred

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Stored Cross-Site Scripting in Web UI

Severity:

HIGH RISK

(8.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Gogs prior to 0.14.3 contains a stored cross-site scripting flaw in the Jupyter Notebook (.ipynb) preview feature, where client-side re-rendering bypasses server-side sanitization.

An attacker can embed malicious links that regenerate unsafe schemes, and when a user clicks such a link, arbitrary JavaScript executes in the Gogs origin under typical browsing conditions.

Affected context

The vulnerability occurs in Gogs instances that support previewing Jupyter Notebook (.ipynb) files via the web interface.

It manifests when server-sanitized notebook content is subsequently re-rendered in the browser using client-side Markdown processing on elements with the .nb-markdown-cell class, without equivalent sanitization.

This is most relevant in deployments where users can upload or push notebook files to repositories and other users routinely view those files within the Gogs web UI.

Exploit preconditions

  • Attack surface: Web-based notebook preview pages served by Gogs.
  • Required access: Ability to create or modify a repository containing a crafted .ipynb file (e.g., via push, upload, or commit).
  • Trigger point: A victim user visits the notebook preview in the Gogs UI and clicks an attacker-controlled link inside a rendered notebook cell.
  • Why exploitation is possible: Client-side Markdown rendering via marked() on .nb-markdown-cell elements reconstructs link content without enforcing a safe URL scheme or HTML sanitization, allowing reintroduction of javascript: or similar payloads despite prior server-side sanitization.

Why this happens

The underlying issue is a mismatch between server-side sanitization and client-side rendering logic.

Although the .ipynb content is sanitized on the server, the frontend code uses marked() to re-render Markdown in .nb-markdown-cell elements without applying equivalent sanitization or scheme filtering.

This pattern maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where untrusted content from repository files persists and is later interpreted as active script in a user's browser.

Potential impact

  • Arbitrary JavaScript execution in the context of the Gogs origin.
  • Theft of session cookies or other authentication tokens associated with Gogs.
  • Unauthorized actions performed on behalf of the victim (e.g., repository operations, account changes).
  • Manipulation of repository content or settings visible to the victim.
  • Potential lateral movement through social engineering using trusted Gogs UI.

General mitigation guidance

Mitigation typically focuses on aligning client-side rendering behavior with secure server-side sanitization and constraining what notebook content can do in the browser.

Common defensive patterns include:

  • Ensuring all client-side Markdown rendering paths apply robust HTML sanitization, including filtering dangerous URL schemes such as javascript:.
  • Centralizing content sanitization logic so that both server and client use the same, security-aware transformation pipeline.
  • Treating repository file content as untrusted input and rendering it in a strictly inert form (e.g., using safe HTML whitelists and disabling inline event handlers).
  • Limiting the privileges associated with user sessions so that compromise of one account yields minimal damage.
  • Applying content security policies to reduce the impact of any script execution that might occur.

How teams detect issues like this

Effective detection combines code-level analysis with behavioral monitoring:

  • Use static analysis or manual code review to flag any client-side rendering of untrusted repository content that bypasses sanitization routines, especially uses of Markdown libraries such as marked() without safe configuration.
  • Define review checklists that require verification of URL scheme filtering and HTML escaping wherever links or rich text from user-controlled files are processed.
  • Employ automated security testing (e.g., dynamic application security tests) to scan notebook and Markdown preview features for persistent XSS behaviors.
  • Maintain policies in CI that block changes introducing new unsanitized rendering paths or relaxing existing sanitization filters.

Sources

SourceLink
github.comgithub.com/gogs/gogs/commit/17b168b11ca759a7550e1f4bbd68bbde14db7785
github.comgithub.com/gogs/gogs/pull/8319
github.comgithub.com/gogs/gogs/releases/tag/v0.14.3
github.comgithub.com/gogs/gogs/security/advisories/GHSA-jq8v-rmf6-65jw

Frequently asked

questions

It primarily affects Jupyter Notebook .ipynb previews where notebook content is rendered as Markdown in the browser. Other file types may be unaffected unless they follow a similar client-side rendering pattern.

An attacker generally needs the ability to push or upload a crafted .ipynb file into a repository that a victim will view. This might be through a normal user account, a compromised account, or a collaboration workflow.

The most robust fix is to ensure that all client-side rendering of untrusted content is passed through a strict sanitization and URL-scheme filtering layer, ideally using the same validated logic as the server, before it is inserted into the DOM.

Design new rendering features under the assumption that repository and user-supplied content is untrusted, enforce consistent sanitization for both server and client, adopt secure-by-default Markdown and HTML processing libraries, and include XSS checks in code review and automated testing pipelines.

Find out what's already
exploitable in your codebase.