---
id: "CVE-2026-123638"
page: "https://infrastack.ai/live/CVE-2026-123638"
kind: "vulnerability"
aliases: ["CVE-2026-123638", "GHSA-w87g-xmrp-86v2"]
title: "Branch protection \"Protected file patterns\" bypass via git C-quoted file names \u2014 push and merge gates both fail open; leads to untrusted Actions workflow execution on self-hosted runners when .gitea/** is protected"
severity: "high"
cvss: 8.5
epss: null
exploited: false
status: "open"
category: "package"
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"]
published_at: "2026-11-15T21:03:05+00:00"
first_seen_at: "2026-11-15T21:12:48+00:00"
updated_at: "2026-11-15T21:14:01+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-w87g-xmrp-86v2", "first_seen_at": "2026-11-15T21:12:48+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-123638", "first_seen_at": "2026-11-15T22:40:23+00:00"}]
exploit_sources: []
---

# 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

Link for people: https://infrastack.ai/live/CVE-2026-123638 (this .md is for agents)

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.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- go:gitea.dev affected <= 28.3.0 fixed 28.4.0

## How to check

- Check the Gitea version with `gitea --version`; versions `28.3.0` and earlier are affected.
- In the repository settings, look under Branch protection for 'Protected file patterns' and check whether `.gitea/**` or other workflow paths are listed.
- Check whether Gitea Actions runners are self-hosted.

## Fix

- Gitea: upgrade to `28.4.0`.

## Timeline

- 2026-11-15T21:12:48+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-w87g-xmrp-86v2
- 2026-11-15T22:40:23+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-123638

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-w87g-xmrp-86v2
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.4.0

## From the sources

### Summary

`GetAffectedFiles` (`modules/git/diff.go`, v28.1.0 lines 303–341) is the **only** file-name source for the
branch-protection *Protected file patterns* feature. It runs

```go
cmd := gitcmd.NewCommand("diff", "--name-only").AddDynamicArguments(oldCommitID, newCommitID)
...
path := strings.TrimSpace(scanner.Text())   // consumed raw — no -z, no C-quote unquoting
affectedFiles = append(affectedFiles, path)
```

`git diff --name-only` C-quotes any path containing `"`, `\`, or a control byte, emitting e.g.
`"protected/weird\"name.md"` instead of `protected/weird"name.md`. Such a line can never match a
pattern like `protected/**` compiled via `glob.Compile(expr, '.', '/')`
(`models/git/protected_branch.go:267`), so the protection gate fails **open**.

Both enforcement paths consume this function:

1. **Direct push** — `routers/private/hook_pre_receive.go:206-208` →
   `pull_service.CheckFileProtection` (`services/pull/patch.go:368-381`):
   ```go
   affectedFiles, err := git.GetAffectedFiles(...)
   for _, affectedFile := range affectedFiles {
       lpath := strings.ToLower(affectedFile)
       for _, pat := range patterns {
           if pat.Match(lpath) { ... }   // quoted name → no match → not protected
   ```
2. **PR merge gate** — `services/pull/patch.go:439` stores `pr.ChangedProtectedFiles` →
   `services/pull/merge.go:718` `pb.MergeBlockedByProtectedFiles(...)` blocks the merge. Same name
   source, same blind spot.

Meanwhile the **web UI / PR file list** goes through parsers that DO unquote (and #39781, merged
2026-10-15, frames missing unquoting as a bug): the PR view shows the file with its real name and
flags it protected, while both enforcement gates let it through — a clean
"UI says protected / enforcement disagrees" divergence.

### Impact

A write-access collaborator — precisely the actor this feature exists to constrain — can:

1. **Create or modify** files under any protected pattern by naming them with `"`, `\`, or a control byte.
2. **Destroy existing protected files**: rename `protected/important.yaml` to
   `protected/gone"x.yaml` (rename detection reports the quoted names; the old, protected-looking
   name disappears from the affected-file list) and then rewrite/delete its content — verified live.
3. **Execute attacker-chosen code on self-hosted runners** when the owner protects workflow paths
   (`.gitea/**;.github/**` — the documented pattern for this exact purpose, cf. go-gitea/gitea#33370):
   a workflow file pushed as `.gitea/workflows/pwn"name.yml` bypasses the gate, is still detected by
   the Actions workflow scanner, and a run is created and executed by the runner
   (full 5-hop observed chain in Appendix C; job log line: `PWNED-BY-QUOTED-NAME`).

Not affected: **Unprotected file patterns** (the whitelist direction) fails CLOSED — a quoted name
there makes the file *more* restricted, not less. Verified.

`git fsck --strict` passes these trees; `transfer.fsckObjects` (the duplicate-tree-entry mitigation
for CVE-2026-95106) does not block them — quoting is legal git output, not object corruption.

### Suggested fix

Make `GetAffectedFiles` consume unquoted paths, exactly as sibling code already does:

```go
cmd := gitcmd.NewCommand("diff", "--name-only", "-z").AddDynamicArguments(oldCommitID, newCommitID)
// split on NUL; each entry is the raw path — no quoting, no newline ambiguity
```

(the webhook file-list and the Actions `paths:` filter already use `-z`; alternatively unquote with
the same helper family that #39781 introduced for `diff-tree --raw`). A regression test should push
a `protected/weird"name.md` under `protected/**` and assert rejection.

---

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
