CVE-2026-104633: Gitea took its loop bound from the server it was migrating from
When Gitea migrates a repository from another Gitea instance, it asks that instance how many items it returns per page and stops paging when a page comes back shorter than that. A source that answers zero makes six loops run until the process dies. One request from an ordinary account took a clean 1.27.3 from 99MiB to 5.7GB of memory in ninety seconds. Fixed in 28.1.0.
Contents
Gitea can import a repository from another Gitea instance along with its issues, releases, milestones and pull requests. The user who starts the import types in the address of the source. On 22 September 2026 I reported that the source can make the import run forever. Gitea published the fix on 6 October as GHSA-jj5r-9rpc-8h6h, CVE-2026-104633, rated 6.5.
This covers the cause and what it costs the server. It also covers a second lead in the same file that I spent an afternoon on and had to drop.
The page size comes from the source
Before it fetches anything, the downloader asks the source for its API settings and reads one number out of them: the most items the source will return in a page. This is services/migrations/gitea_downloader.go in 1.27.3.
maxPerPage := 10
apiConf, _, err := giteaClient.Settings.GetGlobalAPISettings(ctx)
if err != nil {
log.Info("Unable to get global API settings. Ignoring these.")
}
if apiConf != nil {
maxPerPage = apiConf.MaxResponseItems
}The error is logged and then ignored. The guard is apiConf != nil where it should be err == nil, so a response that failed to parse can still supply the value. Nothing checks that the number is above zero.
Six loops end on the same comparison
Every paginated fetch in that file decides it has reached the last page the same way: the page it just received was shorter than the page size.
216: if !g.pagination || len(ms) < g.maxPerPage { // milestones
254: if !g.pagination || len(ls) < g.maxPerPage { // labels
342: if !g.pagination || len(rl) < g.maxPerPage { // releases
381: if !g.pagination || len(reactions) < g.maxPerPage { // reactions
511: if !g.pagination || len(comments) < g.maxPerPage { // comments
710: if len(prl) < g.maxPerPage { // pull requestsWith a page size of zero that test is len(x) < 0, which is never true. The loop asks for the next page, appends what it gets to a slice it keeps, and asks again. There were five such loops up to 1.25 and six from 1.27.0, and the pattern is in every tag I checked back to 1.17.0.
Closing the connection does not stop it
Each loop checks ctx.Done() on every pass, which looks like the way out. The API handler starts the migration like this:
doLongTimeMigrate(graceful.GetManager().HammerContext(), ctx.Doer)HammerContext is the context Gitea cancels when it is being forced to shut down. It is not the context of the request. That is deliberate, since a migration is meant to outlive the HTTP call that started it. It also means the client going away changes nothing, and there was no timeout on the migration task or on the HTTP client it uses. The loop runs until the process is killed.
What it costs
The test was a clean 1.27.3 in a container and a fake source that answers max_response_items: 0. One migration request, from an account with no special rights:
baseline anon: 99 MiB
t+ 20s: anon 1391 MiB
t+ 40s: anon 2471 MiB
t+ 60s: anon 3997 MiB
t+ 90s: anon 5758 MiBAn earlier run reached 7,983MiB at two minutes, by which point the fake source had served 931,524 pages of releases. That is about 7,700 requests a second leaving the Gitea server and about 66MiB a second of growth. Both were still linear when I stopped it.
The figure is anon from the container’s cgroup memory.stat and not memory.current. The second one includes page cache, and a number that includes page cache can be dismissed as files the kernel would drop under pressure.
Who can do it
Any account that can create a repository can start a migration and choose the source. The attacker runs the source. It has to answer five API endpoints (the version, the API settings, the repository, its topics and its releases) and serve a git repository over plain HTTP so that the clone step succeeds.
My lab sets ALLOW_LOCALNETWORKS=true, and the report says so up front so that nobody reads it as a requirement. Gitea refuses migrations from private addresses by default, and the fake source in the lab sits on one. A source on a public address needs no setting changed.
How I found it
Not by fuzzing. Two earlier advisories, GHSA-5952-x23q-p23f and GHSA-46px-6cqx-c5fv, had each hardened one migration downloader against a hostile source: the GitLab one and the OneDev one. The OneDev fix put a size limit on one response, and that limit was the only LimitReader anywhere in services/migrations. Two of the downloaders had been read with a hostile source in mind and the others had not, so I read the next one.
The lead I dropped
The first thing I chased in that file was something else. At line 302 the release asset download builds its request with http.NewRequest and never attaches a context. The GitLab downloader does the same job and attaches one on the next line. The shared migration client sets no timeout, so this looked like a request nobody could cancel.
I built a source that accepts the connection and never answers, started a migration, killed the client, and watched the connection sit established for two and a half minutes. I took that as proof.
Then I checked which context the migration runs under and found HammerContext. The migration was never tied to the client, so killing the client was never going to cancel anything, with or without a context on that request. The test would have given the same result against correct code. The GitLab path that does attach a context attaches the shutdown one, so in practice it is stuck in the same way.
I did not report it as a vulnerability. It is in the advisory as something the maintainers might want to tidy.
The fix
The value is now used only when the settings call succeeded and the number is positive, and it is capped at 100. This is the code on main today:
apiConf, _, err := giteaClient.Settings.GetGlobalAPISettings(ctx)
if err != nil {
log.Info("Unable to get global API settings. Ignoring these.")
log.Debug("giteaClient.GetGlobalAPISettings. Error: %v", err)
} else if apiConf != nil && apiConf.MaxResponseItems > 0 {
maxPerPage = min(apiConf.MaxResponseItems, 100)
}The advisory gives 28.1.0, released on 6 October 2026, as the patched version. If you run an older Gitea where untrusted users can create repositories, upgrade. Until you can, DISABLE_MIGRATIONS = true under [repository] turns the feature off for everyone.
The report also notes that a source with a sensible page size can still return one item per page for as long as it likes, which grows the same slices more slowly. I have not tested that against 28.1.0.
Timeline
- 22 September 2026: reported privately through GitHub security advisories.
- 6 October 2026: published as GHSA-jj5r-9rpc-8h6h with CVE-2026-104633. The advisory credits bircni and silverwind for the fix.
Every report we have filed with other projects, and what became of each one, is on one page. Disclosures