/

CVE-2026-60004

Severity:

CRITICAL RISK

(9.8)

Remote Code Injection (CWE-94) in Gitea Diffpatch API

CVE-2026-60004

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

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 critical command or code injection vulnerability in Gitea's diffpatch API may allow an attacker to achieve remote code execution through Git hook installation. The risk arises when the API processes attacker-controlled patch or repository-related input in a way that permits hook creation or execution.

Affected context

The vulnerability affects Gitea deployments using the diffpatch API and Git-related functionality that permits hook installation. It becomes especially risky when the API is reachable by untrusted or insufficiently trusted users and the resulting Git hooks execute with the privileges of the Gitea service or an associated repository process.

Exploit preconditions

  • Attack surface: Gitea's remotely accessible diffpatch API
  • Required access: Access sufficient to submit requests to the affected API; the exact requirement may depend on deployment authorization controls
  • Trigger point: Processing a diff or patch operation that reaches Git hook installation behavior
  • Why exploitation is possible: Attacker-controlled input can influence a repository operation in a manner that permits executable hook content or commands to be installed and subsequently run

Why this happens

The underlying bug is an insufficient separation between patch data and executable Git configuration or hook behavior. When API-controlled input is allowed to influence Git hook installation without strict validation, canonicalization, and authorization checks, attacker-supplied data may be interpreted as executable logic. This behavior maps to CWE-94, Improper Control of Generation of Code, commonly described as code injection.

Potential impact

  • An attacker may execute arbitrary code on the Gitea host or service container
  • The compromise could expose repositories, credentials, and application secrets
  • Attackers could modify source code, workflows, or repository contents
  • The vulnerability may enable lateral movement or broader infrastructure compromise
  • Service availability could be disrupted through unauthorized commands or resource use

General mitigation guidance

Mitigation generally focuses on preventing untrusted API input from creating

executable Git hooks or influencing command execution.

Common defensive patterns include:

  • Enforcing strict authorization for diff, patch, repository, and hook-related operations
  • Treating patch content and repository metadata as data rather than executable configuration
  • Validating, canonicalizing, and constraining all paths and hook-related values
  • Using secure-by-default repository handling that disables unnecessary hook installation or execution
  • Running Gitea with a dedicated, least-privileged service identity
  • Isolating repository-processing workers and limiting filesystem, network, and secret access
  • Applying request filtering and policy controls at the API boundary

How teams detect issues like this

Detection approaches may include:

  • Static analysis for code paths that concatenate or derive Git hook paths, shell commands, or executable configuration from request data
  • Code review checks for diffpatch handlers that lack strict authorization, path validation, or output encoding
  • Runtime monitoring for unexpected hook creation, modification, or execution in repository directories
  • Audit logging for patch API requests, repository changes, and process launches by the Gitea service account
  • Policy enforcement that blocks unapproved executable files or hooks in managed repositories
  • Automated security review tools that identify command and code injection patterns

Sources

SourceLink
blog.gitea.comblog.gitea.com/release-of-1.27.1/
github.comgithub.com/0xBlackash/CVE-2026-60004
github.comgithub.com/go-gitea/gitea/security/advisories/GHSA-rcr6-4jqh-j84m
runzero.comrunzero.com/blog/gitea/
cisa.govcisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2026-60004

Frequently asked

questions

Yes. The affected functionality is exposed through a remote API, although

successful exploitation depends on the attacker's access to that API and the

deployment's authorization controls.

The exact requirement depends on how the Gitea instance protects the

diffpatch API. Any account or integration allowed to invoke the relevant

operation should be treated as a potential attack surface.

Prevent API-controlled data from creating or executing Git hooks, enforce

strict authorization and validation, and isolate repository-processing

operations under a least-privileged service identity.

Treat repository and patch input as untrusted, apply centralized input and

path validation, monitor hook activity, and enforce security tests and

policies for any code that invokes Git or handles executable repository

metadata.

Find out what's already
exploitable in your codebase.