llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Go · gogs.io/gogs

GHSA-6972-PQ3Q-8W9R

Stored cross-site scripting in Gogs commit subjects through the external issue tracker format

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
8.7
Alta
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición3 dDesde la divulgación, 18 nov 2026, 11:43 a. m.
Detección6 hDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir de cerca
Monitorear y programar la remediación
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico total. No hay versión corregida: aplique mitigaciones.
Ojo de llama: esto puede escalar.Échale un ojo a tu inventario, ¿dale?
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
18 nov 26
22 nov 26
18 nov 26
19 nov 26
20 nov 26
21 nov 26
22 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-6972-PQ3Q-8W9R divulgada · CVSS 8.7 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
GitHub

Summary

A repository administrator can set the external issue tracker format to a `javascript:` URL. Commit subjects that contain an issue reference such as `#1` are then rendered as links whose target is that `javascript:` URL. The web API returns the link HTML without sanitization, and the React client inserts it with `dangerouslySetInnerHTML`. When a visitor clicks the reference, the script runs in the Gogs origin with the visitor's session.

The independent reviewer demonstrated the cross-user case: a normal user's public repository ran script in a signed-in site administrator's session after the administrator clicked the reference. It confirmed that this is stored XSS across principals, not self-XSS, and that the behavior is not intended.

The same class was reported in 2018 as issue #5545 and fixed by piping the commit message through the server-side sanitizer. The recent React migration removed the server templates and returned the raw HTML to the browser, so the sanitizer is no longer applied. The behavior is a regression of that fix.

Root Cause

The external tracker format is stored without a URL scheme check. It has no `validate` tag in `repoAdvancedSettings` (`cmd/gogs/internal/web/webapi_repo_settings.go:81-84`), while the sibling `ExternalTrackerStyle` is limited to `numeric` or `alphanumeric`. `putRepoAdvanced` assigns the value as received (`:348`). The API v1 route also assigns `TrackerURLFormat` without a scheme check (`internal/route/api/v1/repo_repo.go:442`).

`Repository.ComposeMetas` puts the value into `ExternalMetas["format"]` (`internal/database/repo.go:482-493`). `template.RenderCommitMessage` escapes the commit message with `template.HTMLEscapeString`, then calls `markup.RenderIssueIndexPattern` (`internal/template/template.go:43-65`). That function builds the link target with:

href = []byte(html.EscapeString(expand(metas["format"], match)))

`html.EscapeString` escapes HTML metacharacters. It does not restrict the URL scheme, so `javascript:document.body.dataset.xss=1//{index}` becomes `javascript:document.body.dataset.xss=1//1`.

The web API returns the result as `SubjectHTML` from `toCommitListItems` (`cmd/gogs/internal/web/webapi_commits.go:166`) and from the repository source handler (`cmd/gogs/internal/web/webapi_src.go:341`). Neither applies `markup.Sanitize`.

React inserts the string with `dangerouslySetInnerHTML` in `web/src/pages/repo/Commits.tsx:250,316` and `web/src/pages/repo/Code.tsx:958,1036`. React's `sanitizeURL` applies to `href` props set through JSX, not to HTML parsed from `innerHTML`, so the `javascript:` href remains in the DOM.

The regression is visible in the history. Issue #5545, "Stored XSS in external issue tracker URL format", was closed in December 2018. Commit `d3d8284`, "templates: sanitize special links in commit message (#5545)", changed the server templates to pipe `RenderCommitMessage` through `Str2html`, which sanitizes with bluemonday. The React migration (`37b859d`, `c413106`, and the related web API commits) removed those templates and returned the unsanitized `SubjectHTML` to the new client.

Prerequisites

  • The attacker can administer a repository. Any registered user can create a repository and becomes its admin, so no site administrator is needed.
  • The repository can be public, so any visitor can reach the commit history and the repository home.
  • The victim clicks the issue reference in the commit subject. The attacker can choose a commit subject such as `#1 fix login` so the link looks like a normal issue reference.
  • The repository enables the external issue tracker and stores the format. The normal settings page accepts the value, and the advanced settings API accepts it.

Steps to Reproduce

  1. Sign in as a user who can create a repository and create a public repository.
  2. Open the repository settings, then the advanced settings. Enable the external issue tracker, set the URL to `https://example.com`, set the style to numeric, and set the format to `javascript:alert(document.domain)//{index}` for the popup proof, or `javascript:document.body.dataset.xss=1//{index}` for the non-popup marker. Both were used.
  3. Create a commit whose subject contains `#1`, for example `#1 xss`. The lab used `PUT /api/v1/repos/{owner}/{repo}/contents/README.md` with `{"message":"#1 xss","content":"...","branch":"main"}`.
  4. Load `/{owner}/{repo}/commits/main` in a browser while signed in.
  5. The server returns `subjectHTML` with the configured href, for example `<a href="javascript:alert(document.domain)//1">#1</a> xss` or `<a href="javascript:document.body.dataset.xss=1//1">#1</a> xss`. The page renders it through `dangerouslySetInnerHTML`.
  6. Click the `#1` link. With the alert payload, the browser opens an alert with the message `127.0.0.1`, the Gogs origin. The recorded CDP event is `Page.javascriptDialogOpening` with `type: "alert"` and `message: "127.0.0.1"`, and accepting it returns true. With the marker payload, `document.body.dataset.xss` changes from undefined to `"1"`.

<img width="1917" height="967" alt="image" src="https://github.com/user-attachments/assets/69b8b127-06ba-4df4-8080-f5ccf63b56e8" />

The settings can also be saved with `PUT /api/web/{owner}/{repo}/settings/advanced` and a JSON body that contains the same fields. The lab used the path `//api/web/labadmin/xss/settings/advanced` with Basic credentials, which also exercises the separate path bypass, but a normal signed-in repository administrator can use the canonical path.

Impact

  • Any visitor who clicks the issue reference runs attacker script in the Gogs origin. The script can call the same-origin web API as the victim.
  • If the victim is a site administrator, the script can reach the admin web API, read the admin user list and configuration, and perform admin actions. If the victim is a normal user, the script can read their repositories and settings, change their profile, add an SSH key, create access tokens, or disable their two-factor authentication.
  • The session cookie is HttpOnly, but the script does not need to read it. Same-origin requests carry it automatically.
  • The attacker can make the link look like a normal issue reference, so the click is plausible. The repository can be public and the commit history is normally visited by maintainers and reviewers.
  • The attack requires the victim to click the reference. It does not execute on page load.

The demonstrated impact is stored script execution in the Gogs origin with the victim's session. It can lead to full account takeover of the victim, including an administrator. It does not by itself give code execution on the server.

Expected Result

The external tracker format should be restricted to `http` and `https` URLs, and the rendered commit subject should be sanitized before it reaches the browser. A `javascript:` format should be rejected at save time and must never become an anchor target. The React client should not insert unsanitized server strings with `dangerouslySetInnerHTML`.

Suggested Fix

Validate the scheme of `ExternalTrackerFormat` and of the expanded link target. Accept only `http` and `https`. Reject or strip other schemes at save time in both the web settings handler and the API v1 handler, and check again when the link is built.

Restore the 2018 sanitizer at the new API boundary. Before `SubjectHTML` is returned from `webapi_commits.go` and `webapi_src.go`, pass the `RenderCommitMessage` output through `markup.Sanitize`, or apply an equivalent sanitizer in the React client before `dangerouslySetInnerHTML`. The server-side check is the safer of the two because the API is also used by other clients.

Add a Content Security Policy that blocks inline script without a nonce, as defense in depth, and add regression tests with `javascript:`, `data:`, and `vbscript:` formats in commit subjects.

References

  • Gogs commit `4816842955f4b49e0dc510b5c088f6da13f26455`, main on 2026-11-17.
  • gogs/gogs issue #5545, "Stored XSS in external issue tracker URL format", closed 2018-12-12.
  • Gogs commit `d3d8284`, "templates: sanitize special links in commit message (#5545)".
  • `internal/template/template.go:43-65`, `RenderCommitMessage`.
  • `internal/markup/markup.go:191-197`, the issue reference href.
  • `cmd/gogs/internal/web/webapi_repo_settings.go:81-84,348`, the unvalidated setting.
  • `internal/route/api/v1/repo_repo.go:442`, the API v1 assignment.
  • `cmd/gogs/internal/web/webapi_commits.go:166` and `webapi_src.go:341`, the unsanitized `SubjectHTML`.
  • `web/src/pages/repo/Commits.tsx:250,316` and `web/src/pages/repo/Code.tsx:958,1036`, the `dangerouslySetInnerHTML` sinks.
  • Commit `37b859d` and `c413106`, the React migration that removed the server template sanitizer.
  • GHSA-4j89-2c4f-44c6 / PR #8312, the denial of service in the same external tracker setting.
Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:L
NingunoBajosAltos
InteracciónUI:R
NingunaRequerida
AlcanceS:C
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:N
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
7.2/ 10Alto
Vector 7.2 (fácil) · sin evidencia de explotación.
Versiones

Versiones afectadas

0.15.0+dev
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
gogogs.io/gogs
Sin parche — — v0.13.3 no afectada
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/gogs/gogs/security/advisories/GHSA-6972-pq3q-8w9r

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.