{"id":"CVE-2026-129337","kind":"vulnerability","aliases":["CVE-2026-129337","GHSA-8cjj-9p56-j54f"],"related":[],"title":"Read-only users can push over HTTP to repositories being migrated","description":"A user with only read access to a repository can push to it over HTTP while it is being imported. The pushed commits create or overwrite its branches and tags, become part of the imported repository, and leave no entry in its activity feed. For a public repository this is any registered user; for a private one it is anyone with read access, such as a read-only team member. The attached reproducer has an unrelated read-only user overwrite `main` of another user's repository during a migration, and shows the identical push being refused with \"User permission denied for writing\" once the import has finished.\n\nThe cause is in `httpBase` (`routers/web/repo/githttp.go`). Since the AGit support added in 370516883717 (#14295, first released in v1.16.0-rc1), it lowers the required mode for `git-receive-pack` on an existing code repository to read and leaves the write check to the `pre-receive` hook. Unlike the SSH path (`routers/private/serv.go`) and the web routes, it never refuses a repository whose status is `RepositoryBeingMigrated`. Meanwhile, `MigrateRepositoryGitData` (`services/repository/migrate.go`) places a plain `git clone --mirror` with no Gitea hooks at the served location. The delegate hooks are only written by `CleanUpMigrateInfo` after the clone, wiki clone, branch sync and LFS download, so during that time `git receive-pack` runs with no write check at all.\n\nThe attacker has to push inside this window, but does not need a slow or cooperating import source. Against a one-commit import that finished in 0.12 s, a blind push loop landed a branch in 4 of 5 runs. If the import fails before the hooks are installed (for example a wiki clone or LFS download error), the repository stays in the being-migrated state without hooks, and readers can keep pushing until the owner deletes or retries it. Imports created as pull mirrors are not affected. The bug grants write access only: nothing becomes readable that was not already, and no code runs on the server.\n\n## Details\n\nScanned commit `31626de2a6cdd3e1fe93216e4ac80f511297f1e7`. Attacker: a regular user who can read the repository (any\nregistered user for a public one, a read-only team member for a private one). Configuration: default. Entry point: `git push`\nover HTTP, i.e. `POST /{owner}/{repo}.git/git-receive-pack`.\n\nTwo things combine. First, git over HTTP does not check write permission for a push to an existing code repository. It\nlowers the required mode to read (so that readers can push AGit `refs/for/*`) and leaves the decision to the `pre-receive`\nhook (`routers/web/repo/githttp.go:184-204`):\n\n```go\nif repoExist {\n\t// Only the main code repo accepts refs/for pushes, so wiki pushes must keep write checks.\n\tif !isWiki {\n\t\taccessMode = perm.AccessModeRead\n\t}\n\t…\n\tif !p.CanAccess(accessMode, unitType) {\n\t\tctx.PlainText(http.StatusNotFound, \"Repository not found\")\n\t\treturn nil\n\t}\n\n\tif !isPull && repo.IsMirror {\n```\n\n`httpBase` never looks at `repo.Status`. The SSH path does (`routers/private/serv.go:161`), and so do the web routes\n(`services/context/repo.go:711`):\n\n```go\nif repo.IsBeingCreated() {\n\tctx.PrivateUserErrorf(http.StatusForbidden, \"Repository is being created, you could retry after it finished\")\n\treturn\n}\n```\n\nThe lowering to read was introduced in `370516883717` (\"Add agit flow support in gitea (#14295)\", 2021-07-28), first\nreleased in v1.16.0-rc1; before it, `httpBase` refused the same push with 403 before git ran.\n\nSecond, a repository that is being migrated has no Gitea hooks for most of the import. The database row already exists with\n`Status: RepositoryBeingMigrated` (`routers/api/v1/repo/migrate.go:179`, `services/task/task.go:117`), so the repository\nresolves on the git routes and the usual read permission applies. `MigrateRepositoryGitData` then replaces its directory with\na plain clone at the final, served location (`services/repository/migrate.go:88-102`):\n\n```go\nif err := git.DeleteRepository(ctx, repo); err != nil {\n\t…\n}\n\nif err := git.CloneExternalRepo(ctx, opts.CloneAddr, repo, git.CloneRepoOptions{\n\tMirror:        true,\n\t…\n```\n\n`CloneExternalRepo` (`modules/git/clone.go:13`) is `git clone --mirror -- <url> <RepoLocalPath(repo)>`; what it creates\ncontains git's `*.sample` hooks only. The delegate hooks are written by `CleanUpMigrateInfo` → `git.CreateDelegateHooks`\n(`migrate.go:240`, `:264`), the last step of the function. Between the two lie the clone itself, `WriteCommitGraph` (`:104`),\nthe wiki probe and wiki clone (`:109`), the branch and tag sync (`:147-157`) and the download of all LFS objects (`:165`).\nIf the import fails in between (wiki clone error, LFS download error, clone timeout), the repository is left with status\n`RepositoryBeingMigrated` and without hooks, and readers can still push to it after the failed import.\n\nSo mallory's request passes `httpBase` with read permission, `git receive-pack` runs in a directory without `pre-receive`,\nand git updates the ref. The write check (`routers/private/hook_pre_receive.go:60`) never runs. `post-receive` is missing\nas well: after mallory's push the repository's activity feed stayed empty, while a later push by alice added a\n`commit_repo` entry. `SyncRepoBranchesWithRepo` (`migrate.go:147`) then records whatever the refs point to as the imported\nstate.\n\nThe window opens as soon as `git clone` has initialised the directory, before any object has arrived. With the remote\nholding back its pack, mallory's push of a new root commit to `refs/heads/evil` was accepted and the finished import had the\nbranches `evil` and `main`. A push to `refs/heads/main` in that phase is accepted as well, but Gitea's own\n`git clone --mirror` then aborts (`initial ref transaction called with existing refs`, git 2.47.3) and the import fails\nwith 422, which leaves the repository in the hookless state described above. Overwriting `main` works once the clone has\nwritten its refs, which is what the reproducer does.\n\nImports created as pull mirrors are not affected: their row has `IsMirror` set from the start and `githttp.go:201` answers\nthe same push with `mirror repository is read-only`.\n\n## Impact\n\nA user with read access to a repository can write to any of its branches and tags while it is being imported (default\nsettings, stock `git` client, the user's own password), and the result looks like imported history: the push leaves no\nentry in the activity feed. For a public repository that is every registered user; for a private one it is anyone who has read access from the moment the repository is created. That case\nwas checked as well: a member of an organization team with read permission on all repositories pushed to `main` and\ncreated a tag in a private repository of that organization while an owner imported it. The precondition is timing. The\nvictim must be running an import, and the attacker must push before its git phase ends, which lasts as long as the clone,\nthe wiki clone and the LFS download take. The repository answers API and git requests of its readers during that time, so\nthe start of an import can be watched for. No slow or cooperating import source is needed: against a one-commit import\nthat finished in 0.12 s, a blind loop of pushes landed a branch in 4 of 5 runs. The window does not always close either:\nan import that fails between the clone and the hook installation leaves a repository that readers can keep pushing to\nuntil the owner deletes or retries it, and a push to `main` during the clone is one way to make the import fail. Once an\nimport has finished, the same user cannot push. Nothing becomes readable that was not before, and no code runs on the\nserver.\n\n\n_Reported by the Anthropic OSS scanner, finding ANT-2026-2TN6AY02 (scan gitea-20261022-004), commit 31626de2a6cdd3e1fe93216e4ac80f511297f1e7._","summary":"While a repository is being imported, the HTTP git route does not check write permission, so a user with only read access can push branches and tags into it. The pushed commits look like imported history and leave no activity-feed entry.","severity":"medium","cvss":null,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"gitea.dev","fixed":["28.4.0"],"affected":">= 1.16, <= 28.3.0","ecosystem":"go"}],"ecosystems":["go"],"tags":["cwe-862","gitea","http-git","package","self-hosted"],"not_affected_if":["gitea-28.4.0-or-later","no-migrations","pull-mirror-only"],"how_to_check":"- Run `gitea --version` or check the Gitea version in the admin dashboard and compare it with `28.4.0`\n- Look for repositories in the being-migrated state (the migration status in the database) that have no hooks directory content besides `*.sample` files\n- Review recent pushes in repositories that were imported recently for commits not tied to a user action","fix":"- Gitea: upgrade to `28.4.0` or later (affected from `1.16.0-rc1` through `28.3.0`)","status":"open","published_at":"2026-11-15T21:03:14+00:00","first_seen_at":"2026-11-15T21:12:47+00:00","triaged_at":"2026-11-15T21:14:21+00:00","updated_at":"2026-11-15T21:14:21+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-11-15T21:14:21Z","model":"claude-haiku-5-5","output":{"fix":"- Gitea: upgrade to `28.4.0` or later (affected from `1.16.0-rc1` through `28.3.0`)","reach":"network","title":"Gitea: read-only users can push to repositories during migration","impact":"medium","summary":"While a repository is being imported, the HTTP git route does not check write permission, so a user with only read access can push branches and tags into it. The pushed commits look like imported history and leave no activity-feed entry.","audience":"businesses","category":"package","nicknames":[],"who_cares":["gitea","self-hosted","http-git"],"confidence":0.85,"fix_status":"available","needs_auth":"yes","worst_case":"read-only user writes branches and tags into a repository being imported","analyst_note":"","how_to_check":"- Run `gitea --version` or check the Gitea version in the admin dashboard and compare it with `28.4.0`\n- Look for repositories in the being-migrated state (the migration status in the database) that have no hooks directory content besides `*.sample` files\n- Review recent pushes in repositories that were imported recently for commits not tied to a user action","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["pull-mirror-only","no-migrations","gitea-28.4.0-or-later"],"who_is_affected":"Gitea servers from 1.16.0-rc1 through 28.3.0 with repository migrations enabled on the default configuration. Exposure exists only during an import, or after an import that failed before the hooks were installed; instances that never migrate repositories, or that use pull mirrors, are not affected.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"no","severity_if_unknown":"unknown"},"cost_usd":0.001021,"input_tokens":7264,"output_tokens":589,"severity_before":"medium"},"analyst_status":null,"analyst_note":null,"search":"'-07':588C '-102':664C '-129337':15A,23A '-2026':14A,22A '-204':500C '-28':589C '-862':26B '0.12':328C '117':633C '14295':200C,586C '161':547C '179':631C '184':499C '2021':587C '31626de2a6cdd3e1fe93216e4ac80f511297f1e7':414C '370516883717':199C,579C '4':338C '403':602C '5':340C '711':555C '88':663C '8cjj':18A '9p56':19A 'accept':509C 'access':56B,83C,140C,395C 'accessmod':521C,525C 'activ':75B,120C 'activity-fe':74B 'add':197C,580C 'affect':390C 'agit':195C,486C,581C 'alreadi':403C,625C 'anoth':162C 'anyon':137C 'appli':647C 'attach':150C 'attack':302C,415C 'becom':108C,398C 'being-migr':365C 'blind':331C 'branch':59B,105C,281C,336C 'bug':392C 'caus':188C 'check':47B,226C,298C,463C,518C 'cleanupmigrateinfo':275C 'clone':258C,278C,280C,355C,656C 'code':218C,406C,472C,507C 'combin':456C 'commit':66B,100C,323C,413C 'configur':441C 'cooper':316C 'could':566C 'creat':101C,384C,564C 'ctx':669C 'ctx.plaintext':527C 'ctx.privateusererrorf':559C 'cve':13A,21A 'cwe':25B 'databas':623C 'decis':491C 'default':442C 'deleg':269C 'delet':379C 'deni':179C 'detail':411C 'directori':652C 'download':285C,358C 'entri':77B,117C,443C 'err':667C,671C,674C 'error':359C 'exampl':352C 'exist':217C,471C,626C 'fail':345C 'feed':76B,121C 'final':659C 'finish':186C,326C,570C 'first':201C,457C,590C 'flow':582C 'found':531C 'ghsa':17A 'ghsa-8cjj-9p56-j54f':16A 'git':30B,43B,212C,257C,290C,445C,458C,604C,640C 'git-receive-pack':211C 'git.cloneexternalrepo':675C 'git.deleterepository':668C 'git/git-receive-pack':453C 'gitea':27B,262C,585C,615C 'gitea.dev':24A 'go':501C,556C,665C 'grant':393C 'histori':70B 'hook':232C,263C,270C,348C,370C,497C,616C 'host':34B 'http':8A,29B,42B,92C,448C,460C 'http-git':28B 'http.statusforbidden':560C 'http.statusnotfound':528C 'httpbase':191C,537C,596C 'i.e':449C 'ident':172C 'import':40B,69B,97C,112C,184C,317C,324C,344C,383C,621C 'insid':306C 'instal':350C 'introduc':577C 'ispul':535C 'iswiki':520C 'j54f':20A 'keep':374C,516C 'land':334C 'leav':72B,115C,223C,489C 'lfs':284C,357C 'like':68B 'locat':267C,661C 'look':67B,539C 'loop':333C 'lower':206C,475C,573C 'main':160C,506C 'meanwhil':251C 'member':148C,436C 'migrat':12A,168C,367C,612C 'migraterepositorygitdata':252C,648C 'mirror':259C,387C 'mode':209C,478C 'must':515C 'need':312C 'never':243C,538C 'nil':533C,672C 'noth':397C 'one':134C,322C,430C,440C 'one-commit':321C 'overwrit':103C,159C 'owner':378C,451C 'p.canaccess':524C 'pack':214C,293C 'packag':31B 'part':109C 'path':236C,544C 'perm.accessmoderead':522C 'permiss':49B,178C,465C,646C 'place':254C 'plain':256C,655C 'point':444C 'post':450C 'pre':230C,495C 'pre-rec':229C,494C 'privat':133C,439C 'public':124C,429C 'pull':386C 'push':6A,58B,65B,88C,99C,173C,305C,332C,375C,446C,468C,485C,511C,514C,600C 'ran':605C 'read':2A,55B,82C,139C,145C,156C,221C,421C,433C,480C,575C,645C 'read-on':1A,144C,155C,432C 'readabl':399C 'reader':372C,483C 'receiv':213C,231C,292C,496C 'receive-pack':291C 'refs/for':487C,510C 'refus':175C,244C,597C 'regist':129C,425C 'regular':417C 'releas':202C,591C 'replac':650C 'repo':452C,508C,670C 'repo.isbeingcreated':558C 'repo.ismirror':536C 'repo.status':541C 'repoexist':503C 'repositori':10A,37B,86C,113C,125C,165C,219C,246C,361C,423C,473C,529C,561C,608C,636C 'repositorybeingmigr':250C,629C 'reproduc':151C 'requir':208C,477C 'resolv':637C 'retri':381C,567C 'return':532C,571C 'rout':44B,241C,553C,641C 'routers/api/v1/repo/migrate.go':630C 'routers/private/serv.go':237C,546C 'routers/web/repo/githttp.go':192C,498C 'row':624C 'run':294C,341C,407C 'scan':412C 'second':606C 'self':33B 'self-host':32B 'serv':266C,660C 'server':410C 'services/context/repo.go':554C 'services/repository/migrate.go':253C,662C 'services/task/task.go':632C 'show':170C 'sinc':193C 'slow':314C 'sourc':318C 'ssh':235C,543C 'state':368C 'status':248C,628C 'stay':362C 'support':196C,583C 'sync':282C 'tag':61B,107C 'team':147C,435C 'thing':455C 'time':289C 'two':454C 'unittyp':526C 'unlik':233C 'unrel':154C 'user':4A,52B,79C,130C,158C,163C,177C,418C,426C 'usual':644C 'v1.16.0-rc1':204C,593C 'web':240C,552C 'whose':247C 'wiki':279C,354C,513C 'window':308C 'without':369C 'write':48B,181C,225C,297C,394C,464C,517C 'written':273C","nicknames":[],"mitigations":[],"who_affected":"Gitea servers from 1.16.0-rc1 through 28.3.0 with repository migrations enabled on the default configuration. Exposure exists only during an import, or after an import that failed before the hooks were installed; instances that never migrate repositories, or that use pull mirrors, are not affected.","tier":"C","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"businesses","plain_action":null,"pkeys":["giteadev"],"ptokens":["dev","gitea"],"labels":["cwe862","gitea","go","httpgit","medium","package","selfhosted"],"campaign_type":null,"search_a":"'-129337':15A,23A '-2026':14A,22A '8cjj':18A '9p56':19A 'cve':13A,21A 'ghsa':17A 'ghsa-8cjj-9p56-j54f':16A 'gitea.dev':24A 'http':8A 'j54f':20A 'migrat':12A 'push':6A 'read':2A 'read-on':1A 'repositori':10A 'user':4A","search_b":"'-862':26B 'access':56B 'activ':75B 'activity-fe':74B 'branch':59B 'check':47B 'commit':66B 'cwe':25B 'entri':77B 'feed':76B 'git':30B,43B 'gitea':27B 'histori':70B 'host':34B 'http':29B,42B 'http-git':28B 'import':40B,69B 'leav':72B 'like':68B 'look':67B 'packag':31B 'permiss':49B 'push':58B,65B 'read':55B 'repositori':37B 'rout':44B 'self':33B 'self-host':32B 'tag':61B 'user':52B 'write':48B","search_c":"'-07':588C '-102':664C '-204':500C '-28':589C '0.12':328C '117':633C '14295':200C,586C '161':547C '179':631C '184':499C '2021':587C '31626de2a6cdd3e1fe93216e4ac80f511297f1e7':414C '370516883717':199C,579C '4':338C '403':602C '5':340C '711':555C '88':663C 'accept':509C 'access':83C,140C,395C 'accessmod':521C,525C 'activ':120C 'add':197C,580C 'affect':390C 'agit':195C,486C,581C 'alreadi':403C,625C 'anoth':162C 'anyon':137C 'appli':647C 'attach':150C 'attack':302C,415C 'becom':108C,398C 'being-migr':365C 'blind':331C 'branch':105C,281C,336C 'bug':392C 'caus':188C 'check':226C,298C,463C,518C 'cleanupmigrateinfo':275C 'clone':258C,278C,280C,355C,656C 'code':218C,406C,472C,507C 'combin':456C 'commit':100C,323C,413C 'configur':441C 'cooper':316C 'could':566C 'creat':101C,384C,564C 'ctx':669C 'ctx.plaintext':527C 'ctx.privateusererrorf':559C 'databas':623C 'decis':491C 'default':442C 'deleg':269C 'delet':379C 'deni':179C 'detail':411C 'directori':652C 'download':285C,358C 'entri':117C,443C 'err':667C,671C,674C 'error':359C 'exampl':352C 'exist':217C,471C,626C 'fail':345C 'feed':121C 'final':659C 'finish':186C,326C,570C 'first':201C,457C,590C 'flow':582C 'found':531C 'git':212C,257C,290C,445C,458C,604C,640C 'git-receive-pack':211C 'git.cloneexternalrepo':675C 'git.deleterepository':668C 'git/git-receive-pack':453C 'gitea':262C,585C,615C 'go':501C,556C,665C 'grant':393C 'hook':232C,263C,270C,348C,370C,497C,616C 'http':92C,448C,460C 'http.statusforbidden':560C 'http.statusnotfound':528C 'httpbase':191C,537C,596C 'i.e':449C 'ident':172C 'import':97C,112C,184C,317C,324C,344C,383C,621C 'insid':306C 'instal':350C 'introduc':577C 'ispul':535C 'iswiki':520C 'keep':374C,516C 'land':334C 'leav':115C,223C,489C 'lfs':284C,357C 'locat':267C,661C 'look':539C 'loop':333C 'lower':206C,475C,573C 'main':160C,506C 'meanwhil':251C 'member':148C,436C 'migrat':168C,367C,612C 'migraterepositorygitdata':252C,648C 'mirror':259C,387C 'mode':209C,478C 'must':515C 'need':312C 'never':243C,538C 'nil':533C,672C 'noth':397C 'one':134C,322C,430C,440C 'one-commit':321C 'overwrit':103C,159C 'owner':378C,451C 'p.canaccess':524C 'pack':214C,293C 'part':109C 'path':236C,544C 'perm.accessmoderead':522C 'permiss':178C,465C,646C 'place':254C 'plain':256C,655C 'point':444C 'post':450C 'pre':230C,495C 'pre-rec':229C,494C 'privat':133C,439C 'public':124C,429C 'pull':386C 'push':88C,99C,173C,305C,332C,375C,446C,468C,485C,511C,514C,600C 'ran':605C 'read':82C,139C,145C,156C,221C,421C,433C,480C,575C,645C 'read-on':144C,155C,432C 'readabl':399C 'reader':372C,483C 'receiv':213C,231C,292C,496C 'receive-pack':291C 'refs/for':487C,510C 'refus':175C,244C,597C 'regist':129C,425C 'regular':417C 'releas':202C,591C 'replac':650C 'repo':452C,508C,670C 'repo.isbeingcreated':558C 'repo.ismirror':536C 'repo.status':541C 'repoexist':503C 'repositori':86C,113C,125C,165C,219C,246C,361C,423C,473C,529C,561C,608C,636C 'repositorybeingmigr':250C,629C 'reproduc':151C 'requir':208C,477C 'resolv':637C 'retri':381C,567C 'return':532C,571C 'rout':241C,553C,641C 'routers/api/v1/repo/migrate.go':630C 'routers/private/serv.go':237C,546C 'routers/web/repo/githttp.go':192C,498C 'row':624C 'run':294C,341C,407C 'scan':412C 'second':606C 'serv':266C,660C 'server':410C 'services/context/repo.go':554C 'services/repository/migrate.go':253C,662C 'services/task/task.go':632C 'show':170C 'sinc':193C 'slow':314C 'sourc':318C 'ssh':235C,543C 'state':368C 'status':248C,628C 'stay':362C 'support':196C,583C 'sync':282C 'tag':107C 'team':147C,435C 'thing':455C 'time':289C 'two':454C 'unittyp':526C 'unlik':233C 'unrel':154C 'user':79C,130C,158C,163C,177C,418C,426C 'usual':644C 'v1.16.0-rc1':204C,593C 'web':240C,552C 'whose':247C 'wiki':279C,354C,513C 'window':308C 'without':369C 'write':181C,225C,297C,394C,464C,517C 'written':273C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-15T21:03:14+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa-repo","external_id":"GHSA-8cjj-9p56-j54f","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-8cjj-9p56-j54f","severity":"medium","published_at":"2026-11-15T21:03:14+00:00","modified_at":"2026-11-15T21:03:14+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-129337","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129337","severity":null,"published_at":"2026-11-15T22:17:19+00:00","modified_at":"2026-11-15T22:17:19+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":165567,"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-8cjj-9p56-j54f","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa-repo","publisher":"vendor","text":null,"published_at":"2026-11-15T21:03:14+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"}