/

CVE-2026-27779

Severity:

HIGH RISK

(7.5)

Canonical URL Spoofing (CWE-284) in Gitea URL Logic

CVE-2026-27779

Deferred

Vulnerability type

Category:

Improper Access Control

CWE:

CWE-284

Impact:

Canonical URL Spoofing and Trust Boundary Bypass

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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 http or https) 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.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.25.5/
github.comgithub.com/go-gitea/gitea/pull/36810
github.comgithub.com/go-gitea/gitea/pull/36836
github.comgithub.com/go-gitea/gitea/releases/tag/v1.25.5

Frequently asked

questions

Exploitability depends on the deployment environment. It is most relevant where Gitea is behind proxies or gateways that allow clients or untrusted intermediaries to influence forwarded-proto or similar headers, enabling canonical URLs to be spoofed.

An attacker typically needs the ability to manipulate forwarding headers on requests that reach Gitea. This may come from direct client control in a misconfigured setup, influence over an upstream proxy, or operation of an intermediary service in front of Gitea.

The safest pattern is to stop inferring canonical URLs from unvalidated headers and instead rely on explicit, server-side configuration. Where header-based inference is unavoidable, accept only normalized, whitelisted scheme values injected by trusted proxies and ignore or reject all others.

Future prevention relies on treating transport and forwarding headers as part of a strict trust boundary: validate and normalize them, ensure only trusted infrastructure can set them, avoid using them directly in security-sensitive URL logic, and codify these rules into development guidelines and automated checks.

Find out what's already
exploitable in your codebase.