{"id":"CVE-2026-120729","kind":"vulnerability","aliases":["CVE-2026-120729","GHSA-wmr3-xg9x-vc55"],"related":[],"title":"Stored XSS: issue context popup loads a linked raw file as issue info","description":"A stored XSS in the issue reference popup lets any regular Gitea user run script on the Gitea origin, in the session of another signed-in user, when that user rests the mouse on what looks like an ordinary `#1` issue reference. No click is needed. The attacker commits a JSON file to their own repository and posts a link into that file's raw path in an issue, pull request or comment. Gitea renders the link as `#1`. On hover, the victim's frontend fetches the attacker's file and inserts one of its fields into the page as HTML. This works on default settings. The attacker needs an issued account (self-registration is off by default), a repository the victim can read, and a host to serve a script.\n\nThe cause is that `showRefIssuePopup` (`web_src/js/features/ref-issue.ts:26`) requests `${link.pathname}/info` instead of the real `/{owner}/{repo}/issues/{index}/info` endpoint. `ContextPopup.vue` then renders the answer's `renderedLabels` with `v-html`. Two checks fail to stop an arbitrary path from reaching this code:\n\n- `parseIssueHref` uses an unanchored regex.\n- `fullIssuePatternProcessor` gives the `ref-issue` class and `#N` text to any same-site URL that merely ends in `/owner/repo/issues/N`.\n\nAs a result, `/mallory/x/raw/branch/main/alice/app/issues/1` is treated as a genuine reference, and the popup loads mallory's committed file through the raw route. Links inside the dashboard feed and repo activity (`[data-ref-issue-container]`) reach the popup even without the class.\n\nThe attached reproducer runs the shipped frontend bundle in happy-dom with the victim's session. It shows the hover fetching the attacker's file, an `<iframe srcdoc>` being inserted, and the attacker's externally hosted script reading the victim's page URL and user name. happy-dom does not enforce Content-Security-Policy, so execution in a real browser has not been observed. It follows from the page's `script-src *` policy, which permits an external script inside a same-origin `srcdoc` frame.\n\nThe behaviour was introduced in 12d83cbfa3ca (\"Extend issue context popup beyond markdown content (#36908)\", first in v1.27.0-rc0). Before that commit, the popup built its request URL from the parsed owner, repo and index.\n\n## Details\n\nCommit `31626de2a6cdd3e1fe93216e4ac80f511297f1e7`, default configuration. The attacker is a regular user (self-registration is off by default, so an account the site has issued) with a public repository of their own who can write an issue, pull request or comment that the victim reads. The victim rests the mouse for 300 ms on a link that is rendered as an ordinary `#1` issue reference; nothing is clicked.\n\nThe issue reference popup takes its data from the path of the hovered link plus `/info`, and inserts one field of the answer as HTML:\n\n```ts\n// web_src/js/features/ref-issue.ts:24\nasync function showRefIssuePopup(link: HTMLAnchorElement) {\n  const [data, {default: ContextPopup}] = await Promise.all([\n    getIssueInfo(`${link.pathname}/info`),                 // :26\n    …\n  const app = createApp(ContextPopup, {\n    issue: data.convertedIssue,\n    renderedLabels: data.renderedLabels,                   // :32\n```\n\n```html\n<!-- web_src/js/components/ContextPopup.vue:43 -->\n<div v-if=\"issue.labels.length\" v-html=\"renderedLabels\"/>\n```\n\nThis is safe only while `<path>/info` is the route `GET /{owner}/{repo}/(issues|pulls)/{index}/info` (`routers/web/web.go:1313`), where `GetIssueInfo` builds `renderedLabels` on the server with `RenderLabels` (`routers/web/repo/issue.go:274`). Nothing restricts the link to that route. For the link\n\n```\nhttp://<gitea>/mallory/x/raw/branch/main/alice/app/issues/1\n```\n\nthe popup requests `/mallory/x/raw/branch/main/alice/app/issues/1/info`, which is the file `alice/app/issues/1/info` on branch `main` of mallory's repository `mallory/x`, served by the raw route (`routers/web/web.go:1696`). Its content is whatever mallory committed.\n\nTwo conditions decide whether a hovered link gets the popup (`ref-issue.ts:52-53`), and the link above meets both.\n\nThe first is `parseIssueHref`, whose expression is not anchored, so any path that *contains* `a/b/issues/N` passes:\n\n```ts\n// web_src/js/utils.ts:52\nexport function parseIssueHref(href: string): IssuePathInfo | null {\n  // FIXME: it should use pathname and trim the appSubUrl ahead\n  const path = (href || '').replace(/[#?].*$/, '');\n  const match = /([^/]+)\\/([^/]+)\\/(issues|pulls)\\/([0-9]+)/.exec(path);\n```\n\nThe second is that the link has the class `ref-issue` or sits inside a `[data-ref-issue-container]`. The markup backend hands out that class itself. `issueFullPattern` (`modules/markup/html.go:81`) starts with `https?://(?:\\S+/)`, so it matches any URL that *ends* in `/a/b/issues/N`, and `fullIssuePatternProcessor` (`modules/markup/html_issue.go:47-73`) only checks that the URL is on the current site, takes the last path segments as owner and repository, and emits the link with class `ref-issue`. Written as a bare URL in an issue of `alice/app`, the link above is rendered as\n\n```html\n<a href=\"http://<gitea>/mallory/x/raw/branch/main/alice/app/issues/1\" class=\"ref-issue\" …>#1</a>\n```\n\nwhich reads `#1`, exactly like the genuine reference to `alice/app#1`.\n\nWhat was observed: the shipped frontend bundle, run in a DOM emulation (happy-dom) with alice's session, requests mallory's file on hover and inserts the iframe into the document; the emulation then loads `x.js`, which reads `top.location` and the signed-in user name from the parent page. The same run on a genuine reference requests `/alice/app/issues/1/info` and inserts no frame.\n\nWhat was not observed, because no browser is available offline: enforcement of the page's Content-Security-Policy, which happy-dom does not implement. The policy is delivered as a meta tag (`services/context/context_template.go:136-142`), and the issue page carries no policy header:\n\n```\ndefault-src * data: blob:;script-src * 'nonce-…';style-src * 'unsafe-inline';\n```\n\nIt stops inline scripts and inline event handlers, which is why the payload is not `<script>…</script>` or `onerror=`. It does not stop this payload: a `srcdoc` frame has the origin of its parent and inherits the parent's policy, the script in it is a parser-inserted external script, and `script-src *` allows an external script from any host. The frame has no `sandbox` attribute, so the script reaches the Gitea page through `top`.\n\nThe `[data-ref-issue-container]` branch of the second condition needs no backend help at all. The dashboard activity feed (`templates/user/dashboard/feeds.tmpl:1`) is such a container, and a comment `[more details](/mallory/x/raw/branch/main/alice/app/issues/1)` on an issue in alice's repository shows up in alice's own dashboard feed as a link with that href and free text. In the same emulation, hovering it on `/` requests mallory's file and runs the script there. `templates/repo/activity.tmpl:8` is the other container.\n\n## Impact\n\nA regular user can run script on the Gitea origin in the session of any user who hovers a planted reference: in an issue, pull request or comment of any repository the attacker may post in (including the victim's own), or in the victim's dashboard feed. The link is indistinguishable from a normal `#N` reference and the only interaction is resting the mouse on it. The script can read everything the victim can see and perform any web UI action as the victim; for a site administrator that includes the admin pages. Preconditions: an account (registration is off by default, so one the site has issued), one public repository (or any repository the victim can read) to host the file, and a host that serves the script to the victim's browser. No non-default setting is involved. The fetch and the insertion of the attacker's HTML are demonstrated; that a real browser then runs the external script follows from the page's `script-src *` policy (see *Details*) and was shown only in a DOM emulation that does not enforce the policy.\n\nThe popup has requested `<link pathname>/info` since `12d83cbfa3ca` (\"Extend issue context popup beyond markdown content (#36908)\", 2026-04-23), first released in v1.27.0-rc0; at its parent the same planted link makes the popup fetch the genuine `/alice/app/issues/1/info`.\n\n## Suggested fix\n\nTwo patches are attached; both stop deriving the endpoint from the link, and patch 2 adds one extra check on top of patch 1. Either one suffices; patch 2 is the recommended one.\n\nAttached patch 1 does what the `FIXME` in `parseIssueHref` asks for. In `web_src/js/utils.ts`, `parseIssueHref` resolves the href with `new URL(href, window.location.href)`, requires the pathname to start with `window.config.appSubUrl`, and matches the rest against `^/([-.\\w]+)/([-.\\w]+)/(issues|pulls)/([0-9]+)(?:/|$)`, so a path that merely *contains* `a/b/issues/N` (such as mallory's raw-file path) no longer parses, while pull-request sub-pages like `/pulls/1/files` still do. In `web_src/js/features/ref-issue.ts`, `initRefIssueContextPopup` passes the parsed result on, and `showRefIssuePopup` builds the request as `${appSubUrl}/${ownerName}/${repoName}/${pathType}/${indexString}/info`, so it can only reach `GetIssueInfo`. `parseIssueHref` has one other caller, `web_src/js/features/comp/TextExpander.ts:13`, which passes `window.location.href` and keeps working, including under a sub-path. One behaviour change: an issue path that does not start at `appSubUrl` (e.g. `/sub/owner/repo/issues/1` with no sub-path configured) no longer parses. The patch updates `web_src/js/utils.test.ts` accordingly, setting `appSubUrl` for the sub-path cases and adding cases such as `/other/x/raw/branch/main/owner/repo/issues/1` → `null`; that vitest suite needs a Playwright browser and should be run before merging.\n\nAttached patch 2 is patch 1 plus a check in `getIssueInfo`: an answer whose `Content-Type` is not `application/json` is rejected before it can reach `v-html`, following the existing pattern in `web_src/js/modules/fetch-action.ts`. `GetIssueInfo` answers with `ctx.JSON`, so the genuine popup is unaffected, while a raw file (served as `text/plain`) or any future route mix-up fails instead of being rendered.\n\nFollow-ups that neither patch includes. On the backend, `fullIssuePatternProcessor` should give the `ref-issue` class and the `#N` text only to URLs whose path after `AppSubURL` is exactly `/{owner}/{repo}/(issues|pulls)/{index}`; today any same-site URL with that suffix is displayed as a reference to an issue it does not point to. The backend change alone is not sufficient, because links inside `[data-ref-issue-container]` reach the popup without the class. The patched parser also ignores the link's host, so a link to another site with an issue-shaped path shows the local issue's popup; this is harmless and already the case today, and comparing the origin would tidy it. Longer term, rendering the popup's labels from data would remove the `v-html`.\n\n## Suggested patch\n\n```diff\ndiff --git a/web_src/js/features/ref-issue.ts b/web_src/js/features/ref-issue.ts\nindex 3abb2f4382..7b968757fc 100644\n--- a/web_src/js/features/ref-issue.ts\n+++ b/web_src/js/features/ref-issue.ts\n@@ -3,7 +3,9 @@ import {GET} from '../modules/fetch.ts';\n import {createApp} from 'vue';\n import {createTippy, getAttachedTippyInstance} from '../modules/tippy.ts';\n import {addDelegatedEventListener} from '../utils/dom.ts';\n-import type {Issue, TimeoutId} from '../types.ts';\n+import type {Issue, IssuePathInfo, TimeoutId} from '../types.ts';\n+\n+const {appSubUrl} = window.config;\n \n type IssueInfo = {\n   convertedIssue: Issue,\n@@ -21,9 +23,11 @@ async function getIssueInfo(url: string): Promise<IssueInfo> {\n   return data;\n }\n \n-async function showRefIssuePopup(link: HTMLAnchorElement) {\n+async function showRefIssuePopup(link: HTMLAnchorElement, issuePathInfo: IssuePathInfo) {\n+  const {ownerName, repoName, pathType, indexString} = issuePathInfo;\n   const [data, {default: ContextPopup}] = await Promise.all([\n-    getIssueInfo(`${link.pathname}/info`),\n+    // the response is rendered as HTML, so the URL must be built from the parsed parts and never from the link's own path\n+    getIssueInfo(`${appSubUrl}/${ownerName}/${repoName}/${pathType}/${indexString}/info`),\n     import('../components/ContextPopup.vue'),\n   ]);\n   const el = document.createElement('div');\n@@ -49,7 +53,8 @@ async function showRefIssuePopup(link: HTMLAnchorElement) {\n export function initRefIssueContextPopup() {\n   const selector = 'a[href]:not([data-ref-issue-popup]):not(.ref-external-issue)';\n   addDelegatedEventListener<HTMLAnchorElement, MouseEvent>(document, 'mouseover', selector, (link) => {\n-    if (!parseIssueHref(link.getAttribute('href')!)) return;\n+    const issuePathInfo = parseIssueHref(link.getAttribute('href')!);\n+    if (!issuePathInfo) return;\n     if (!link.classList.contains('ref-issue') && !link.closest('[data-ref-issue-container]')) return;\n     if (getAttachedTippyInstance(link)) return;\n     link.setAttribute('data-ref-issue-popup', '');\n@@ -64,7 +69,7 @@ export function initRefIssueContextPopup() {\n     timer = setTimeout(async () => {\n       link.removeEventListener('mouseleave', cancel);\n       try {\n-        await showRefIssuePopup(link);\n+        await showRefIssuePopup(link, issuePathInfo);\n       } catch (err) {\n         console.error('Failed to load issue info:', err);\n         link.removeAttribute('data-ref-issue-popup');\ndiff --git a/web_src/js/utils.test.ts b/web_src/js/utils.test.ts\nindex 8c0a6c1318..d6e52e3acd 100644\n--- a/web_src/js/utils.test.ts\n+++ b/web_src/js/utils.test.ts\n@@ -40,18 +40,27 @@ test('parseIssueHref', () => {\n   expect(parseIssueHref('/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n   expect(parseIssueHref('/owner/repo/pulls/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n   expect(parseIssueHref('/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('/sub/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('/sub/sub2/owner/repo/pulls/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n-  expect(parseIssueHref('/sub/sub2/owner/repo/issues/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('/sub/sub2/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n+  expect(parseIssueHref('/owner/repo/pulls/1/files')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n   expect(parseIssueHref('https://example.com/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n   expect(parseIssueHref('https://example.com/owner/repo/pulls/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n   expect(parseIssueHref('https://example.com/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/pulls/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n   expect(parseIssueHref('')).toBeNull();\n+  expect(parseIssueHref('/owner/repo/issues/1a')).toBeNull();\n+  expect(parseIssueHref('/owner/repo/issues/new')).toBeNull();\n+  // the issue path must start at the site root, a user-controlled path must not be mistaken for an issue link\n+  expect(parseIssueHref('/sub/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/other/x/raw/branch/main/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('https://example.com/other/x/raw/branch/main/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/other\\\\x\\\\raw\\\\branch\\\\main\\\\owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('mailto:/other\\\\x\\\\raw\\\\branch\\\\main\\\\owner/repo/issues/1')).toBeNull();\n+  window.config.appSubUrl = '/sub';\n+  expect(parseIssueHref('/sub/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n+  expect(parseIssueHref('/sub/owner/repo/pulls/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n+  expect(parseIssueHref('https://example.com/sub/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n+  expect(parseIssueHref('/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/sub/sub2/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/sub/owner/repo/raw/branch/main/other/repo/issues/1')).toBeNull();\n+  window.config.appSubUrl = '';\n });\n \n test('parseRepoOwnerPathInfo', () => {\ndiff --git a/web_src/js/utils.ts b/web_src/js/utils.ts\nindex b2a4427bc6..76dfe703b2 100644\n--- a/web_src/js/utils.ts\n+++ b/web_src/js/utils.ts\n@@ -49,10 +49,19 @@ export function stripTags(text: string): string {\n   return text;\n }\n \n+/** parse the owner, repo, type and index from an issue/pull link like \"/sub/owner/repo/issues/1\" */\n export function parseIssueHref(href: string): IssuePathInfo | null {\n-  // FIXME: it should use pathname and trim the appSubUrl ahead\n-  const path = (href || '').replace(/[#?].*$/, '');\n-  const match = /([^/]+)\\/([^/]+)\\/(issues|pulls)\\/([0-9]+)/.exec(path);\n+  let pathname: string;\n+  try {\n+    pathname = new URL(href, window.location.href).pathname;\n+  } catch {\n+    return null;\n+  }\n+  const appSubUrl = window.config.appSubUrl;\n+  if (!pathname.startsWith(`${appSubUrl}/`)) return null;\n+  // the match must be anchored to the site root, otherwise user-controlled paths like\n+  // \"/owner/repo/raw/branch/main/other/repo/issues/1\" would also be treated as issue links\n+  const match = /^\\/([-.\\w]+)\\/([-.\\w]+)\\/(issues|pulls)\\/([0-9]+)(?:\\/|$)/.exec(pathname.substring(appSubUrl.length));\n   if (!match) return null;\n   const [, ownerName, repoName, pathType, indexString] = match;\n   return {ownerName, repoName, pathType, indexString};\ndiff --git a/web_src/js/features/ref-issue.ts b/web_src/js/features/ref-issue.ts\nindex 3abb2f4382..776aa98a2b 100644\n--- a/web_src/js/features/ref-issue.ts\n+++ b/web_src/js/features/ref-issue.ts\n@@ -3,7 +3,9 @@ import {GET} from '../modules/fetch.ts';\n import {createApp} from 'vue';\n import {createTippy, getAttachedTippyInstance} from '../modules/tippy.ts';\n import {addDelegatedEventListener} from '../utils/dom.ts';\n-import type {Issue, TimeoutId} from '../types.ts';\n+import type {Issue, IssuePathInfo, TimeoutId} from '../types.ts';\n+\n+const {appSubUrl} = window.config;\n \n type IssueInfo = {\n   convertedIssue: Issue,\n@@ -16,14 +18,18 @@ async function getIssueInfo(url: string): Promise<IssueInfo> {\n   if (issueInfoCache.has(url)) return issueInfoCache.get(url)!;\n   const resp = await GET(url);\n   if (!resp.ok) throw new Error(resp.statusText || 'Unknown network error');\n+  // the response is rendered as HTML, never accept anything but the JSON from the issue info endpoint\n+  if (!resp.headers.get('content-type')?.includes('application/json')) throw new Error('Unexpected response content type');\n   const data = await resp.json();\n   issueInfoCache.set(url, data);\n   return data;\n }\n \n-async function showRefIssuePopup(link: HTMLAnchorElement) {\n+async function showRefIssuePopup(link: HTMLAnchorElement, issuePathInfo: IssuePathInfo) {\n+  const {ownerName, repoName, pathType, indexString} = issuePathInfo;\n   const [data, {default: ContextPopup}] = await Promise.all([\n-    getIssueInfo(`${link.pathname}/info`),\n+    // the response is rendered as HTML, so the URL must be built from the parsed parts and never from the link's own path\n+    getIssueInfo(`${appSubUrl}/${ownerName}/${repoName}/${pathType}/${indexString}/info`),\n     import('../components/ContextPopup.vue'),\n   ]);\n   const el = document.createElement('div');\n@@ -49,7 +55,8 @@ async function showRefIssuePopup(link: HTMLAnchorElement) {\n export function initRefIssueContextPopup() {\n   const selector = 'a[href]:not([data-ref-issue-popup]):not(.ref-external-issue)';\n   addDelegatedEventListener<HTMLAnchorElement, MouseEvent>(document, 'mouseover', selector, (link) => {\n-    if (!parseIssueHref(link.getAttribute('href')!)) return;\n+    const issuePathInfo = parseIssueHref(link.getAttribute('href')!);\n+    if (!issuePathInfo) return;\n     if (!link.classList.contains('ref-issue') && !link.closest('[data-ref-issue-container]')) return;\n     if (getAttachedTippyInstance(link)) return;\n     link.setAttribute('data-ref-issue-popup', '');\n@@ -64,7 +71,7 @@ export function initRefIssueContextPopup() {\n     timer = setTimeout(async () => {\n       link.removeEventListener('mouseleave', cancel);\n       try {\n-        await showRefIssuePopup(link);\n+        await showRefIssuePopup(link, issuePathInfo);\n       } catch (err) {\n         console.error('Failed to load issue info:', err);\n         link.removeAttribute('data-ref-issue-popup');\ndiff --git a/web_src/js/utils.test.ts b/web_src/js/utils.test.ts\nindex 8c0a6c1318..d6e52e3acd 100644\n--- a/web_src/js/utils.test.ts\n+++ b/web_src/js/utils.test.ts\n@@ -40,18 +40,27 @@ test('parseIssueHref', () => {\n   expect(parseIssueHref('/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n   expect(parseIssueHref('/owner/repo/pulls/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n   expect(parseIssueHref('/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('/sub/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('/sub/sub2/owner/repo/pulls/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n-  expect(parseIssueHref('/sub/sub2/owner/repo/issues/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('/sub/sub2/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n+  expect(parseIssueHref('/owner/repo/pulls/1/files')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n   expect(parseIssueHref('https://example.com/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n   expect(parseIssueHref('https://example.com/owner/repo/pulls/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n   expect(parseIssueHref('https://example.com/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/pulls/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n-  expect(parseIssueHref('https://example.com/sub/sub2/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n   expect(parseIssueHref('')).toBeNull();\n+  expect(parseIssueHref('/owner/repo/issues/1a')).toBeNull();\n+  expect(parseIssueHref('/owner/repo/issues/new')).toBeNull();\n+  // the issue path must start at the site root, a user-controlled path must not be mistaken for an issue link\n+  expect(parseIssueHref('/sub/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/other/x/raw/branch/main/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('https://example.com/other/x/raw/branch/main/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/other\\\\x\\\\raw\\\\branch\\\\main\\\\owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('mailto:/other\\\\x\\\\raw\\\\branch\\\\main\\\\owner/repo/issues/1')).toBeNull();\n+  window.config.appSubUrl = '/sub';\n+  expect(parseIssueHref('/sub/owner/repo/issues/1')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n+  expect(parseIssueHref('/sub/owner/repo/pulls/1?query')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'pulls', indexString: '1'});\n+  expect(parseIssueHref('https://example.com/sub/owner/repo/issues/1#hash')).toEqual({ownerName: 'owner', repoName: 'repo', pathType: 'issues', indexString: '1'});\n+  expect(parseIssueHref('/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/sub/sub2/owner/repo/issues/1')).toBeNull();\n+  expect(parseIssueHref('/sub/owner/repo/raw/branch/main/other/repo/issues/1')).toBeNull();\n+  window.config.appSubUrl = '';\n });\n \n test('parseRepoOwnerPathInfo', () => {\ndiff --git a/web_src/js/utils.ts b/web_src/js/utils.ts\nindex b2a4427bc6..76dfe703b2 100644\n--- a/web_src/js/utils.ts\n+++ b/web_src/js/utils.ts\n@@ -49,10 +49,19 @@ export function stripTags(text: string): string {\n   return text;\n }\n \n+/** parse the owner, repo, type and index from an issue/pull link like \"/sub/owner/repo/issues/1\" */\n export function parseIssueHref(href: string): IssuePathInfo | null {\n-  // FIXME: it should use pathname and trim the appSubUrl ahead\n-  const path = (href || '').replace(/[#?].*$/, '');\n-  const match = /([^/]+)\\/([^/]+)\\/(issues|pulls)\\/([0-9]+)/.exec(path);\n+  let pathname: string;\n+  try {\n+    pathname = new URL(href, window.location.href).pathname;\n+  } catch {\n+    return null;\n+  }\n+  const appSubUrl = window.config.appSubUrl;\n+  if (!pathname.startsWith(`${appSubUrl}/`)) return null;\n+  // the match must be anchored to the site root, otherwise user-controlled paths like\n+  // \"/owner/repo/raw/branch/main/other/repo/issues/1\" would also be treated as issue links\n+  const match = /^\\/([-.\\w]+)\\/([-.\\w]+)\\/(issues|pulls)\\/([0-9]+)(?:\\/|$)/.exec(pathname.substring(appSubUrl.length));\n   if (!match) return null;\n   const [, ownerName, repoName, pathType, indexString] = match;\n   return {ownerName, repoName, pathType, indexString};\n\n```\n\n\n_Reported by the Anthropic OSS scanner, finding ANT-2026-UXY3CBIH (scan gitea-20261022-004), commit 31626de2a6cdd3e1fe93216e4ac80f511297f1e7._","summary":"Gitea's issue reference popup fetches a path built from the hovered link and inserts part of the response as HTML, so a crafted link pointing at a raw file in an attacker's repository can run script in another signed-in user's browser session when hovered. The attacker can read anything the victim sees and act as the victim, including administrators.","severity":"high","cvss":null,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"gitea.dev","fixed":["28.4.0"],"affected":">= 1.27, <= 28.3.0","ecosystem":"go"}],"ecosystems":["go"],"tags":["cwe-79","gitea","package","self-hosted"],"not_affected_if":["managed-hosting-patched","version-before-1.27"],"how_to_check":"- Run `gitea --version` or check the Gitea server version in the admin dashboard and compare to the affected range `>= 1.27, <= 28.3.0`.\n- Check the Gitea version pinned in your deployment config or container image tag.","fix":"- Gitea `28.4.0`\n- Two proposed patches exist in the advisory, but the sources do not state them as shipped fixes.","status":"open","published_at":"2026-11-15T21:03:07+00:00","first_seen_at":"2026-11-15T21:12:48+00:00","triaged_at":"2026-11-15T21:14:23+00:00","updated_at":"2026-11-15T21:14:23+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-11-15T21:14:23Z","model":"claude-haiku-5-5","output":{"fix":"- Gitea `28.4.0`\n- Two proposed patches exist in the advisory, but the sources do not state them as shipped fixes.","reach":"internet","title":"Gitea: issue hover popup lets a planted link run script in victims' sessions","impact":"high","summary":"Gitea's issue reference popup fetches a path built from the hovered link and inserts part of the response as HTML, so a crafted link pointing at a raw file in an attacker's repository can run script in another signed-in user's browser session when hovered. The attacker can read anything the victim sees and act as the victim, including administrators.","audience":"businesses","category":"package","nicknames":[],"who_cares":["gitea","self-hosted"],"confidence":0.8,"fix_status":"available","needs_auth":"yes","worst_case":"Attacker script runs in victim session and reads or acts as victim","analyst_note":"Confirm in a real browser whether the CSP script-src * allows execution inside srcdoc; source: https://github.com/go-gitea/gitea/security/advisories/GHSA-wmr3-xg9x-vc55","how_to_check":"- Run `gitea --version` or check the Gitea server version in the admin dashboard and compare to the affected range `>= 1.27, <= 28.3.0`.\n- Check the Gitea version pinned in your deployment config or container image tag.","plain_action":"","product_name":"","needs_analyst":true,"not_affected_if":["version-before-1.27","managed-hosting-patched"],"who_is_affected":"Any self-hosted Gitea instance from 1.27 through 28.3.0 is exposed, because the popup behaviour is on by default and any account the site has issued can plant the link. Instances on versions before 1.27 are not affected by this code path, and the advisory notes the flaw was introduced in 1.27.0-rc0.","user_interaction":"yes","product_ecosystem":"","needs_special_setup":"no","severity_if_unknown":"high"},"cost_usd":0.00124,"input_tokens":9102,"output_tokens":660,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-120729':16A,24A '-2026':15A,23A '-53':665C '-79':27B '/info':240C,249C,545C,572C,589C,599C '/issues':247C '/mallory/x/raw/branch/main/alice/app/issues/1':303C,623C '/mallory/x/raw/branch/main/alice/app/issues/1/info':627C '/owner/repo/issues/n':299C '1':137C,176C,524C '12d83cbfa3ca':434C '1313':601C '1696':647C '24':558C '26':237C,573C '274':612C '300':513C '31626de2a6cdd3e1fe93216e4ac80f511297f1e7':464C '32':582C '36908':442C 'account':209C,482C 'act':91B 'activ':329C 'administr':96B 'alice/app/issues/1/info':632C 'anoth':72B,120C 'answer':255C,552C 'anyth':86B 'app':575C 'arbitrari':268C 'async':559C 'attach':343C 'attack':65B,83B,145C,185C,205C,365C,373C,468C 'await':568C 'behaviour':430C 'beyond':439C 'branch':634C 'browser':78B,402C 'build':604C 'built':41B,451C 'bundl':349C 'caus':231C 'check':263C 'class':285C,341C 'click':141C,529C 'code':273C 'comment':170C,502C 'commit':146C,316C,448C,463C,653C 'condit':655C 'configur':466C 'const':564C,574C 'contain':334C 'content':394C,441C,649C 'content-security-polici':393C 'context':4A,437C 'contextpopup':567C,577C 'contextpopup.vue':251C 'craft':56B 'createapp':576C 'cve':14A,22A 'cwe':26B 'dashboard':325C 'data':331C,536C,565C 'data-ref-issue-contain':330C 'data.convertedissue':579C 'data.renderedlabels':581C 'decid':656C 'default':202C,216C,465C,479C,566C 'detail':462C 'dom':353C,389C 'end':297C 'endpoint':250C 'enforc':392C 'even':338C 'execut':398C 'extend':435C 'extern':375C,420C 'fail':264C 'feed':326C 'fetch':38B,183C,363C 'field':193C,549C 'file':10A,62B,149C,160C,187C,317C,367C,631C 'first':443C 'follow':408C 'frame':428C 'frontend':182C,348C 'fullissuepatternprocessor':279C 'function':560C 'genuin':308C 'get':593C,661C 'getissueinfo':570C,603C 'ghsa':18A 'ghsa-wmr3-xg9x-vc55':17A 'gitea':28B,33B,108C,114C,171C 'gitea.dev':25A 'give':280C 'happi':352C,388C 'happy-dom':351C,387C 'host':32B,225C,376C 'hover':44B,81B,178C,362C,542C,659C 'html':53B,198C,261C,554C,583C 'htmlanchorel':563C 'includ':95B 'index':248C,461C,598C 'info':13A 'insert':47B,189C,370C,547C 'insid':323C,422C 'instead':241C 'introduc':432C 'issu':3A,12A,35B,102C,138C,166C,208C,284C,333C,436C,486C,498C,525C,531C,578C,596C 'json':148C 'let':105C 'like':134C 'link':8A,45B,57B,157C,174C,322C,517C,543C,562C,616C,622C,660C 'link.pathname':239C,571C 'load':6A,313C 'look':133C 'main':635C 'mallori':314C,637C,652C 'mallory/x':640C 'markdown':440C 'mere':296C 'mous':130C,511C 'ms':514C 'n':287C 'name':386C 'need':143C,206C 'noth':527C,613C 'observ':406C 'one':190C,548C 'ordinari':136C,523C 'origin':115C,426C 'owner':245C,458C,594C 'packag':29B 'page':196C,382C,411C 'pars':457C 'parseissuehref':274C 'part':48B 'path':40B,163C,269C,539C 'permit':418C 'plus':544C 'point':58B 'polici':396C,416C 'popup':5A,37B,104C,312C,337C,438C,450C,533C,625C,663C 'post':155C 'promise.all':569C 'public':489C 'pull':167C,499C,597C 'raw':9A,61B,162C,320C,644C 'reach':271C,335C 'read':85B,222C,378C,506C 'real':244C,401C 'ref':283C,332C 'ref-issu':282C 'ref-issue.ts:52':664C 'refer':36B,103C,139C,309C,526C,532C 'regex':278C 'registr':212C,475C 'regular':107C,471C 'render':172C,253C,520C 'renderedlabel':257C,580C,605C 'renderlabel':610C 'repo':246C,328C,459C,595C 'repositori':67B,153C,218C,490C,639C 'reproduc':344C 'request':168C,238C,453C,500C,626C 'respons':51B 'rest':128C,509C 'restrict':614C 'result':302C 'rout':321C,592C,619C,645C 'routers/web/repo/issue.go':611C 'routers/web/web.go':600C,646C 'run':69B,110C,345C 'safe':586C 'same-origin':424C 'same-sit':291C 'script':70B,111C,229C,377C,414C,421C 'script-src':413C 'secur':395C 'see':89B 'self':31B,211C,474C 'self-host':30B 'self-registr':210C,473C 'serv':227C,641C 'server':608C 'session':79B,118C,358C 'set':203C 'ship':347C 'show':360C 'showrefissuepopup':234C,561C 'sign':74B,122C 'signed-in':73B,121C 'site':293C,484C 'src':415C 'src/js/features/ref-issue.ts':236C,557C 'srcdoc':427C 'stop':266C 'store':1A,98C 'take':534C 'text':288C 'treat':305C 'ts':555C 'two':262C,654C 'unanchor':277C 'url':294C,383C,454C 'use':275C 'user':76B,109C,124C,127C,385C,472C 'v':260C 'v-html':259C 'v1.27.0-rc0':445C 'vc55':21A 'victim':88B,94B,180C,220C,356C,380C,505C,508C 'web':235C,556C 'whatev':651C 'whether':657C 'without':339C 'wmr3':19A 'work':200C 'write':496C 'xg9x':20A 'xss':2A,99C","nicknames":[],"mitigations":[],"who_affected":"Any self-hosted Gitea instance from 1.27 through 28.3.0 is exposed, because the popup behaviour is on by default and any account the site has issued can plant the link. Instances on versions before 1.27 are not affected by this code path, and the advisory notes the flaw was introduced in 1.27.0-rc0.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"businesses","plain_action":null,"pkeys":["giteadev"],"ptokens":["dev","gitea"],"labels":["cwe79","gitea","go","high","package","selfhosted"],"campaign_type":null,"search_a":"'-120729':16A,24A '-2026':15A,23A 'context':4A 'cve':14A,22A 'file':10A 'ghsa':18A 'ghsa-wmr3-xg9x-vc55':17A 'gitea.dev':25A 'info':13A 'issu':3A,12A 'link':8A 'load':6A 'popup':5A 'raw':9A 'store':1A 'vc55':21A 'wmr3':19A 'xg9x':20A 'xss':2A","search_b":"'-79':27B 'act':91B 'administr':96B 'anoth':72B 'anyth':86B 'attack':65B,83B 'browser':78B 'built':41B 'craft':56B 'cwe':26B 'fetch':38B 'file':62B 'gitea':28B,33B 'host':32B 'hover':44B,81B 'html':53B 'includ':95B 'insert':47B 'issu':35B 'link':45B,57B 'packag':29B 'part':48B 'path':40B 'point':58B 'popup':37B 'raw':61B 'read':85B 'refer':36B 'repositori':67B 'respons':51B 'run':69B 'script':70B 'see':89B 'self':31B 'self-host':30B 'session':79B 'sign':74B 'signed-in':73B 'user':76B 'victim':88B,94B","search_c":"'-53':665C '/info':240C,249C,545C,572C,589C,599C '/issues':247C '/mallory/x/raw/branch/main/alice/app/issues/1':303C,623C '/mallory/x/raw/branch/main/alice/app/issues/1/info':627C '/owner/repo/issues/n':299C '1':137C,176C,524C '12d83cbfa3ca':434C '1313':601C '1696':647C '24':558C '26':237C,573C '274':612C '300':513C '31626de2a6cdd3e1fe93216e4ac80f511297f1e7':464C '32':582C '36908':442C 'account':209C,482C 'activ':329C 'alice/app/issues/1/info':632C 'anoth':120C 'answer':255C,552C 'app':575C 'arbitrari':268C 'async':559C 'attach':343C 'attack':145C,185C,205C,365C,373C,468C 'await':568C 'behaviour':430C 'beyond':439C 'branch':634C 'browser':402C 'build':604C 'built':451C 'bundl':349C 'caus':231C 'check':263C 'class':285C,341C 'click':141C,529C 'code':273C 'comment':170C,502C 'commit':146C,316C,448C,463C,653C 'condit':655C 'configur':466C 'const':564C,574C 'contain':334C 'content':394C,441C,649C 'content-security-polici':393C 'context':437C 'contextpopup':567C,577C 'contextpopup.vue':251C 'createapp':576C 'dashboard':325C 'data':331C,536C,565C 'data-ref-issue-contain':330C 'data.convertedissue':579C 'data.renderedlabels':581C 'decid':656C 'default':202C,216C,465C,479C,566C 'detail':462C 'dom':353C,389C 'end':297C 'endpoint':250C 'enforc':392C 'even':338C 'execut':398C 'extend':435C 'extern':375C,420C 'fail':264C 'feed':326C 'fetch':183C,363C 'field':193C,549C 'file':149C,160C,187C,317C,367C,631C 'first':443C 'follow':408C 'frame':428C 'frontend':182C,348C 'fullissuepatternprocessor':279C 'function':560C 'genuin':308C 'get':593C,661C 'getissueinfo':570C,603C 'gitea':108C,114C,171C 'give':280C 'happi':352C,388C 'happy-dom':351C,387C 'host':225C,376C 'hover':178C,362C,542C,659C 'html':198C,261C,554C,583C 'htmlanchorel':563C 'index':248C,461C,598C 'insert':189C,370C,547C 'insid':323C,422C 'instead':241C 'introduc':432C 'issu':102C,138C,166C,208C,284C,333C,436C,486C,498C,525C,531C,578C,596C 'json':148C 'let':105C 'like':134C 'link':157C,174C,322C,517C,543C,562C,616C,622C,660C 'link.pathname':239C,571C 'load':313C 'look':133C 'main':635C 'mallori':314C,637C,652C 'mallory/x':640C 'markdown':440C 'mere':296C 'mous':130C,511C 'ms':514C 'n':287C 'name':386C 'need':143C,206C 'noth':527C,613C 'observ':406C 'one':190C,548C 'ordinari':136C,523C 'origin':115C,426C 'owner':245C,458C,594C 'page':196C,382C,411C 'pars':457C 'parseissuehref':274C 'path':163C,269C,539C 'permit':418C 'plus':544C 'polici':396C,416C 'popup':104C,312C,337C,438C,450C,533C,625C,663C 'post':155C 'promise.all':569C 'public':489C 'pull':167C,499C,597C 'raw':162C,320C,644C 'reach':271C,335C 'read':222C,378C,506C 'real':244C,401C 'ref':283C,332C 'ref-issu':282C 'ref-issue.ts:52':664C 'refer':103C,139C,309C,526C,532C 'regex':278C 'registr':212C,475C 'regular':107C,471C 'render':172C,253C,520C 'renderedlabel':257C,580C,605C 'renderlabel':610C 'repo':246C,328C,459C,595C 'repositori':153C,218C,490C,639C 'reproduc':344C 'request':168C,238C,453C,500C,626C 'rest':128C,509C 'restrict':614C 'result':302C 'rout':321C,592C,619C,645C 'routers/web/repo/issue.go':611C 'routers/web/web.go':600C,646C 'run':110C,345C 'safe':586C 'same-origin':424C 'same-sit':291C 'script':111C,229C,377C,414C,421C 'script-src':413C 'secur':395C 'self':211C,474C 'self-registr':210C,473C 'serv':227C,641C 'server':608C 'session':118C,358C 'set':203C 'ship':347C 'show':360C 'showrefissuepopup':234C,561C 'sign':122C 'signed-in':121C 'site':293C,484C 'src':415C 'src/js/features/ref-issue.ts':236C,557C 'srcdoc':427C 'stop':266C 'store':98C 'take':534C 'text':288C 'treat':305C 'ts':555C 'two':262C,654C 'unanchor':277C 'url':294C,383C,454C 'use':275C 'user':109C,124C,127C,385C,472C 'v':260C 'v-html':259C 'v1.27.0-rc0':445C 'victim':180C,220C,356C,380C,505C,508C 'web':235C,556C 'whatev':651C 'whether':657C 'without':339C 'work':200C 'write':496C 'xss':99C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-15T21:03:07+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa-repo","external_id":"GHSA-wmr3-xg9x-vc55","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-wmr3-xg9x-vc55","severity":"high","published_at":"2026-11-15T21:03:07+00:00","modified_at":"2026-11-15T21:03:07+00:00","first_seen_at":"2026-11-15T21:12:48+00:00","fetched_at":"2026-11-15T21:12:48+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-120729","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-120729","severity":null,"published_at":"2026-11-15T22:17:17+00:00","modified_at":"2026-11-15T22:17:17+00:00","first_seen_at":"2026-11-15T22:40:23+00:00","fetched_at":"2026-11-15T22:40:23+00:00","note":null}],"documents":[{"id":165574,"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-wmr3-xg9x-vc55","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa-repo","publisher":"vendor","text":null,"published_at":"2026-11-15T21:03:07+00:00","relation":"advisory","confidence":null,"note":"Maintainer's advisory: github.com"},{"id":165694,"url":"https://github.com/go-gitea/gitea/releases/tag/v28.4.0","title":"Release notes: github.com","kind":"release","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release notes: github.com"}],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}