CVE-2026-26022: Gogs Cross-Site Scripting Vulnerability

HIGH
Advisory Identifier: GHSA-xrcr-gmf5-2r8j
CVSS 8.7
CWE-79
Published
Advisory Summary

CVE-2026-26022 is a HIGH (CVSS 8.7) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Gogs libraries in the Go ecosystem. The issue involves stored xss via data uri in issue comments. Remediation is available by upgrading affected packages to version 0.14.2.

CVE-2026-26022 at a Glance

CVE Identifier CVE-2026-26022
GHSA Identifier GHSA-xrcr-gmf5-2r8j
Severity HIGH
CVSS v3.1 Base Score 8.7
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Gogs
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-26022

To remediate this vulnerability, upgrade all affected Gogs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gogs.io/gogs fixed: 0.14.2
Upgrade gogs.io/gogs to 0.14.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for gogs.io/gogs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-26022, inspect your project dependencies for Gogs:

inspect dependencies for gogs.io/gogs

Analyze the terminal output to locate any version of Gogs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.14.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Gogs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A Stored Cross-site Scripting (XSS) vulnerability exists in the comment and issue description functionality. The application's HTML sanitizer explicitly allows `data:` URI schemes, enabling authenticated users to inject arbitrary JavaScript execution via malicious links. ### Details The vulnerability is located in `internal/markup/sanitizer.go`. The application uses the `bluemonday` HTML sanitizer but explicitly weakens the security policy by allowing the `data` URL scheme: ```go // internal/markup/sanitizer.go func NewSanitizer() { sanitizer.init.Do(func() { // ... // Data URLs sanitizer.policy.AllowURLSchemes("data") // ... }) } ``` While the Markdown renderer rewrites relative links (mitigating standard Markdown `[link](data:...)` attacks), Gogs supports **Raw HTML** input. Raw HTML anchor tags bypass the Markdown parser's link rewriting and are processed directly by the sanitizer. Since the sanitizer is configured to allow `data:` URIs, payloads like `<a href="data:text/html...">` are rendered as-is. ### PoC 1. Create a file named `exploit.md` in a repository. 2. Add the following content (Raw HTML): ```html <a href="data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4=">Click me for XSS</a> ``` 3. Commit and push the file. 4. Navigate to the file in the Gogs web interface. 5. Click the "Click me for XSS" link. 6. **Result:** An alert box with "XSS" appears, executing the JavaScript payload. ### Impact This is a **Stored XSS** vulnerability. Any user who views the malicious comment and clicks the link will execute the attacker-supplied JavaScript in their browser context. This allows attackers to: * Steal authentication cookies and session tokens. * Perform arbitrary actions on behalf of the victim (e.g., modifying repositories, adding collaborators). * Redirect users to malicious sites.

CVE-2026-26022 Affected Gogs Versions

1 component(s)
Fixed Versions:
0.14.2
Product / Package Ecosystem Affected Versions Fixed Version
gogs.io/gogs
Go
< 0.14.2
0.14.2

References

Frequently Asked Questions

What is CVE-2026-26022?
CVE-2026-26022 is a security vulnerability in Gogs involving Stored XSS via data URI in issue comments under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Gogs versions are affected?
Affected versions include releases prior to 0.14.2 across affected packages: gogs.io/gogs.
What version fixes CVE-2026-26022?
Upgrading to 0.14.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gogs.io/gogs affected?
Yes, gogs.io/gogs is affected in releases prior to 0.14.2. Upgrade your dependency to 0.14.2 or later.
What is the CVSS score of CVE-2026-26022?
CVE-2026-26022 has a CVSS v3.1 base score of 8.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2026-26022?
CVE-2026-26022 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Go dependencies for CVE-2026-26022?
Run the dependency tree command: 'inspect dependencies for gogs.io/gogs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xrcr-gmf5-2r8j",
  "modified" : "2026-03-05T22:28:35Z",
  "published" : "2026-03-05T19:26:02Z",
  "aliases" : [ "CVE-2026-26022" ],
  "summary" : "Gogs: Stored XSS via data URI in issue comments",
  "details" : "### Summary\nA Stored Cross-site Scripting (XSS) vulnerability exists in the comment and issue description functionality. The application's HTML sanitizer explicitly allows `data:` URI schemes, enabling authenticated users to inject arbitrary JavaScript execution via malicious links.\n\n### Details\nThe vulnerability is located in `internal/markup/sanitizer.go`. The application uses the `bluemonday` HTML sanitizer but explicitly weakens the security policy by allowing the `data` URL scheme:\n\n```go\n// internal/markup/sanitizer.go\nfunc NewSanitizer() {\n    sanitizer.init.Do(func() {\n        // ...\n        // Data URLs\n        sanitizer.policy.AllowURLSchemes(\"data\")\n        // ...\n    })\n}\n```\n\nWhile the Markdown renderer rewrites relative links (mitigating standard Markdown `[link](data:...)` attacks), Gogs supports **Raw HTML** input. Raw HTML anchor tags bypass the Markdown parser's link rewriting and are processed directly by the sanitizer. Since the sanitizer is configured to allow `data:` URIs, payloads like `<a href=\"data:text/html...\">` are rendered as-is.\n\n### PoC\n1.  Create a file named `exploit.md` in a repository.\n2.  Add the following content (Raw HTML):\n    ```html\n    <a href=\"data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4=\">Click me for XSS</a>\n    ```\n3.  Commit and push the file.\n4.  Navigate to the file in the Gogs web interface.\n5.  Click the \"Click me for XSS\" link.\n6.  **Result:** An alert box with \"XSS\" appears, executing the JavaScript payload.\n\n### Impact\nThis is a **Stored XSS** vulnerability. Any user who views the malicious comment and clicks the link will execute the attacker-supplied JavaScript in their browser context. This allows attackers to:\n*   Steal authentication cookies and session tokens.\n*   Perform arbitrary actions on behalf of the victim (e.g., modifying repositories, adding collaborators).\n*   Redirect users to malicious sites.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "gogs.io/gogs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.14.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.14.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/security/advisories/GHSA-xrcr-gmf5-2r8j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-26022"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/pull/8174"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/commit/441c64d7bd8893b2f4e48660a8be3a7472e14291"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gogs/gogs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/releases/tag/v0.14.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-05T19:26:02Z",
    "nvd_published_at" : "2026-03-05T19:16:03Z"
  }
}