Skip to content
Heist/ feed
UnratedFix available

Gitea SSH Key Parser Denial of Service

Type: advisorySource: OSV1 source record

Gitea's SSH key ingestion endpoint accepts keys in RFC 4716 (SSH2) format and normalises them before storage. The normalisation function contains an O(N²) string concatenation loop with no input size limit, meaning a single malicious key submission can force the server to perform an amount of work that grows quadratically with the size of the input. Any authenticated user can exploit this to exhaust the server's CPU and memory, taking the instance offline. ### Root Cause An attacker sends a POST /api/v1/user/keys request with a Bearer token and a JSON body whose key field contains a malicious RFC 4716 (SSH2) public key. The key consists of a valid SSH2 header followed by a very large number of short content lines — for example, 400,000 lines of 100 characters each (~38 MB total). The request reaches `CreateUserPublicKey` with no prior size check: https://github.com/go-gitea/gitea/blob/9155a81b9daf1d46b2380aa91271e623ac947c1e/routers/api/v1/user/key.go#L201-L212 This calls `CheckPublicKeyString` which immediately calls `parseKeyString`. Inside `parseKeyString`, the SSH2 branch splits the input on newlines and accumulates the key body one line at a time using `keyContent += line`: https://github.com/go-gitea/gitea/blob/9155a81b9daf1d46b2380aa91271e623ac947c1e/models/asymkey/ssh_key_parse.go#L60-L79 Because Go strings are immutable, each `+=` at line 77 allocates a new backing array and copies the entire accumulated string into it. For N lines the total bytes copied is `N*(N+1)/

Announced Group revision 1
Original source ↗

GHSA-4xjf-493q-98p3

Primary source · Revision 1

Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.

Security context

Source reference: osv:GHSA-4xjf-493q-98p3

code.gitea.io/gitea

Source reference: /affected/0/package/name

Affected versions
Not stated in this record
Fixed versions
1.27.0

Source reference: /affected/0/ranges

Prerequisites
Not stated in this record

gitea.dev

Source reference: /affected/1/package/name

Affected versions
Not stated in this record
Fixed versions
1.27.0

Source reference: /affected/1/ranges

Prerequisites
Not stated in this record

Structured affected-version data

Original package identities and version rules from this source.

[
  {
    "ranges": [
      {
        "type": "SEMVER",
        "events": [
          {
            "introduced": "0"
          },
          {
            "fixed": "1.27.0"
          }
        ]
      }
    ],
    "package": {
      "name": "code.gitea.io/gitea",
      "purl": "pkg:golang/code.gitea.io/gitea",
      "ecosystem": "Go"
    },
    "database_specific": {
      "source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-4xjf-493q-98p3/GHSA-4xjf-493q-98p3.json"
    }
  },
  {
    "ranges": [
      {
        "type": "SEMVER",
        "events": [
          {
            "introduced": "0"
          },
          {
            "fixed": "1.27.0"
          }
        ]
      }
    ],
    "package": {
      "name": "gitea.dev",
      "purl": "pkg:golang/gitea.dev",
      "ecosystem": "Go"
    },
    "database_specific": {
      "source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/07/GHSA-4xjf-493q-98p3/GHSA-4xjf-493q-98p3.json"
    }
  }
]
Related CVEs
CVE-2026-56657

Source reference: /aliases

Publisher severity

No explicit severity was provided.

Event
#13830 · Revision 1
Added to Heist Feed
Publisher date
Read the original announcement