Gitea Incomplete SSRF Protection in Webhook and Migration Allow-List (CVE-2026-22874)
Published: 2026-11-27 • Researcher: Eliot-Code (GitHub user Eliot-code; the commit is attributed to Devoloper CODE)
- Severity
- Critical
- CVE
- CVE-2026-22874 / GHSA-2r5c-gw76-rh3w
- Category
- web
- Affected product
- Gitea (the default host matcher used by webhook delivery and repository migrations)
- Affected versions
- Up to and including 1.26.2; fixed in 1.26.3 and carried into 1.26.4
- Disclosed
- 2026-11-27
- Patch status
- Patched
Tags
References
- https://nvd.nist.gov/vuln/detail/CVE-2026-22874
- https://github.com/go-gitea/gitea/security/advisories/GHSA-2r5c-gw76-rh3w
- https://blog.gitea.com/release-of-1.26.3-and-1.26.4
- https://github.com/go-gitea/gitea/pull/38059
- https://github.com/go-gitea/gitea/pull/38173
- https://github.com/Eliot-code/CVE-2026-22874-PoC
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2026-07-05 (upstream commit by Devoloper CODE, “Actualizar CVE-2026-22874-PoC.py”) |
| Author / Researcher | Eliot-Code (GitHub user Eliot-code; the commit is attributed to Devoloper CODE) |
| CVE / Advisory | CVE-2026-22874 / GHSA-2r5c-gw76-rh3w |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.6 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N, GHSA and NVD) |
| Status | PoC |
| Tags | SSRF, Gitea, webhook, repository migration, allow-list bypass, cloud metadata, IMDS, IPv6 transition, CWE-918 |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Gitea (the default host matcher used by webhook delivery and repository migrations) |
| Versions Affected | Up to and including 1.26.2; fixed in 1.26.3 and carried into 1.26.4 |
| Language / Platform | Go server application; the archived PoC is Python 3 |
| Authentication Required | Yes — a personal access token for an account that may create repository webhooks or migrations |
| Network Access Required | Yes — HTTPS to the Gitea API; the outbound requests themselves are made by the Gitea server |
Summary
Gitea decides whether an outbound webhook or repository migration destination is allowed by calling Go’s standard IsPrivate check on the resolved IP address. That check only recognises RFC 1918 IPv4 ranges and IPv6 unique-local addresses, so addresses used for cloud metadata, carrier-grade NAT, documentation prefixes and several IPv6 transition mechanisms are treated as safe external destinations. An authenticated user who can configure a repository webhook can therefore point it at an internal or metadata URL and read the captured response back through the webhook delivery history. The SSRF is not blind: Gitea stores the response status, headers and up to 1 MiB of the body, which makes internal service enumeration and cloud credential theft practical where a metadata endpoint is reachable.
Vulnerability Details
Root Cause
The default webhook and migration allow-list is the built-in external matcher in modules/hostmatcher. Its checkIP function accepts an address when Go’s net.IP.IsGlobalUnicast returns true and net.IP.IsPrivate returns false. net.IP.IsPrivate only covers 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and fc00::/7, so the following ranges pass the check and are contacted: 100.64.0.0/10 (RFC 6598 carrier-grade NAT), 168.63.129.16/32 (Azure WireServer metadata), the non-RFC 1918 part of 172.0.0.0/8, 64:ff9b::/96 (NAT64, which can embed 169.254.169.254), 2001::/32 (Teredo), 2002::/16 (6to4) and 2001:db8::/32. Both the webhook delivery service and the repository migration service call the same matcher with MatchBuiltinExternal when no administrator allow-list is configured, so the gap is shared by both features.
Attack Vector
An authenticated user with permission to manage webhooks on any repository sends POST /api/v1/repos/{owner}/{repo}/hooks with a gitea-type hook whose config.url is an internal address in one of the unblocked ranges, for example http://[64:ff9b::a9fe:a9fe]/latest/meta-data/ (NAT64-encoded 169.254.169.254). A subsequent push, or a file created through the contents API, triggers a delivery. The user then reads the delivery record at /api/v1/repos/{owner}/{repo}/hooks/{id}/deliveries, which contains the response status, headers and body captured by Gitea. The same gap is reachable through the repository migration form by supplying an internal clone URL.
Impact
Server-side requests to internal networks and cloud metadata endpoints, with the response readable by the attacker. On a cloud-hosted instance this can disclose instance identity documents and temporary IAM credentials for the role attached to the instance, allowing lateral movement into the cloud account. It also provides a way to probe internal HTTP services and to reach admin panels bound to loopback or link-local addresses. The CVSS scope-changed vector reflects that the vulnerable component can affect resources beyond the Gitea server itself.
Environment / Lab Setup
OS: Linux host running Docker (Debian or Ubuntu used upstream)
Target: Gitea 1.26.2 (Docker image gitea/gitea:1.26.2), optionally with a metadata service emulator
Attacker: Same or another host with Python 3 and network access to the Gitea API
Tools: python3, requests, git, curl, DockerSetup Steps
| |
Proof of Concept
Step-by-Step Reproduction
Prepare the token and repository — the account must be able to create hooks on the chosen repository. Any ordinary user who owns a repository qualifies.
Run the exploit against a metadata URL — the default bypass is NAT64-encoded 169.254.169.254; the alternative values cover Azure WireServer, CGNAT, IPv4-mapped IPv6, Teredo and 6to4.
Shell script1 2 3python3 exploit.py --url http://gitea.lab:3000 \ --token <PAT> --owner lab --repo test \ --bypass nat64-imds --method apiTrigger a delivery — the script creates the hook, then either pushes a commit to the repository or creates a file through the contents API. The API method avoids needing git credentials.
Read the captured response — the script polls the hook delivery endpoint and prints the status code and response body, which is the proof that Gitea fetched the internal URL.
Confirm the hook — the same delivery is visible in the repository’s webhook history in the Gitea UI, so the request can also be verified by hand.
Exploit Code
See
exploit.pyin this folder for the complete implementation (upstream file name CVE-2026-22874-PoC, extensionless; renamed for execution clarity).
| |
Expected Output
The upstream repository does not include a captured run, so the following is the output shape produced by the script on a successful bypass against a metadata service (illustrative, not an observed transcript):
[*] CVE-2026-22874 Gitea SSRF Exploit
[*] Target: http://gitea.lab:3000
[*] Bypass: nat64-imds
[*] Method: api
[+] Hook created: 3
[+] Target URL: http://[64:ff9b::a9fe:a9fe]/latest/meta-data/
[*] Triggering webhook via API content creation...
[+] File created via API
[*] Polling deliveries (timeout: 30s)...
[+] 1 delivery(ies) found!
[Delivery 1] ID: 1
Status Code: 200
Response Body:
------------------------------------------------------------
ami-id
ami-launch-index
ami-manifest-path
hostname
iam/
instance-id
local-ipv4
------------------------------------------------------------Detection & Indicators of Compromise
Webhook created with a config.url that is an IP literal or an internal hostname,
especially in 100.64.0.0/10, 168.63.129.16, 172.32.0.0/11, 64:ff9b::/96,
2001::/32, 2002::/16 or 2001:db8::/32
Hook delivery records whose response body contains cloud metadata keys
(ami-id, instance-id, iam/security-credentials, metadata/instance)
Repository migrations whose clone URL resolves to an internal address
Outbound HTTP/HTTPS from the Gitea server to 169.254.169.254, 168.63.129.16,
100.64.0.0/10 or internal RFC 1918 services it has no business reaching
DNS resolution of unusual hostnames by the Gitea process
Gitea process establishing connections to link-local or metadata addressesSIEM / IDS Rule (example):
alert http $HOME_NET any -> $HOME_NET any (msg:"Gitea webhook delivery to internal/metadata target (CVE-2026-22874)"; flow:to_server,established; content:"/api/v1/repos/"; http_uri; content:"/hooks"; http_uri; classtype:attempted-recon; sid:9022874; rev:1;)Detection is easier at the destination: alert on any HTTP request arriving at a metadata address or internal admin interface from the Gitea server, since legitimate webhook traffic should never reach those ranges.
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade to Gitea 1.26.3 or later, where the default matcher was expanded to cover the omitted ranges; 1.26.4 includes the follow-up fixes. |
| Workaround | Disable webhooks and repository migrations for untrusted users, or set a restrictive ALLOWED_HOST_LIST (for example explicit external hosts only) instead of the built-in external matcher. Block egress from the Gitea host and container to 169.254.169.254, 168.63.129.16, 100.64.0.0/10 and IPv6 transition prefixes at the network layer. |
| Config Hardening | Require IMDSv2 on AWS and disable the metadata service where it is not needed; run Gitea with a network policy that permits only required egress; audit webhook creation and migration activity; review existing hooks for IP-literal or internal targets. |
References
Notes
Review verdict: ingested as a genuine PoC. The repository contains a real, non-malicious SSRF exploit: it drives the Gitea hooks API, builds a webhook pointed at an internal address, triggers delivery through the git or contents API, and reads the captured response from the delivery endpoint. It is not a scanner, version audit, template or placeholder, and it contains no C2, persistence, evasion or credential-stealing functionality. The script requires an account that can create webhooks, so it demonstrates the authenticated variant described in the advisory rather than an unauthenticated attack.
License: the upstream repository has no LICENSE file, so copyright remains with the author and no reuse rights are granted. The archived script keeps the upstream code unchanged apart from a three-line research-use and source header; the upstream README is copied verbatim as upstream-README.md. The upstream file was named CVE-2026-22874-PoC without an extension and has been copied as exploit.py.
Limitations: the escape targets are hardcoded to well-known metadata and internal addresses; there is no arbitrary URL mode, no redirect handling and no gopher or file scheme support. The delivery response printed by the script is truncated to 1500 bytes while Gitea captures up to 1 MiB, so an operator reading the UI may see more than the script prints. The exploit needs a personal access token with hook rights, the target repository must permit the token owner to manage hooks, and the bypass only yields data when the chosen internal address actually answers. The 2001:db8::/32 documentation range is listed in the advisory as unblocked but is not a useful real target and is not used by this script. No exploit was executed while preparing this entry, so Status is PoC rather than Weaponized: the code path is complete but no captured successful run accompanies it upstream, and the hook identifier, repository and token in the commands above are placeholders.
| |