CVE-2026-52816: Gogs's Unauthenticated Jupyter Notebook (ipynb) Sanitizer allows arbitrary data: URIs leading to XSS
Summary The Jupyter Notebook (ipynb) sanitizer endpoint at POST /-/api/sanitizeipynb allows arbitrary data: URIs without proper restrictions, potentially leading to Cross-Site Scripting (XSS). The endpoint uses bluemonday.UGCPolicy() with p.AllowURLSchemes("data") which permits all data URI schemes including data:text/html, enabling attackers to inject malicious HTML/JavaScript.
Published Jun 23, 2026 · Updated Jul 21, 2026
Affected packages
gogs.io/gogs
- Ecosystem
- Go
- Affected
- < 0.14.3
- Fixed in
- 0.14.3
- Check
go list -m gogs.io/gogs
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
The Jupyter Notebook (ipynb) sanitizer endpoint at POST /-/api/sanitize_ipynb allows arbitrary data: URIs without proper restrictions, potentially leading to Cross-Site Scripting (XSS). The endpoint uses bluemonday.UGCPolicy() with p.AllowURLSchemes("data") which permits all data URI schemes including data:text/html, enabling attackers to inject malicious HTML/JavaScript. Additionally, the endpoint has no authentication middleware, allowing any registered user to exploit this vulnerability.
Severity
High
Affected Versions
All versions using the vulnerable endpoint
Vulnerability Details
- CVE ID: (To be assigned)
- Entry Point:
POST /-/api/sanitize_ipynb - Attack Vector: Network
- Authentication Required: No (only needs a registered user account)
Impact
An attacker with a registered user account can:
- Send malicious HTML containing
data:text/htmlURIs to the sanitization endpoint - Receive sanitized but attacker-controlled HTML in the response
- Execute arbitrary JavaScript in the attacker's browser context through XSS
- Potentially exploit other users if the sanitized output is rendered in their context
The vulnerability has higher severity because:
- No authentication required (only needs a registered user account)
- Unlike the safer pattern in
internal/markup/sanitizer.go:39which usesisSafeDataURIto only allow safe image MIME types, this endpoint allows ALL data URIs including HTML - The returned HTML can be used to craft XSS attacks
Proof of Concept
Attacker sends a POST request to the sanitization endpoint:
POST /-/api/sanitize_ipynb HTTP/1.1
Host: target.gogs.instance
Content-Type: text/plain
alert(document.cookie)</script>">clickThe server returns the sanitized HTML with the data URI preserved:
alert(document.cookie)</script>">clickWhen this HTML is rendered in a browser, the JavaScript within the data URI will execute, leading to XSS.
Affected Component
File: internal/app/api.go:10-16
func ipynbSanitizer() *bluemonday.Policy {
p := bluemonday.UGCPolicy()
p.AllowAttrs("class", "data-prompt-number").OnElements("div")
p.AllowAttrs("class").OnElements("img")
p.AllowURLSchemes("data") // <-- VULNERABLE: allows all data URIs
return p
}File: cmd/gogs/web.go:681-683 - No authentication middleware
m.Group("/-", func() {
m.Get("/metrics", app.MetricsFilter(), promhttp.Handler())
m.Group("/api", func() {
m.Post("/sanitize_ipynb", app.SanitizeIpynb()) // <-- No auth middleware
})
})Root Cause
- Unrestricted data URI scheme: The code at
internal/app/api.go:14usesp.AllowURLSchemes("data")without any restriction, unlike the safer implementation ininternal/markup/sanitizer.go:39which usesAllowURLSchemeWithCustomPolicy("data", isSafeDataURI)to only allow safe image MIME types.
- No authentication: The endpoint at
cmd/gogs/web.go:682does not have any authentication middleware applied, making it accessible to any registered user.
- Insufficient validation: The sanitization only removes dangerous tags/attributes but preserves data URIs, allowing
data:text/htmlpayloads to pass through.
Suggested Fix
Option 1: Use the same safe pattern as internal/markup/sanitizer.go
Replace p.AllowURLSchemes("data") with:
p.AllowURLSchemeWithCustomPolicy("data", isSafeDataURI)Where isSafeDataURI is a function that only allows safe image MIME types (image/png, image/jpeg, image/gif, etc.).
Option 2: Add authentication middleware
Apply appropriate authentication to the endpoint:
m.Post("/sanitize_ipynb", middleware.signIn, app.SanitizeIpynb())Option 3: Disable data URI scheme entirely
If data URIs are not required for ipynb sanitization:
// Remove this line entirely:
// p.AllowURLSchemes("data")Credited to JLGitHub66.
References
- https://github.com/gogs/gogs/security/advisories/GHSA-3w28-36p9-w929
- https://github.com/gogs/gogs/pull/8326
- https://github.com/gogs/gogs/commit/dd1bd9837aa196b3ed3a8ee21e5727b5d7a986a3
- https://github.com/gogs/gogs/releases/tag/v0.14.3
- https://nvd.nist.gov/vuln/detail/CVE-2026-52816
- https://github.com/advisories/GHSA-3w28-36p9-w929
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
