{"id":"CVE-2026-123009","kind":"vulnerability","aliases":["CVE-2026-123009","GHSA-9vh6-6hgj-j5m5"],"related":[],"title":"Privilege bypass in repo file-editor allows reading private base-repo branches","description":"### Summary\r\nGitea's web file-editor has a *submit-to-fork* flow: when you edit a file in a repository you can read but cannot write to, Gitea redirects you into your own fork's editor carrying `?from_base_branch=<branch>`, so the branch you were viewing is copied from the base repo into your fork and you can open a pull request from it (`services/context/repo.go:241-244`).\r\n\r\nThat parameter is never authorized against the base repository. Any authenticated user who owns a fork can therefore submit it directly and read the contents of the fork's **now-private base repository**, long after the owner revoked their access, by naming any branch of it.\r\n\r\n### Details\r\n`routers/web/repo/editor.go:136` reads the parameter with no binding and no validator. A non-empty value forces the new-branch path, which skips the protected-branch guard, leaving only a check against the attacker's **own fork**:\r\n\r\n```go\r\n// routers/web/repo/editor.go:136-145\r\nfromBaseBranch := ctx.FormString(\"from_base_branch\")\r\ncommitToNewBranch := commonForm.CommitChoice == editorCommitChoiceNewBranch || fromBaseBranch != \"\"\r\ntargetBranchName := util.Iif(commitToNewBranch, commonForm.NewBranchName, ctx.Repo.BranchName)\r\nif targetBranchName == ctx.Repo.BranchName && !commitFormOptions.CanCommitToBranch {\r\n\tctx.JSONError(ctx.Tr(\"repo.editor.cannot_commit_to_protected_branch\", targetBranchName))\r\n\treturn nil\r\n}\r\n\r\nif !issues.CanMaintainerWriteToBranch(ctx, ctx.Repo.Permission, targetBranchName, ctx.Doer) {\r\n\tctx.NotFound(nil)\r\n\treturn nil\r\n}\r\n```\r\n\r\nNote the asymmetry with the field beside it: `new_branch_name` carries `binding:\"GitRefName;MaxSize(100)\"` in `services/forms/repo_form_editor.go:17`, while `from_base_branch` is not a form-struct field at all, so it never enters binding. And `CanMaintainerWriteToBranch` resolves against the fork the request targets (`models/issues/pull_list.go:82-84`, `headPerm.CanWrite(unit.TypeCode)`), which the attacker owns — so it short-circuits true.\r\n\r\nThe value then drives a base→fork git push, with no read check on the base repo anywhere on the path:\r\n\r\n```go\r\n// routers/web/repo/editor_util.go:129-134\r\nfunc editorPushBranchToForkedRepository(ctx context.Context, doer *user_model.User, baseRepo *repo_model.Repository, baseBranchName string, targetRepo *repo_model.Repository, targetBranchName string) error {\r\n\treturn git.PushManaged(ctx, baseRepo, targetRepo, git.PushOptions{\r\n\t\tBranch: baseBranchName + \":\" + targetBranchName,\r\n\t\tEnv:    repo_module.PushingEnvironment(doer, targetRepo),\r\n\t})\r\n}\r\n```\r\n\r\n- The other caller of this same primitive, `MergeUpstream` (`services/repository/merge_upstream.go:31-38`), does gate on `GetDoerRepoPermission(ctx, repo.BaseRepo, doer).CanRead(unit.TypeCode)` before pushing. `editorPushBranchToForkedRepository` has no equivalent.\r\n- `git.PushManaged` (`modules/git/push.go:18-21`) just pushes; it has no notion of authorization, so every caller must check first.\r\n- `Repository.GetBaseRepo` (`models/repo/repo.go:537`) is a pure ID lookup, and making a repo private cascades to forks without ever detaching them, so the fork keeps a permission-free handle on the parent forever.\r\n- Reachable at `POST /<owner>/<fork-repo>/_new/<branch>/` (the fork's own new-file editor route) with no privilege beyond owning the fork — the attacker never touches a route on the base repo.\r\n\r\nNote: a request rejected later with `HTTP 400` (e.g. a stale `last_commit` value) still creates and populates the branch first, because the base→fork push in `prepareEditorCommitSubmittedForm` runs before the stale-commit check in `ChangeRepoFiles`. In testing, only real branch names for `from_base_branch` worked (a tag, a raw commit SHA, and `refs/pull/N/head` were all rejected) — but no branch-only validation exists in source, so the true scope may be broader.\r\n\r\n### Impact\r\nAny authenticated user who owns a fork of a repository can exfiltrate the **current contents of any branch** of that repository's base repo after the owner makes it private, bypassing repository privacy entirely — including repos the attacker was never a collaborator on beyond having forked them while public. Recommended fix: add the same `GetDoerRepoPermission(baseRepo, doer).CanRead(unit.TypeCode)` check used in `MergeUpstream` to `editorPushBranchToForkedRepository` before calling `git.PushManaged`, ideally centralized so every `PushManaged` caller enforces it, and bind/validate `from_base_branch` the same way `NewBranchName` is validated.","summary":"Gitea's web file editor accepts an unchecked from_base_branch parameter that copies a branch from the base repository into the user's fork. An authenticated fork owner can therefore read the current contents of any branch of a base repository after it has been made private.","severity":"high","cvss":7.7,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"gitea.dev","fixed":["28.4.0"],"affected":">= 1.25, <= 28.3.0","ecosystem":"go"}],"ecosystems":["go"],"tags":["cwe-284","cwe-863","git","gitea","package","self-hosted"],"not_affected_if":["forking-disabled","managed-hosting","no-private-repos"],"how_to_check":"- Check the Gitea version with `gitea --version` or the server admin page; affected versions are `>= 1.25` up to `28.3.0`.\n- Look for forks whose base repository was made private after the fork was created.","fix":"- `go:gitea.dev`: upgrade to `28.4.0`.","status":"open","published_at":"2026-11-15T21:03:10+00:00","first_seen_at":"2026-11-15T21:12:47+00:00","triaged_at":"2026-11-15T21:14:05+00:00","updated_at":"2026-11-15T21:14:05+00:00","category":"package","confidence":0.8,"triage":{"at":"2026-11-15T21:14:05Z","model":"claude-haiku-5-5","output":{"fix":"- `go:gitea.dev`: upgrade to `28.4.0`.","reach":"internet","title":"Gitea: fork owners can read private base-repo branches via editor","impact":"medium","summary":"Gitea's web file editor accepts an unchecked from_base_branch parameter that copies a branch from the base repository into the user's fork. An authenticated fork owner can therefore read the current contents of any branch of a base repository after it has been made private.","audience":"businesses","category":"package","nicknames":[],"who_cares":["gitea","self-hosted","git"],"confidence":0.8,"fix_status":"available","needs_auth":"yes","worst_case":"authenticated fork owner reads private repository branch contents","analyst_note":"","how_to_check":"- Check the Gitea version with `gitea --version` or the server admin page; affected versions are `>= 1.25` up to `28.3.0`.\n- Look for forks whose base repository was made private after the fork was created.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["forking-disabled","no-private-repos","managed-hosting"],"who_is_affected":"Self-hosted Gitea instances on affected versions where users can fork repositories, especially where private repositories have forks created while they were public. Instances that disable forking or do not have private repositories with public forks are less exposed. The sources do not say whether managed Gitea hosting has already been patched.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"no","severity_if_unknown":"high"},"cost_usd":0.000886,"input_tokens":6286,"output_tokens":515,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-123009':17A,25A '-134':368C '-145':244C '-2026':16A,24A '-21':426C '-244':153C '-284':28B '-38':407C '-84':331C '-863':30B '/_new':477C '100':298C '129':367C '136':203C,243C '17':301C '18':425C '241':152C '31':406C '400':511C '537':443C '6hgj':21A '82':330C '9vh6':20A 'accept':42B 'access':194C 'allow':8A 'anywher':361C 'asymmetri':285C 'attack':237C,336C,495C 'authent':63B,164C,581C 'author':158C,434C 'base':12A,46B,55B,77B,125C,137C,161C,186C,248C,304C,349C,359C,502C,527C,549C,602C 'base-repo':11A 'basebranchnam':377C,391C 'baserepo':375C,387C 'besid':289C 'beyond':490C 'bind':209C,295C,319C 'branch':14A,47B,52B,74B,126C,129C,198C,222C,229C,249C,269C,292C,305C,390C,523C,545C,550C,566C,597C 'branch-on':565C 'broader':578C 'bypass':2A 'caller':399C,437C 'canmaintainerwritetobranch':321C 'cannot':111C 'canread':415C 'carri':123C,294C 'cascad':454C 'changerepofil':540C 'check':234C,356C,439C,538C 'circuit':342C 'commit':266C,516C,537C,556C 'commitformoptions.cancommittobranch':262C 'committonewbranch':250C,256C 'commonform.commitchoice':251C 'commonform.newbranchname':257C 'content':71B,178C,594C 'context.context':372C 'copi':50B,134C 'creat':519C 'ctx':275C,371C,386C,412C 'ctx.doer':278C 'ctx.formstring':246C 'ctx.jsonerror':263C 'ctx.notfound':279C 'ctx.repo.branchname':258C,261C 'ctx.repo.permission':276C 'ctx.tr':264C 'current':70B,593C 'cve':15A,23A 'cwe':27B,29B 'detach':459C 'detail':201C 'direct':174C 'doer':373C,395C,414C 'drive':347C 'e.g':512C 'edit':101C 'editor':7A,41B,91C,122C,485C 'editorcommitchoicenewbranch':252C 'editorpushbranchtoforkedrepositori':370C,419C 'empti':216C 'enter':318C 'env':393C 'equival':422C 'error':383C 'ever':458C 'everi':436C 'exfiltr':591C 'exist':569C 'field':288C,312C 'file':6A,40B,90C,103C,484C 'file-editor':5A,89C 'first':440C,524C 'flow':98C 'forc':218C 'forev':473C 'fork':61B,64B,97C,120C,141C,169C,181C,240C,325C,350C,456C,463C,479C,493C,528C,586C 'form':310C 'form-struct':309C 'free':468C 'frombasebranch':245C,253C 'func':369C 'gate':409C 'getdoerrepopermiss':411C 'ghsa':19A 'ghsa-9vh6-6hgj-j5m5':18A 'git':31B,351C 'git.pushmanaged':385C,423C 'git.pushoptions':389C 'gitea':32B,37B,86C,114C 'gitea.dev':26A 'gitrefnam':296C 'go':241C,365C 'guard':230C 'handl':469C 'headperm.canwrite':332C 'host':36B 'http':510C 'id':447C 'impact':579C 'issues.canmaintainerwritetobranch':274C 'j5m5':22A 'keep':464C 'last':515C 'later':508C 'leav':231C 'long':188C 'lookup':448C 'made':83B 'make':450C,607C 'maxsiz':297C 'may':576C 'mergeupstream':404C 'models/issues/pull_list.go':329C 'models/repo/repo.go':442C 'modules/git/push.go':424C 'must':438C 'name':196C,293C,546C 'never':157C,317C,496C 'new':221C,291C,483C 'new-branch':220C 'new-fil':482C 'nil':272C,280C,282C 'non':215C 'non-empti':214C 'note':283C,504C 'notion':432C 'now-priv':183C 'open':145C 'own':167C,337C,491C,584C 'owner':65B,191C,606C 'packag':33B 'paramet':48B,155C,206C 'parent':472C 'path':223C,364C 'permiss':467C 'permission-fre':466C 'popul':521C 'post':476C 'prepareeditorcommitsubmittedform':531C 'primit':403C 'privat':10A,84B,185C,453C 'privileg':1A,489C 'protect':228C,268C 'protected-branch':227C 'pull':147C 'pure':446C 'push':352C,418C,428C,529C 'raw':555C 'reachabl':474C 'read':9A,68B,109C,176C,204C,355C 'real':544C 'redirect':115C 'refs/pull/n/head':559C 'reject':507C,562C 'repo':4A,13A,138C,360C,452C,503C,603C 'repo.baserepo':413C 'repo.editor.cannot':265C 'repo_model.repository':376C,380C 'repo_module.pushingenvironment':394C 'repositori':56B,78B,106C,162C,187C,589C,600C 'repository.getbaserepo':441C 'request':148C,327C,506C 'resolv':322C 'return':271C,281C,384C 'revok':192C 'rout':486C,499C 'routers/web/repo/editor.go':202C,242C 'routers/web/repo/editor_util.go':366C 'run':532C 'scope':575C 'self':35B 'self-host':34B 'services/context/repo.go':151C 'services/forms/repo_form_editor.go':300C 'services/repository/merge_upstream.go':405C 'sha':557C 'short':341C 'short-circuit':340C 'skip':225C 'sourc':571C 'stale':514C,536C 'stale-commit':535C 'still':518C 'string':378C,382C 'struct':311C 'submit':95C,172C 'submit-to-fork':94C 'summari':85C 'tag':553C 'target':328C 'targetbranchnam':254C,260C,270C,277C,381C,392C 'targetrepo':379C,388C,396C 'test':542C 'therefor':67B,171C 'touch':497C 'true':343C,574C 'uncheck':44B 'unit.typecode':333C,416C 'user':59B,165C,582C 'user_model.user':374C 'util.iif':255C 'valid':212C,568C 'valu':217C,345C,517C 'view':132C 'web':39B,88C 'without':457C 'work':551C 'write':112C","nicknames":[],"mitigations":[],"who_affected":"Self-hosted Gitea instances on affected versions where users can fork repositories, especially where private repositories have forks created while they were public. Instances that disable forking or do not have private repositories with public forks are less exposed. The sources do not say whether managed Gitea hosting has already been patched.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"businesses","plain_action":null,"pkeys":["giteadev"],"ptokens":["dev","gitea"],"labels":["cwe284","cwe863","git","gitea","go","high","package","selfhosted"],"campaign_type":null,"search_a":"'-123009':17A,25A '-2026':16A,24A '6hgj':21A '9vh6':20A 'allow':8A 'base':12A 'base-repo':11A 'branch':14A 'bypass':2A 'cve':15A,23A 'editor':7A 'file':6A 'file-editor':5A 'ghsa':19A 'ghsa-9vh6-6hgj-j5m5':18A 'gitea.dev':26A 'j5m5':22A 'privat':10A 'privileg':1A 'read':9A 'repo':4A,13A","search_b":"'-284':28B '-863':30B 'accept':42B 'authent':63B 'base':46B,55B,77B 'branch':47B,52B,74B 'content':71B 'copi':50B 'current':70B 'cwe':27B,29B 'editor':41B 'file':40B 'fork':61B,64B 'git':31B 'gitea':32B,37B 'host':36B 'made':83B 'owner':65B 'packag':33B 'paramet':48B 'privat':84B 'read':68B 'repositori':56B,78B 'self':35B 'self-host':34B 'therefor':67B 'uncheck':44B 'user':59B 'web':39B","search_c":"'-134':368C '-145':244C '-21':426C '-244':153C '-38':407C '-84':331C '/_new':477C '100':298C '129':367C '136':203C,243C '17':301C '18':425C '241':152C '31':406C '400':511C '537':443C '82':330C 'access':194C 'anywher':361C 'asymmetri':285C 'attack':237C,336C,495C 'authent':164C,581C 'author':158C,434C 'base':125C,137C,161C,186C,248C,304C,349C,359C,502C,527C,549C,602C 'basebranchnam':377C,391C 'baserepo':375C,387C 'besid':289C 'beyond':490C 'bind':209C,295C,319C 'branch':126C,129C,198C,222C,229C,249C,269C,292C,305C,390C,523C,545C,550C,566C,597C 'branch-on':565C 'broader':578C 'caller':399C,437C 'canmaintainerwritetobranch':321C 'cannot':111C 'canread':415C 'carri':123C,294C 'cascad':454C 'changerepofil':540C 'check':234C,356C,439C,538C 'circuit':342C 'commit':266C,516C,537C,556C 'commitformoptions.cancommittobranch':262C 'committonewbranch':250C,256C 'commonform.commitchoice':251C 'commonform.newbranchname':257C 'content':178C,594C 'context.context':372C 'copi':134C 'creat':519C 'ctx':275C,371C,386C,412C 'ctx.doer':278C 'ctx.formstring':246C 'ctx.jsonerror':263C 'ctx.notfound':279C 'ctx.repo.branchname':258C,261C 'ctx.repo.permission':276C 'ctx.tr':264C 'current':593C 'detach':459C 'detail':201C 'direct':174C 'doer':373C,395C,414C 'drive':347C 'e.g':512C 'edit':101C 'editor':91C,122C,485C 'editorcommitchoicenewbranch':252C 'editorpushbranchtoforkedrepositori':370C,419C 'empti':216C 'enter':318C 'env':393C 'equival':422C 'error':383C 'ever':458C 'everi':436C 'exfiltr':591C 'exist':569C 'field':288C,312C 'file':90C,103C,484C 'file-editor':89C 'first':440C,524C 'flow':98C 'forc':218C 'forev':473C 'fork':97C,120C,141C,169C,181C,240C,325C,350C,456C,463C,479C,493C,528C,586C 'form':310C 'form-struct':309C 'free':468C 'frombasebranch':245C,253C 'func':369C 'gate':409C 'getdoerrepopermiss':411C 'git':351C 'git.pushmanaged':385C,423C 'git.pushoptions':389C 'gitea':86C,114C 'gitrefnam':296C 'go':241C,365C 'guard':230C 'handl':469C 'headperm.canwrite':332C 'http':510C 'id':447C 'impact':579C 'issues.canmaintainerwritetobranch':274C 'keep':464C 'last':515C 'later':508C 'leav':231C 'long':188C 'lookup':448C 'make':450C,607C 'maxsiz':297C 'may':576C 'mergeupstream':404C 'models/issues/pull_list.go':329C 'models/repo/repo.go':442C 'modules/git/push.go':424C 'must':438C 'name':196C,293C,546C 'never':157C,317C,496C 'new':221C,291C,483C 'new-branch':220C 'new-fil':482C 'nil':272C,280C,282C 'non':215C 'non-empti':214C 'note':283C,504C 'notion':432C 'now-priv':183C 'open':145C 'own':167C,337C,491C,584C 'owner':191C,606C 'paramet':155C,206C 'parent':472C 'path':223C,364C 'permiss':467C 'permission-fre':466C 'popul':521C 'post':476C 'prepareeditorcommitsubmittedform':531C 'primit':403C 'privat':185C,453C 'privileg':489C 'protect':228C,268C 'protected-branch':227C 'pull':147C 'pure':446C 'push':352C,418C,428C,529C 'raw':555C 'reachabl':474C 'read':109C,176C,204C,355C 'real':544C 'redirect':115C 'refs/pull/n/head':559C 'reject':507C,562C 'repo':138C,360C,452C,503C,603C 'repo.baserepo':413C 'repo.editor.cannot':265C 'repo_model.repository':376C,380C 'repo_module.pushingenvironment':394C 'repositori':106C,162C,187C,589C,600C 'repository.getbaserepo':441C 'request':148C,327C,506C 'resolv':322C 'return':271C,281C,384C 'revok':192C 'rout':486C,499C 'routers/web/repo/editor.go':202C,242C 'routers/web/repo/editor_util.go':366C 'run':532C 'scope':575C 'services/context/repo.go':151C 'services/forms/repo_form_editor.go':300C 'services/repository/merge_upstream.go':405C 'sha':557C 'short':341C 'short-circuit':340C 'skip':225C 'sourc':571C 'stale':514C,536C 'stale-commit':535C 'still':518C 'string':378C,382C 'struct':311C 'submit':95C,172C 'submit-to-fork':94C 'summari':85C 'tag':553C 'target':328C 'targetbranchnam':254C,260C,270C,277C,381C,392C 'targetrepo':379C,388C,396C 'test':542C 'therefor':171C 'touch':497C 'true':343C,574C 'unit.typecode':333C,416C 'user':165C,582C 'user_model.user':374C 'util.iif':255C 'valid':212C,568C 'valu':217C,345C,517C 'view':132C 'web':88C 'without':457C 'work':551C 'write':112C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-15T21:03:10+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa-repo","external_id":"GHSA-9vh6-6hgj-j5m5","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-9vh6-6hgj-j5m5","severity":"high","published_at":"2026-11-15T21:03:10+00:00","modified_at":"2026-11-15T21:03:10+00:00","first_seen_at":"2026-11-15T21:12:47+00:00","fetched_at":"2026-11-15T21:12:47+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-123009","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-123009","severity":null,"published_at":"2026-11-15T22:17:18+00:00","modified_at":"2026-11-15T22:17:18+00:00","first_seen_at":"2026-11-15T22:40:23+00:00","fetched_at":"2026-11-15T22:40:24+00:00","note":null}],"documents":[{"id":165571,"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-9vh6-6hgj-j5m5","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa-repo","publisher":"vendor","text":null,"published_at":"2026-11-15T21:03:10+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"}