CVE-2026-58431: Gitea Remote Code Execution Vulnerability

MODERATE
Advisory Identifier: GHSA-h56g-4qw7-2mxg
CVSS 4.3
CWE-863
Published
Advisory Summary

CVE-2026-58431 is a MODERATE (CVSS 4.3) remote code execution vulnerability (CWE-863: Incorrect Authorization) affecting Gitea libraries in the Go ecosystem. The issue involves public-only api token restriction is not enforced on team api routes. Remediation is available by upgrading affected packages to version 1.27.0.

CVE-2026-58431 at a Glance

CVE Identifier CVE-2026-58431
GHSA Identifier GHSA-h56g-4qw7-2mxg
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-863: Incorrect Authorization
Affected Product Gitea
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 4.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-58431

To remediate this vulnerability, upgrade all affected Gitea dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gitea.dev fixed: 1.27.0
Upgrade gitea.dev to 1.27.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for gitea.dev

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-58431, inspect your project dependencies for Gitea:

inspect dependencies for gitea.dev

Analyze the terminal output to locate any version of Gitea in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.27.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. In Gitea, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary Gitea's `/api/v1/teams/{id}` API routes do not correctly enforce the `public-only` access token restriction. A `public-only` token is intended to limit API access to public repositories and public organizations. However, several team API routes continue to return private team repository metadata and private team activity feed entries when called with a `public-only` token. ### Details The `/api/v1/teams/{teamid}` route group uses: ```go orgAssignment(false, true) ``` This loads `ctx.Org.Team`, but does not load `ctx.Org.Organization`. The `checkTokenPublicOnly` middleware checks organization visibility through `ctx.Org.Organization`. When `ctx.Org.Organization` is nil, the organization visibility check silently passes. In addition, the team repository handlers return repositories without applying repository-level `public-only` filtering: ```go repo_model.GetTeamRepositories(...) convert.ToRepo(...) ``` They do not call: ```go ctx.TokenCanAccessRepo(repo) ``` The team activity feed handler also sets: ```go IncludePrivate: true ``` but does not apply: ```go opts.ApplyPublicOnly(ctx.PublicOnly) ``` ### PoC Vulnerability is verified on latest gitea release (1.26.2) and nightly build. Frist, create a `public-only` organization-scoped token for a user who is a member of a team in a private org with private repositories: <img width="1075" height="577" alt="image" src="https://github.com/user-attachments/assets/4a01d0ab-f67c-47c9-94b1-e74ddd77d7bc" /> <img width="649" height="375" alt="image" src="https://github.com/user-attachments/assets/b5d91962-088e-40f4-bc51-88a17946e6d8" /> Use the returned token to request team repositories: <img width="1728" height="190" alt="image" src="https://github.com/user-attachments/assets/0f15878f-5806-431d-958c-ffb39bf7c1e9" /> Expected result: Private repositories should be hidden or rejected for a public-only token. Actual result: Private team repository metadata is returned. The team activity feed endpoint can be tested similarly: <img width="1728" height="237" alt="image" src="https://github.com/user-attachments/assets/280a5ddf-ad14-4769-86a8-1fdad858287c" /> ### Impact A `public-only` token can access private team resources that should be hidden from that token.

CVE-2026-58431 Affected Gitea Versions

1 component(s)
Fixed Versions:
1.27.0
Product / Package Ecosystem Affected Versions Fixed Version
gitea.dev
Go
< 1.27.0
1.27.0

References

Frequently Asked Questions

What is CVE-2026-58431?
CVE-2026-58431 is a security vulnerability in Gitea involving Public-only API token restriction is not enforced on team API routes under CWE-863: Incorrect Authorization.
Which Gitea versions are affected?
Affected versions include releases prior to 1.27.0 across affected packages: gitea.dev.
What version fixes CVE-2026-58431?
Upgrading to 1.27.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gitea.dev affected?
Yes, gitea.dev is affected in releases prior to 1.27.0. Upgrade your dependency to 1.27.0 or later.
What is the CVSS score of CVE-2026-58431?
CVE-2026-58431 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2026-58431?
CVE-2026-58431 is classified under CWE-863: Incorrect Authorization (The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.).
How can I check Go dependencies for CVE-2026-58431?
Run the dependency tree command: 'inspect dependencies for gitea.dev'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-h56g-4qw7-2mxg",
  "modified" : "2026-07-21T21:50:11Z",
  "published" : "2026-07-21T21:50:11Z",
  "aliases" : [ "CVE-2026-58431" ],
  "summary" : "Gitea: Public-only API token restriction is not enforced on team API routes",
  "details" : "### Summary\n\nGitea's `/api/v1/teams/{id}` API routes do not correctly enforce the `public-only` access token restriction.\n\nA `public-only` token is intended to limit API access to public repositories and public organizations. However, several team API routes continue to return private team repository metadata and private team activity feed entries when called with a `public-only` token.\n\n### Details\n\nThe `/api/v1/teams/{teamid}` route group uses:\n\n```go\norgAssignment(false, true)\n```\n\nThis loads `ctx.Org.Team`, but does not load `ctx.Org.Organization`.\n\nThe `checkTokenPublicOnly` middleware checks organization visibility through `ctx.Org.Organization`. When `ctx.Org.Organization` is nil, the organization visibility check silently passes.\n\nIn addition, the team repository handlers return repositories without applying repository-level `public-only` filtering:\n\n```go\nrepo_model.GetTeamRepositories(...)\nconvert.ToRepo(...)\n```\n\nThey do not call:\n\n```go\nctx.TokenCanAccessRepo(repo)\n```\n\nThe team activity feed handler also sets:\n\n```go\nIncludePrivate: true\n```\n\nbut does not apply:\n\n```go\nopts.ApplyPublicOnly(ctx.PublicOnly)\n```\n\n### PoC\n\nVulnerability is verified on latest gitea release (1.26.2) and nightly build.\nFrist, create a `public-only` organization-scoped token for a user who is a member of a team in a private org with private repositories:\n\n<img width=\"1075\" height=\"577\" alt=\"image\" src=\"https://github.com/user-attachments/assets/4a01d0ab-f67c-47c9-94b1-e74ddd77d7bc\" />\n\n<img width=\"649\" height=\"375\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b5d91962-088e-40f4-bc51-88a17946e6d8\" />\n\nUse the returned token to request team repositories:\n\n<img width=\"1728\" height=\"190\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0f15878f-5806-431d-958c-ffb39bf7c1e9\" />\n\nExpected result: Private repositories should be hidden or rejected for a public-only token.\nActual result: Private team repository metadata is returned.\n\nThe team activity feed endpoint can be tested similarly:\n\n<img width=\"1728\" height=\"237\" alt=\"image\" src=\"https://github.com/user-attachments/assets/280a5ddf-ad14-4769-86a8-1fdad858287c\" />\n\n### Impact\n\nA `public-only` token can access private team resources that should be hidden from that token.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "gitea.dev"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.27.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/go-gitea/gitea/security/advisories/GHSA-h56g-4qw7-2mxg"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/go-gitea/gitea"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-gitea/gitea/releases/tag/v1.27.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-863" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-21T21:50:11Z",
    "nvd_published_at" : null
  }
}