Summary
Gitea versions before 1.25.5 may accept malformed or injected X-Forwarded-Proto values when deriving public-facing URLs, causing spoofed canonical URL generation.
When an intermediary or client can influence these forwarding headers, public links and callbacks produced by Gitea can point to attacker-controlled schemes or endpoints, increasing phishing, misrouting, and trust boundary risks.
Affected context
This vulnerability occurs in Gitea deployments that rely on reverse proxies or load balancers and use the forwarded-proto header to determine the external URL scheme (e.g., HTTP vs HTTPS).
In setups where header values from clients or intermediaries are not strictly validated or normalized, Gitea's public URL detection logic can be influenced by malformed or injected values, affecting links in notifications, webhooks, and other canonical URL references.
Exploit preconditions
- Attack surface: HTTP(S) requests reaching a Gitea instance behind a proxy or load balancer.
- Required access: Ability to set or manipulate forwarded-proto or similar forwarding headers (often via a misconfigured proxy, gateway, or untrusted upstream).
- Trigger point: Gitea's computation of canonical/public URLs for links, redirects, notifications, or callback endpoints that rely on forwarded-proto.
- Why exploitation is possible: The application trusts the forwarded-proto value without robust validation or normalization, allowing crafted schemes or malformed values to be reflected into generated URLs.
Why this happens
The underlying issue stems from overly trusting transport-related headers for deriving security-sensitive canonical URLs, mapping to CWE-284: Improper Access Control in how trust boundaries are enforced.
Instead of treating forwarded-proto as a controlled proxy-only attribute, the logic permits unvalidated or malformed values to influence URL generation. This breaks the assumption that only trusted infrastructure can dictate the external scheme, creating a misconfiguration-prone pattern where user-controlled or untrusted intermediaries effectively bypass intended access and trust controls around canonical URL computation.
Potential impact
- Spoofed canonical URLs that may direct users to attacker-controlled domains.
- Increased effectiveness of phishing or social engineering via tampered links in emails or notifications.
- Misrouted callbacks or webhooks to unintended endpoints, potentially leaking metadata or secrets.
- Confusion or misconfiguration in downstream security controls that rely on accurate canonical URLs (e.g., CSP, OAuth callbacks, or SSO integrations).
General mitigation guidance
Mitigation typically focuses on tightening trust boundaries around header-derived configuration and enforcing strict validation of forwarding metadata.
Common defensive patterns include:
- Treating forwarded-proto and similar headers as trusted-only inputs from known proxies, never directly from clients.
- Normalizing and whitelisting acceptable schemes (e.g., strictly
httporhttps) before using them in canonical URL generation. - Centralizing external URL configuration in static, server-side settings rather than inferring it dynamically from request headers.
- Designing reverse proxy configurations so that only the proxy injects forwarding headers, and the application rejects or ignores conflicting client-supplied values.
- Applying least-privilege principles to URL-sensitive integrations (webhooks, OAuth, SSO) so that misgenerated URLs cannot escalate to broader compromise.
How teams detect issues like this
Organizations can detect this class of issue by combining configuration review and application-level analysis:
- Static analysis or code review targeting places where canonical URLs or callback endpoints are constructed from request headers rather than fixed configuration.
- Inspection of reverse proxy and load balancer configurations to confirm that forwarding headers are stripped from client requests and injected only by trusted infrastructure.
- Logging and monitoring of generated URLs in notifications, webhooks, and redirects to identify anomalous schemes or hostnames.
- Enforcing internal security policies that prohibit using unvalidated header values for security-sensitive URL computation, coupled with automated checks in CI pipelines.

