/

CVE-2026-27780

Severity:

CRITICAL RISK

(9.8)

Authorization Bypass (CWE-863) in Gitea Hooks

CVE-2026-27780

Deferred

Vulnerability type

Category:

Authorization Bypass

CWE:

CWE-863

Impact:

Bypass of Branch Protection and Access Control

Severity:

CRITICAL RISK

(9.8)

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

A logic flaw in Gitea's pre-receive hook handling allows oversized input to bypass branch-protection checks when scanner errors are not treated as failures.

Under certain error conditions, pushes that should be blocked may be accepted, letting attackers circumvent repository protection rules and modify restricted branches.

Affected context

This vulnerability manifests in Gitea instances that rely on pre-receive hooks and branch protection to enforce repository policies.

It is relevant when push input is processed using buffered scanners that can encounter errors on large or malformed payloads.

When scanner failures are not handled in a fail-closed manner, the protection logic can be skipped, creating a gap between intended authorization rules and actual enforcement.

Exploit preconditions

  • Attack surface: Git push operations to repositories hosted on the affected Gitea instance.
  • Required access: Ability to push to the repository (e.g., a user with any level of write access to a branch or fork).
  • Trigger point: Submission of oversized or specially crafted input to the pre-receive hook that causes the scanner to error.
  • Why exploitation is possible: The authorization checks depend on successful scanning of hook input; scanner errors are not treated as denial conditions, allowing the operation to proceed without enforcing branch protection.

Why this happens

The root cause is improper handling of authorization logic when dependent input processing fails.

Pre-receive hooks rely on bufio.Scanner to parse incoming data before applying branch-protection rules, but errors from this scanner are not treated as hard failures.

This aligns with CWE-863: Incorrect Authorization, where the system assumes successful input processing and does not default to denying the operation on parsing errors, resulting in an authorization bypass.

Potential impact

  • Protected branches may be modified by users who should be blocked by branch-protection rules.
  • Code that should be subject to mandatory reviews or approvals can be pushed directly.
  • Security controls based on pre-receive hooks, such as policy or compliance checks, may be silently bypassed.
  • Integrity of critical branches (e.g., main, release, or security branches) can be compromised.

General mitigation guidance

Mitigation typically focuses on enforcing fail-closed behavior for authorization-related input processing.

Common defensive patterns include:

  • Treating any scanner or parsing error in pre-receive hooks as a hard failure that blocks the push.
  • Designing hook logic so that protection checks run only when inputs are fully and correctly parsed, and deny on any uncertainty.
  • Separating authorization decisions from fragile parsing paths where possible, or validating input size and format before deeper processing.
  • Applying least-privilege principles to repository write permissions so that fewer accounts can trigger edge-case behavior.

How teams detect issues like this

Detection approaches commonly include:

  • Code review focused on authorization paths, verifying that all error states from parsers or scanners lead to explicit denial of the operation.
  • Static analysis rules that flag authorization checks dependent on non-validated or potentially failing input-processing routines.
  • Logging and monitoring of pre-receive hook failures versus successful pushes, looking for anomalous cases where hooks encounter errors but the push still succeeds.
  • Periodic security tests or policy enforcement audits that attempt to push oversized or malformed data to confirm hooks fail closed.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.26.0/
github.comgithub.com/go-gitea/gitea/pull/36963
github.comgithub.com/go-gitea/gitea/releases/tag/v1.26.0

Frequently asked

questions

The vulnerability affects any protected branch or repository policy that depends on pre-receive hook evaluation. Attackers who can craft inputs that trigger scanner errors may bypass those protections, impacting critical branches across affected Gitea instances.

An attacker generally needs the ability to perform git pushes to the target repository. They do not need elevated administrative privileges, but must have some write capability that lets them submit crafted input to the pre-receive hook.

The safest pattern is to adopt strict fail-closed behavior: if input processing or scanning fails at any point in an authorization flow, the operation should be denied. Authorization decisions must never assume success when parsing has encountered an error or incomplete data.

Preventing similar issues involves designing security-critical logic so that it does not depend on fragile parsing without robust error handling, systematically reviewing all authorization checks for error paths, enforcing defensive coding guidelines around fail-closed behavior, and integrating tests that exercise malformed and oversized input scenarios.

Find out what's already
exploitable in your codebase.