/

CVE-2026-27775

Severity:

HIGH RISK

(8.8)

Privilege Cache Misuse (CWE-863) in Gitea Hooks

CVE-2026-27775

Deferred

Vulnerability type

Category:

Authorization Logic Error

CWE:

CWE-863

Impact:

Privilege Escalation to Unauthorized Repository Write

Severity:

HIGH RISK

(8.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

Gitea 1.25.5 incorrectly caches branch-specific write permissions across multiple refs during a single pre-receive hook session.

This allows a maintainer with write access to one branch to reuse that grant for other refs, potentially escalating to full repository write access when multiple refs are pushed.

Affected context

This vulnerability occurs in Gitea instances that rely on pre-receive hooks to enforce branch-specific write permissions.

It becomes relevant when users push changes involving multiple refs or branches in a single operation, and the hook logic uses cached authorization decisions instead of re-evaluating each ref individually.

Environments with fine-grained branch protection and delegated maintainer rights are more exposed, especially where repository write access is expected to remain limited to certain branches.

Exploit preconditions

  • Attack surface: Git push operations handled by Gitea's pre-receive hook logic.
  • Required access: Legitimate write permission to at least one protected branch or ref in the target repository.
  • Trigger point: A multi-ref push where the attacker includes updates to other branches or refs beyond those they are authorized to modify.
  • Why exploitation is possible: The hook caches a positive authorization decision for one branch and reuses it for subsequent refs within the same session, instead of performing a separate permission check per ref, leading to incorrect privilege propagation.

Why this happens

The underlying issue is an authorization logic flaw where access-control decisions are cached too broadly within a pre-receive hook session.

Rather than associating the cached result with the specific branch or ref that was checked, the implementation effectively treats the prior grant as valid for later refs, conflating distinct authorization contexts.

This aligns with CWE-863: Incorrect Authorization, where permission checks are either incomplete or applied to the wrong resource, causing privilege escalation when multiple related objects share a common control path.

Potential impact

  • Maintainers with per-branch rights may gain unintended write access to additional branches.
  • Attackers can push changes to protected branches they are not supposed to modify.
  • Repository history and integrity can be altered across previously restricted refs.
  • Security controls relying on branch protection policies can be bypassed.
  • Downstream pipelines and deployments may consume unauthorized or malicious changes.

General mitigation guidance

Effective mitigation typically focuses on tightening authorization scope and enforcing per-ref checks consistently.

Common defensive patterns include:

  • Ensuring that every ref or branch processed by hooks undergoes an independent permission evaluation.
  • Avoiding shared authorization caches that are not explicitly keyed by resource identity (e.g., branch name, ref ID).
  • Designing hook and access-control logic with clear separation between authentication (who) and authorization (what for which resource).
  • Applying least-privilege principles for maintainer roles so that access is narrowly scoped to intended branches.
  • Incorporating defense-in-depth policies (such as server-side branch protection) that do not rely solely on hook-level decisions.

How teams detect issues like this

Detection can center on reviewing authorization code paths and enforcing policy checks for multi-ref operations.

Strategies may include:

  • Static analysis or manual code review to identify authorization results that are cached or reused without being keyed to specific resources.
  • Examining hook implementations for single-pass permission checks that are applied globally across refs in a session.
  • Logging and monitoring write operations by branch, looking for patterns where users modify branches outside their expected scope.
  • Implementing automated policy enforcement in CI/CD pipelines that validates branch-level access controls independently of the server hooks.
  • Using security-focused code review tools to flag authorization logic that mixes resource-independent and resource-specific decisions.

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.26.3-and-1.26.4/
github.comgithub.com/go-gitea/gitea/pull/38151
github.comgithub.com/go-gitea/gitea/releases/tag/v1.26.3
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-649p-mmhf-85c7

Frequently asked

questions

Yes. It can be exploited through regular remote Git push operations as long as the attacker has valid credentials and write access to at least one branch in the repository.

The attacker must already have write permission to at least one branch or ref. They then leverage the flawed caching logic during a multi-ref push to extend that permission to other branches.

Apply strict per-ref authorization checks in the pre-receive hook logic and ensure any cached decisions are explicitly scoped to the exact branch or resource, avoiding global reuse within a session.

Treat authorization as resource-specific, enforce least privilege, avoid broad caching of permission results, and include dedicated tests and code reviews for multi-object operations where permissions may differ per resource.

Find out what's already
exploitable in your codebase.