/

CVE-2026-26022

Severity:

HIGH RISK

(8.7)

XSS in Gogs Issue and Comment Rendering

CVE-2026-26022

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Stored Cross-Site Scripting leading to arbitrary JavaScript execution in users' browsers

Severity:

HIGH RISK

(8.7)

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, a self-hosted Git service, contains a stored cross-site scripting (XSS) vulnerability in issue descriptions and comments where HTML content is sanitized but still permits data: URI schemes.

Authenticated users can craft malicious links that trigger arbitrary JavaScript execution in the browser of any user viewing the affected issue or comment, potentially leading to account compromise and session hijacking.

Affected context

This vulnerability appears in Gogs instances that:

  • Allow authenticated users to create or edit issue descriptions and comments containing rich text or HTML-like content
  • Rely on an HTML sanitizer that intentionally permits data: URI schemes
  • Render user-supplied issue and comment content directly in other users' browsers

The risk manifests in multi-user deployments where untrusted or semi-trusted users can interact via issues and comments, such as in shared repositories, internal developer platforms, or community instances.

Exploit preconditions

  • Attack surface: Web UI for viewing issues and comments in Gogs.
  • Required access: Authenticated account with permission to create or edit issues or comments in a repository.
  • Trigger point: A victim user visits a page rendering the malicious issue description or comment in their browser.
  • Why exploitation is possible: The HTML sanitization pipeline explicitly allows data: URIs, which can be used to embed JavaScript-bearing payloads that are executed when rendered, resulting in stored XSS.

Why this happens

The root cause is an incomplete HTML sanitization strategy that treats data: URIs as safe when processing user-supplied content for issues and comments.

By allowing data: URI schemes in sanitized links or other HTML attributes, the application unintentionally preserves a scripting vector that modern browsers can interpret in a way that leads to JavaScript execution.

This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, where user-controlled input is reflected into the DOM without sufficient encoding or scheme/attribute restrictions to prevent script execution.

Potential impact

  • Theft or misuse of session cookies or authentication tokens via JavaScript in the victim's browser
  • Impersonation of the victim within Gogs (e.g., creating or modifying repositories, issues, or comments)
  • Unauthorized actions performed on behalf of privileged users (e.g., repository admins) viewing malicious content
  • Exfiltration of sensitive data visible in the Gogs UI, such as repository names, private issue content, or internal metadata
  • Delivery of further client-side attacks, such as redirecting users to phishing pages or loading additional malicious scripts

General mitigation guidance

Mitigation focuses on strict output encoding and conservative HTML sanitization for all user-supplied content that is rendered in browsers.

General defensive patterns include:

  • Restricting or removing support for data: URI schemes and other risky URL schemes (e.g., javascript:) in all sanitized attributes
  • Applying a robust HTML sanitizer configuration that whitelists only necessary tags and attributes, and disallows inline event handlers (e.g., onclick, onload)
  • Ensuring all user-controlled text is HTML-encoded by default, and only minimal, reviewed formatting is allowed where strictly needed
  • Using Content Security Policy (CSP) with scripts restricted to trusted origins and disallowing unsafe-inline where feasible, to limit the impact of any residual XSS vector
  • Separating display markup from data by rendering user-supplied content through safe templating engines that escape output by default

How teams detect issues like this

High-level detection and assurance approaches include:

  • Static analysis and secure code review focused on:
  • HTML sanitization utilities or middleware
  • Custom whitelist-based sanitizers that permit URL schemes or inline event handlers
  • Views or templates that interpolate raw user input or sanitized-but-still-HTML content
  • Automated scanning using dynamic application security testing (DAST) tools configured with XSS payloads targeting:
  • Issue creation and editing workflows
  • Comment submission and rendering endpoints
  • Unit and integration tests that:
  • Assert that disallowed tags, attributes, and URL schemes are stripped or safely encoded
  • Validate that rendered issue/comment content does not execute injected JavaScript
  • Periodic policy enforcement that:
  • Prohibits direct use of raw HTML from users unless passed through a vetted sanitization library
  • Requires security review for any modifications to sanitization configuration or Markdown/HTML rendering logic

Sources

SourceLink
github.comgithub.com/gogs/gogs/commit/441c64d7bd8893b2f4e48660a8be3a7472e14291
github.comgithub.com/gogs/gogs/pull/8174
github.comgithub.com/gogs/gogs/releases/tag/v0.14.2
github.comgithub.com/gogs/gogs/security/advisories/GHSA-xrcr-gmf5-2r8j

Frequently asked

questions

Yes. Any authenticated user who can access the Gogs instance and create issues or comments can inject a malicious payload. The impact occurs when other users, potentially over the internet, load the affected pages in their browsers.

No elevated privileges are strictly required. A low-privileged authenticated user who can post issue descriptions or comments is sufficient, although compromising a highly privileged viewer (such as an admin) significantly increases the impact.

The safest pattern is to treat all user-supplied content as untrusted, apply strict HTML sanitization with a minimal whitelist, disallow risky URL schemes like data: and javascript:, and ensure all output is HTML-encoded by default. Complement this with defense-in-depth measures such as a restrictive Content Security Policy.

Standardize on vetted sanitization libraries and configurations, use templating engines that escape by default, perform security-focused code reviews around content rendering paths, and include automated tests and scanning for XSS vectors in CI/CD pipelines whenever user-generated content is processed or rendered.

Find out what's already
exploitable in your codebase.