Skip to content

Gitea: Stored XSS via glTF `extensionsRequired` in Gitea 3D File Viewer

High severity GitHub Reviewed Published Jun 14, 2026 in go-gitea/gitea • Updated Jun 17, 2026

Package

gomod code.gitea.io/gitea (Go)

Affected versions

>= 1.25.0, < 1.26.0

Patched versions

1.26.0

Description

Summary

Me again.

Gitea's built-in 3D file viewer (powered by Online3DViewer) is vulnerable to stored cross-site scripting (XSS) through crafted .gltf files. When a glTF file declares an unsupported required extension, Online3DViewer generates an error message containing the extension name and Gitea inserts it into the DOM using innerHTML without sanitization. An attacker who can push a .gltf file to any repository can execute arbitrary JavaScript in the context of any user who views the file.

Affected Versions

  • Gitea 1.25.0 and later (3D file preview was introduced in 1.25 via the Online3DViewer integration)
  • Confirmed on gitea:1.25-nightly (SHA e33d1da...), which bundles online-3d-viewer npm package v0.16.0
  • The upstream Online3DViewer library is the root cause

Severity

  • Stored XSS: the payload persists in the repository and fires on every page view
  • Executes under the Gitea origin with the victim's session (cookies, CSRF tokens)
  • Any authenticated user viewing the file is compromised
  • Enables full account takeover (token creation, settings modification, repository manipulation)
  • No user interaction beyond viewing the file page is required

Details

Root Cause

When Online3DViewer parses a glTF file, it checks whether all extensionsRequired entries are supported. For unsupported extensions, it calls:

// In the Online3DViewer bundle (online-3d-viewer.js)
// Approximate offset 1142618 in the bundled chunk
this.SetError(yp("Unsupported extension: {0}.", unsupportedExtensions.join(", ")));

The SetError method stores this message, and Gitea's rendering code inserts it into the page using innerHTML:

// Gitea's error display handler
element.innerHTML = errorMessage;  // unsanitized

The extension names from extensionsRequired are taken directly from the JSON file with no escaping or sanitization, allowing HTML injection.

Attack Vector

  1. An attacker creates a .gltf file with a malicious extensionsRequired value:
{
  "asset": {"version": "2.0"},
  "buffers": [],
  "extensionsRequired": ["<img src=x onerror=\"alert(document.cookie)\">"],
  "scenes": []
}
  1. The attacker pushes this file to any Gitea repository they have write access to (including forks of public repositories).

  2. When any user navigates to the file's page in the Gitea web UI, the 3D viewer attempts to render it, encounters the "unsupported extension," and inserts the error message (containing the attacker's HTML) into the DOM via innerHTML.

  3. The injected <img onerror> handler executes arbitrary JavaScript under the Gitea origin with the victim's authenticated session.

Impact

From the XSS context, an attacker can:

  • Create API access tokens for the victim by POSTing to /user/settings/applications with the page's CSRF token
  • Read private repositories via same-origin API calls
  • Modify repository contents (supply chain attacks)
  • Escalate to admin if the victim is a Gitea administrator
  • Exfiltrate data via fetch, XMLHttpRequest, or navigator.sendBeacon

Proof of Concept

Minimal PoC (alert box)

Save as poc.gltf and push to any Gitea 1.25+ repository:

{
  "asset": {"version": "2.0"},
  "buffers": [],
  "extensionsRequired": ["<img src=x onerror=\"alert('XSS: '+document.domain)\">"],
  "scenes": []
}

Navigate to the file in the Gitea web UI. The alert will fire.

Suggested Fixes

Sanitize or text-encode the error message before DOM insertion. Replace innerHTML with textContent for error display:

// Instead of:
element.innerHTML = errorMessage;

// Use:
element.textContent = errorMessage;

Alternatively, escape HTML entities in the error message before insertion.

Additional hardening

  • Render 3D file previews inside a sandboxed <iframe> with sandbox="allow-scripts" and a restrictive CSP (default-src 'none'), similar to how Gitea already handles SVG attachments
  • Apply Content-Security-Policy headers to file preview pages that restrict inline script execution

References

@lunny lunny published to go-gitea/gitea Jun 14, 2026
Published to the GitHub Advisory Database Jun 17, 2026
Reviewed Jun 17, 2026
Last updated Jun 17, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N

EPSS score

Weaknesses

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. Learn more on MITRE.

CVE ID

CVE-2026-28737

GHSA ID

GHSA-9cpj-qc93-vw8v

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.