{"id":"CVE-2026-123638","kind":"vulnerability","aliases":["CVE-2026-123638","GHSA-w87g-xmrp-86v2"],"related":[],"title":"Branch protection \"Protected file patterns\" bypass via git C-quoted file names — push and merge gates both fail open; leads to untrusted Actions workflow execution on self-hosted runners when .gitea/** is protected","description":"### Summary\r\n\r\n`GetAffectedFiles` (`modules/git/diff.go`, v28.1.0 lines 303–341) is the **only** file-name source for the\r\nbranch-protection *Protected file patterns* feature. It runs\r\n\r\n```go\r\ncmd := gitcmd.NewCommand(\"diff\", \"--name-only\").AddDynamicArguments(oldCommitID, newCommitID)\r\n...\r\npath := strings.TrimSpace(scanner.Text())   // consumed raw — no -z, no C-quote unquoting\r\naffectedFiles = append(affectedFiles, path)\r\n```\r\n\r\n`git diff --name-only` C-quotes any path containing `\"`, `\\`, or a control byte, emitting e.g.\r\n`\"protected/weird\\\"name.md\"` instead of `protected/weird\"name.md`. Such a line can never match a\r\npattern like `protected/**` compiled via `glob.Compile(expr, '.', '/')`\r\n(`models/git/protected_branch.go:267`), so the protection gate fails **open**.\r\n\r\nBoth enforcement paths consume this function:\r\n\r\n1. **Direct push** — `routers/private/hook_pre_receive.go:206-208` →\r\n   `pull_service.CheckFileProtection` (`services/pull/patch.go:368-381`):\r\n   ```go\r\n   affectedFiles, err := git.GetAffectedFiles(...)\r\n   for _, affectedFile := range affectedFiles {\r\n       lpath := strings.ToLower(affectedFile)\r\n       for _, pat := range patterns {\r\n           if pat.Match(lpath) { ... }   // quoted name → no match → not protected\r\n   ```\r\n2. **PR merge gate** — `services/pull/patch.go:439` stores `pr.ChangedProtectedFiles` →\r\n   `services/pull/merge.go:718` `pb.MergeBlockedByProtectedFiles(...)` blocks the merge. Same name\r\n   source, same blind spot.\r\n\r\nMeanwhile the **web UI / PR file list** goes through parsers that DO unquote (and #39781, merged\r\n2026-10-15, frames missing unquoting as a bug): the PR view shows the file with its real name and\r\nflags it protected, while both enforcement gates let it through — a clean\r\n\"UI says protected / enforcement disagrees\" divergence.\r\n\r\n### Impact\r\n\r\nA write-access collaborator — precisely the actor this feature exists to constrain — can:\r\n\r\n1. **Create or modify** files under any protected pattern by naming them with `\"`, `\\`, or a control byte.\r\n2. **Destroy existing protected files**: rename `protected/important.yaml` to\r\n   `protected/gone\"x.yaml` (rename detection reports the quoted names; the old, protected-looking\r\n   name disappears from the affected-file list) and then rewrite/delete its content — verified live.\r\n3. **Execute attacker-chosen code on self-hosted runners** when the owner protects workflow paths\r\n   (`.gitea/**;.github/**` — the documented pattern for this exact purpose, cf. go-gitea/gitea#33370):\r\n   a workflow file pushed as `.gitea/workflows/pwn\"name.yml` bypasses the gate, is still detected by\r\n   the Actions workflow scanner, and a run is created and executed by the runner\r\n   (full 5-hop observed chain in Appendix C; job log line: `PWNED-BY-QUOTED-NAME`).\r\n\r\nNot affected: **Unprotected file patterns** (the whitelist direction) fails CLOSED — a quoted name\r\nthere makes the file *more* restricted, not less. Verified.\r\n\r\n`git fsck --strict` passes these trees; `transfer.fsckObjects` (the duplicate-tree-entry mitigation\r\nfor CVE-2026-95106) does not block them — quoting is legal git output, not object corruption.\r\n\r\n### Suggested fix\r\n\r\nMake `GetAffectedFiles` consume unquoted paths, exactly as sibling code already does:\r\n\r\n```go\r\ncmd := gitcmd.NewCommand(\"diff\", \"--name-only\", \"-z\").AddDynamicArguments(oldCommitID, newCommitID)\r\n// split on NUL; each entry is the raw path — no quoting, no newline ambiguity\r\n```\r\n\r\n(the webhook file-list and the Actions `paths:` filter already use `-z`; alternatively unquote with\r\nthe same helper family that #39781 introduced for `diff-tree --raw`). A regression test should push\r\na `protected/weird\"name.md` under `protected/**` and assert rejection.\r\n\r\n---","summary":"Gitea's protected file pattern check reads changed file names without unquoting git's C-quoted output, so names containing quotes, backslashes or control bytes never match a protected pattern. A collaborator with write access can modify or delete protected files, and push a workflow file under .gitea/** that then runs on self-hosted runners.","severity":"high","cvss":8.5,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"gitea.dev","fixed":["28.4.0"],"affected":"<= 28.3.0","ecosystem":"go"}],"ecosystems":["go"],"tags":["branch-protection","cwe-463","cwe-693","gitea","gitea-actions","package","self-hosted"],"not_affected_if":["managed-hosting","no-protected-file-patterns","unprotected-file-patterns-only"],"how_to_check":"- Check the Gitea version with `gitea --version`; versions `28.3.0` and earlier are affected.\n- In the repository settings, look under Branch protection for 'Protected file patterns' and check whether `.gitea/**` or other workflow paths are listed.\n- Check whether Gitea Actions runners are self-hosted.","fix":"- Gitea: upgrade to `28.4.0`.","status":"open","published_at":"2026-11-15T21:03:05+00:00","first_seen_at":"2026-11-15T21:12:48+00:00","triaged_at":"2026-11-15T21:14:01+00:00","updated_at":"2026-11-15T21:14:01+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-11-15T21:14:01Z","model":"claude-haiku-5-5","output":{"fix":"- Gitea: upgrade to `28.4.0`.","reach":"network","title":"Gitea: quoted file names bypass branch protection on pushes and merges","impact":"high","summary":"Gitea's protected file pattern check reads changed file names without unquoting git's C-quoted output, so names containing quotes, backslashes or control bytes never match a protected pattern. A collaborator with write access can modify or delete protected files, and push a workflow file under .gitea/** that then runs on self-hosted runners.","audience":"businesses","category":"package","nicknames":[],"who_cares":["gitea","self-hosted","gitea-actions","branch-protection"],"confidence":0.85,"fix_status":"available","needs_auth":"yes","worst_case":"Protected files altered and attacker code runs on self-hosted runners","analyst_note":"","how_to_check":"- Check the Gitea version with `gitea --version`; versions `28.3.0` and earlier are affected.\n- In the repository settings, look under Branch protection for 'Protected file patterns' and check whether `.gitea/**` or other workflow paths are listed.\n- Check whether Gitea Actions runners are self-hosted.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["no-protected-file-patterns","managed-hosting","unprotected-file-patterns-only"],"who_is_affected":"Self-hosted Gitea instances on version 28.3.0 or earlier that use branch protection with 'Protected file patterns', especially where workflow paths such as `.gitea/**` are protected. Instances without protected file patterns configured, or that run no self-hosted Actions runners, have less exposure. Write-access collaborators are the actors who can exploit it.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"yes","severity_if_unknown":"high"},"cost_usd":0.000924,"input_tokens":6038,"output_tokens":641,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-10':293C '-123638':38A,46A '-15':294C '-2026':37A,45A,511C '-208':227C '-381':231C '-463':52B '-693':54B '-95106':512C '/gitea':428C '1':222C,345C '2':256C,362C '2026':292C '206':226C '267':209C '3':398C '303':125C '33370':429C '341':126C '368':230C '39781':290C,584C '439':261C '5':459C '718':265C '86v2':43A 'access':98B,334C 'action':24A,58B,445C,570C 'actor':338C 'adddynamicargu':152C,546C 'affect':388C,475C 'affected-fil':387C 'affectedfil':167C,169C,233C,237C,239C,242C 'alreadi':536C,573C 'altern':576C 'ambigu':562C 'append':168C 'appendix':464C 'assert':602C 'attack':401C 'attacker-chosen':400C 'backslash':85B 'blind':274C 'block':267C,515C 'branch':1A,49B,137C 'branch-protect':48B,136C 'bug':300C 'bypass':6A,437C 'byte':88B,185C,361C 'c':10A,78B,164C,177C,465C 'c-quot':9A,77B,163C,176C 'cf':424C 'chain':462C 'chang':70B 'check':68B 'chosen':402C 'clean':323C 'close':483C 'cmd':146C,539C 'code':403C,535C 'collabor':95B,335C 'compil':204C 'constrain':343C 'consum':158C,219C,529C 'contain':83B,181C 'content':395C 'control':87B,184C,360C 'corrupt':524C 'creat':346C,452C 'cve':36A,44A,510C 'cwe':51B,53B 'delet':102B 'destroy':363C 'detect':373C,442C 'diff':148C,172C,541C,588C 'diff-tre':587C 'direct':223C,481C 'disagre':328C 'disappear':384C 'diverg':329C 'document':418C 'duplic':505C 'duplicate-tree-entri':504C 'e.g':187C 'emit':186C 'enforc':217C,317C,327C 'entri':507C,553C 'err':234C 'exact':422C,532C 'execut':26A,399C,454C 'exist':341C,364C 'expr':207C 'fail':19A,214C,482C 'famili':582C 'featur':142C,340C 'file':4A,12A,66B,71B,104B,109B,131C,140C,281C,306C,349C,366C,389C,432C,477C,490C,566C 'file-list':565C 'file-nam':130C 'filter':572C 'fix':526C 'flag':312C 'frame':295C 'fsck':497C 'full':458C 'function':221C 'gate':17A,213C,259C,318C,439C 'getaffectedfil':121C,528C 'ghsa':40A 'ghsa-w87g-xmrp-86v2':39A 'git':8A,75B,171C,496C,520C 'git.getaffectedfiles':235C 'gitcmd.newcommand':147C,540C 'gitea':33A,55B,57B,63B,111B,415C,427C 'gitea-act':56B 'gitea.dev':47A 'gitea/workflows/pwn':435C 'github':416C 'glob.compile':206C 'go':145C,232C,426C,538C 'go-gitea':425C 'goe':283C 'helper':581C 'hop':460C 'host':30A,62B,118B,407C 'impact':330C 'instead':190C 'introduc':585C 'job':466C 'lead':21A 'legal':519C 'less':494C 'let':319C 'like':202C 'line':124C,196C,468C 'list':282C,390C,567C 'live':397C 'log':467C 'look':382C 'lpath':240C,249C 'make':488C,527C 'match':90B,199C,253C 'meanwhil':276C 'merg':16A,258C,269C,291C 'miss':296C 'mitig':508C 'models/git/protected_branch.go':208C 'modifi':100B,348C 'modules/git/diff.go':122C 'name':13A,72B,82B,132C,150C,174C,251C,271C,310C,355C,377C,383C,473C,486C,543C 'name-on':149C,173C,542C 'name.md':189C,193C,598C 'name.yml':436C 'never':89B,198C 'newcommitid':154C,548C 'newlin':561C 'nul':551C 'object':523C 'observ':461C 'old':379C 'oldcommitid':153C,547C 'open':20A,215C 'output':80B,521C 'owner':411C 'packag':59B 'parser':285C 'pass':499C 'pat':244C 'pat.match':248C 'path':155C,170C,180C,218C,414C,531C,557C,571C 'pattern':5A,67B,93B,141C,201C,246C,353C,419C,478C 'pb.mergeblockedbyprotectedfiles':266C 'pr':257C,280C,302C 'pr.changedprotectedfiles':263C 'precis':336C 'protect':2A,3A,35A,50B,65B,92B,103B,138C,139C,203C,212C,255C,314C,326C,352C,365C,381C,412C,600C 'protected-look':380C 'protected/gone':370C 'protected/important.yaml':368C 'protected/weird':188C,192C,597C 'pull_service.checkfileprotection':228C 'purpos':423C 'push':14A,106B,224C,433C,595C 'pwned':470C 'pwned-by-quoted-nam':469C 'quot':11A,79B,84B,165C,178C,250C,376C,472C,485C,517C,559C 'rang':238C,245C 'raw':159C,556C,590C 'read':69B 'real':309C 'regress':592C 'reject':603C 'renam':367C,372C 'report':374C 'restrict':492C 'rewrite/delete':393C 'routers/private/hook_pre_receive.go':225C 'run':114B,144C,450C 'runner':31A,119B,408C,457C 'say':325C 'scanner':447C 'scanner.text':157C 'self':29A,61B,117B,406C 'self-host':28A,60B,116B,405C 'services/pull/merge.go':264C 'services/pull/patch.go':229C,260C 'show':304C 'sibl':534C 'sourc':133C,272C 'split':549C 'spot':275C 'still':441C 'store':262C 'strict':498C 'strings.tolower':241C 'strings.trimspace':156C 'suggest':525C 'summari':120C 'test':593C 'transfer.fsckobjects':502C 'tree':501C,506C,589C 'ui':279C,324C 'unprotect':476C 'unquot':74B,166C,288C,297C,530C,577C 'untrust':23A 'use':574C 'v28.1.0':123C 'verifi':396C,495C 'via':7A,205C 'view':303C 'w87g':41A 'web':278C 'webhook':564C 'whitelist':480C 'without':73B 'workflow':25A,108B,413C,431C,446C 'write':97B,333C 'write-access':332C 'x.yaml':371C 'xmrp':42A 'z':161C,545C,575C","nicknames":[],"mitigations":[],"who_affected":"Self-hosted Gitea instances on version 28.3.0 or earlier that use branch protection with 'Protected file patterns', especially where workflow paths such as `.gitea/**` are protected. Instances without protected file patterns configured, or that run no self-hosted Actions runners, have less exposure. Write-access collaborators are the actors who can exploit it.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"businesses","plain_action":null,"pkeys":["giteadev"],"ptokens":["dev","gitea"],"labels":["branchprotection","cwe463","cwe693","gitea","giteaactions","go","high","package","selfhosted"],"campaign_type":null,"search_a":"'-123638':38A,46A '-2026':37A,45A '86v2':43A 'action':24A 'branch':1A 'bypass':6A 'c':10A 'c-quot':9A 'cve':36A,44A 'execut':26A 'fail':19A 'file':4A,12A 'gate':17A 'ghsa':40A 'ghsa-w87g-xmrp-86v2':39A 'git':8A 'gitea':33A 'gitea.dev':47A 'host':30A 'lead':21A 'merg':16A 'name':13A 'open':20A 'pattern':5A 'protect':2A,3A,35A 'push':14A 'quot':11A 'runner':31A 'self':29A 'self-host':28A 'untrust':23A 'via':7A 'w87g':41A 'workflow':25A 'xmrp':42A","search_b":"'-463':52B '-693':54B 'access':98B 'action':58B 'backslash':85B 'branch':49B 'branch-protect':48B 'byte':88B 'c':78B 'c-quot':77B 'chang':70B 'check':68B 'collabor':95B 'contain':83B 'control':87B 'cwe':51B,53B 'delet':102B 'file':66B,71B,104B,109B 'git':75B 'gitea':55B,57B,63B,111B 'gitea-act':56B 'host':62B,118B 'match':90B 'modifi':100B 'name':72B,82B 'never':89B 'output':80B 'packag':59B 'pattern':67B,93B 'protect':50B,65B,92B,103B 'push':106B 'quot':79B,84B 'read':69B 'run':114B 'runner':119B 'self':61B,117B 'self-host':60B,116B 'unquot':74B 'without':73B 'workflow':108B 'write':97B","search_c":"'-10':293C '-15':294C '-2026':511C '-208':227C '-381':231C '-95106':512C '/gitea':428C '1':222C,345C '2':256C,362C '2026':292C '206':226C '267':209C '3':398C '303':125C '33370':429C '341':126C '368':230C '39781':290C,584C '439':261C '5':459C '718':265C 'access':334C 'action':445C,570C 'actor':338C 'adddynamicargu':152C,546C 'affect':388C,475C 'affected-fil':387C 'affectedfil':167C,169C,233C,237C,239C,242C 'alreadi':536C,573C 'altern':576C 'ambigu':562C 'append':168C 'appendix':464C 'assert':602C 'attack':401C 'attacker-chosen':400C 'blind':274C 'block':267C,515C 'branch':137C 'branch-protect':136C 'bug':300C 'bypass':437C 'byte':185C,361C 'c':164C,177C,465C 'c-quot':163C,176C 'cf':424C 'chain':462C 'chosen':402C 'clean':323C 'close':483C 'cmd':146C,539C 'code':403C,535C 'collabor':335C 'compil':204C 'constrain':343C 'consum':158C,219C,529C 'contain':181C 'content':395C 'control':184C,360C 'corrupt':524C 'creat':346C,452C 'cve':510C 'destroy':363C 'detect':373C,442C 'diff':148C,172C,541C,588C 'diff-tre':587C 'direct':223C,481C 'disagre':328C 'disappear':384C 'diverg':329C 'document':418C 'duplic':505C 'duplicate-tree-entri':504C 'e.g':187C 'emit':186C 'enforc':217C,317C,327C 'entri':507C,553C 'err':234C 'exact':422C,532C 'execut':399C,454C 'exist':341C,364C 'expr':207C 'fail':214C,482C 'famili':582C 'featur':142C,340C 'file':131C,140C,281C,306C,349C,366C,389C,432C,477C,490C,566C 'file-list':565C 'file-nam':130C 'filter':572C 'fix':526C 'flag':312C 'frame':295C 'fsck':497C 'full':458C 'function':221C 'gate':213C,259C,318C,439C 'getaffectedfil':121C,528C 'git':171C,496C,520C 'git.getaffectedfiles':235C 'gitcmd.newcommand':147C,540C 'gitea':415C,427C 'gitea/workflows/pwn':435C 'github':416C 'glob.compile':206C 'go':145C,232C,426C,538C 'go-gitea':425C 'goe':283C 'helper':581C 'hop':460C 'host':407C 'impact':330C 'instead':190C 'introduc':585C 'job':466C 'legal':519C 'less':494C 'let':319C 'like':202C 'line':124C,196C,468C 'list':282C,390C,567C 'live':397C 'log':467C 'look':382C 'lpath':240C,249C 'make':488C,527C 'match':199C,253C 'meanwhil':276C 'merg':258C,269C,291C 'miss':296C 'mitig':508C 'models/git/protected_branch.go':208C 'modifi':348C 'modules/git/diff.go':122C 'name':132C,150C,174C,251C,271C,310C,355C,377C,383C,473C,486C,543C 'name-on':149C,173C,542C 'name.md':189C,193C,598C 'name.yml':436C 'never':198C 'newcommitid':154C,548C 'newlin':561C 'nul':551C 'object':523C 'observ':461C 'old':379C 'oldcommitid':153C,547C 'open':215C 'output':521C 'owner':411C 'parser':285C 'pass':499C 'pat':244C 'pat.match':248C 'path':155C,170C,180C,218C,414C,531C,557C,571C 'pattern':141C,201C,246C,353C,419C,478C 'pb.mergeblockedbyprotectedfiles':266C 'pr':257C,280C,302C 'pr.changedprotectedfiles':263C 'precis':336C 'protect':138C,139C,203C,212C,255C,314C,326C,352C,365C,381C,412C,600C 'protected-look':380C 'protected/gone':370C 'protected/important.yaml':368C 'protected/weird':188C,192C,597C 'pull_service.checkfileprotection':228C 'purpos':423C 'push':224C,433C,595C 'pwned':470C 'pwned-by-quoted-nam':469C 'quot':165C,178C,250C,376C,472C,485C,517C,559C 'rang':238C,245C 'raw':159C,556C,590C 'real':309C 'regress':592C 'reject':603C 'renam':367C,372C 'report':374C 'restrict':492C 'rewrite/delete':393C 'routers/private/hook_pre_receive.go':225C 'run':144C,450C 'runner':408C,457C 'say':325C 'scanner':447C 'scanner.text':157C 'self':406C 'self-host':405C 'services/pull/merge.go':264C 'services/pull/patch.go':229C,260C 'show':304C 'sibl':534C 'sourc':133C,272C 'split':549C 'spot':275C 'still':441C 'store':262C 'strict':498C 'strings.tolower':241C 'strings.trimspace':156C 'suggest':525C 'summari':120C 'test':593C 'transfer.fsckobjects':502C 'tree':501C,506C,589C 'ui':279C,324C 'unprotect':476C 'unquot':166C,288C,297C,530C,577C 'use':574C 'v28.1.0':123C 'verifi':396C,495C 'via':205C 'view':303C 'web':278C 'webhook':564C 'whitelist':480C 'workflow':413C,431C,446C 'write':333C 'write-access':332C 'x.yaml':371C 'z':161C,545C,575C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-15T21:03:05+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa-repo","external_id":"GHSA-w87g-xmrp-86v2","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-w87g-xmrp-86v2","severity":"high","published_at":"2026-11-15T21:03:05+00:00","modified_at":"2026-11-15T21:03:05+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-123638","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-123638","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":165576,"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-w87g-xmrp-86v2","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa-repo","publisher":"vendor","text":null,"published_at":"2026-11-15T21:03:05+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"}