---
id: "CVE-2026-120991"
page: "https://infrastack.ai/live/CVE-2026-120991"
kind: "vulnerability"
aliases: ["CVE-2026-120991", "GHSA-q8pg-ggp9-rm9m"]
title: "Over-quota container blob upload deletes other owners' package blobs"
severity: "medium"
cvss: null
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "gitea.dev", "fixed": ["28.4.0"], "affected": ">= 1.20, <= 28.3.0", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["container-registry", "cwe-460", "gitea", "package", "package-registry", "self-hosted"]
not_affected_if: ["default-config", "no-package-quota"]
published_at: "2026-11-15T21:03:16+00:00"
first_seen_at: "2026-11-15T21:12:46+00:00"
updated_at: "2026-11-15T21:14:18+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-q8pg-ggp9-rm9m", "first_seen_at": "2026-11-15T21:12:46+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-120991", "first_seen_at": "2026-11-15T22:40:23+00:00"}]
exploit_sources: []
---

# Over-quota container blob upload deletes other owners' package blobs

Link for people: https://infrastack.ai/live/CVE-2026-120991 (this .md is for agents)

When a package size quota is set, a regular user whose container blob upload is refused for quota still has the stored object with the same SHA-256 deleted, even if another owner's package uses it. The victim's package stays listed but its downloads fail until identical bytes are uploaded again.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- go:gitea.dev affected >= 1.20, <= 28.3.0 fixed 28.4.0

## How to check

- Check the Gitea version with `gitea --version` and whether `[packages]` sets `LIMIT_TOTAL_OWNER_SIZE` or `LIMIT_SIZE_CONTAINER` in app.ini; the flaw needs one of them set.
- Confirm the affected range: go:gitea.dev `>= 1.20, <= 28.3.0`.

## Fix

- gitea.dev (Go module): upgrade to `28.4.0`.

## Timeline

- 2026-11-15T21:12:46+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-q8pg-ggp9-rm9m
- 2026-11-15T22:40:23+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-120991

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-q8pg-ggp9-rm9m
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.4.0

## From the sources

On a Gitea instance with a package size quota configured, a regular user can delete the stored content of another owner's package file or container layer by pushing a copy of its bytes as a container blob to their own namespace while over quota. The push is refused with `403`, but the object is still removed from the package content store. That store keys objects by SHA-256 alone and shares them across all owners and package types. Afterwards the victim's package is still listed, but downloads fail with `500` (generic registry) or `404 BLOB_UNKNOWN` (container registry) until someone uploads identical bytes again.

The bug is in the error path of `saveAsPackageBlobInternal` in `routers/api/packages/container/blob.go`. On failure it deletes the blob's content store object unless `exists` is true. `exists` starts as `false` and is only set by `GetOrSavePackageBlob`. However, `CheckSizeQuotaExceeded` runs first inside the same `db.WithTx` closure, so a quota refusal reaches the rollback with `exists` still false and deletes an object this request never created. Both `POST /v2/{owner}/{image}/blobs/uploads?digest=…` and `PUT …/blobs/uploads/{uuid}?digest=…` reach this path.

The attacker needs:

- a non-admin account;
- an instance with `[packages] LIMIT_TOTAL_OWNER_SIZE` or `LIMIT_SIZE_CONTAINER` set (both default to unlimited, so a default instance is not affected);
- the complete bytes of the target object.

That last condition covers public packages, packages the attacker can read, and content known from elsewhere, such as public base-image layers sitting in a private organisation's image. No content is disclosed or substituted. The behaviour became reachable when `bf999e406994` ("Add Debian package registry (#24426)", first released in v1.20.0-rc0) moved the quota check inside the transaction.

The attached reproducer shows the effect end to end. Mallory fills their own quota, then pushes the bytes of alice's public generic file as a container blob and gets `403`. Alice's download then returns `500` and the object is gone from disk. As a control, the same over-quota upload through the generic registry leaves the object intact.

## Details

Scanned commit `31626de2a6cdd3e1fe93216e4ac80f511297f1e7`. Attacker: any regular user, writing only to their own namespace.
Required configuration: a package quota the attacker's upload can exceed, `[packages] LIMIT_TOTAL_OWNER_SIZE` or
`LIMIT_SIZE_CONTAINER`. Both default to `-1` (unlimited), so a default instance is not affected.

When a container blob upload is refused for quota, the error path of `saveAsPackageBlobInternal` deletes the object with the
uploaded content's SHA-256 from the package content store, even when that object existed before the request and belongs to
other owners' packages:

```go
// routers/api/packages/container/blob.go:38-66
func saveAsPackageBlobInternal(…, pb *packages_model.PackageBlob) (*packages_model.PackageBlob, error) {
	exists := false
	…
	err = db.WithTx(ctx, func(ctx context.Context) error {
		if err := packages_service.CheckSizeQuotaExceeded(ctx, pci.Creator, pci.Owner, packages_model.TypeContainer, hsr.Size()); err != nil {
			return err                          // exists is still false, pb is still the caller's non-nil argument
		}
		pb, exists, err = packages_service.GetOrSavePackageBlob(ctx, contentStore, pb, hsr)
		…
	})
	if err != nil {
		if !exists && pb != nil { // pb can be nil if GetOrInsertBlob failed
			if err := contentStore.Delete(packages_module.BlobHash256Key(pb.HashSHA256)); err != nil {
```

`exists` means "the blob was already there, do not remove it", but it starts as `false` and is only assigned at line 52. The
quota check at line 49 returns before that, so the rollback at line 59 sees `!exists` and a non-nil `pb` and deletes. `pb` is
`NewPackageBlob(hsr)` from `saveAsPackageBlob` (`blob.go:29`), so `pb.HashSHA256` is the hash of whatever the client sent.

The `exists := false` rollback dates from the original package registry, but it became reachable when the quota check moved
inside the transaction in `bf999e406994` ("Add Debian package registry (#24426)", 2023-05-02), first released in
`v1.20.0-rc0`; before that the check ran in front of `db.WithTx` and returned without reaching the rollback.

The content store is one flat namespace keyed by that hash, with no owner or package type in the key
(`modules/packages/content_store.go:64-71`, `aa/bb/<sha256>`). A generic file, a Maven artifact and a container layer with the
same bytes are one object. The delete removes only the object; the `package_blob` and `package_file` rows stay, so the package
is still listed and every download of it fails.

### Path from the request

Both ways of completing a blob upload call `saveAsPackageBlob` after verifying that the `digest` parameter matches the body:

- `POST /v2/{owner}/{image}/blobs/uploads?digest=…` → `PostBlobsUploads` (`routers/api/packages/container/container.go:283`)
- `PUT /v2/{owner}/{image}/blobs/uploads/{uuid}?digest=…` → `PutBlobsUpload` (`container.go:432`)

The guards in front are the `/v2` group's `ReqContainerAccess`, `UserAssignmentWeb`, `PackageAssignment` and
`reqPackageAccess(perm.AccessModeRead)` (`routers/api/packages/api.go:584`) and the routes' own
`reqPackageAccess(perm.AccessModeWrite)` (`api.go:566`, `569`). All of them are about the owner named in the URL, and a user
passes them for `/v2/<own name>/…`. Nothing relates the uploaded content to the owners of existing blobs, which is correct for
a deduplicating store and is why the rollback must not touch an object it did not create.
`CheckSizeQuotaExceeded` (`services/packages/packages.go:390`) skips site admins, so the doer has to be a non-admin.

### Example

`LIMIT_TOTAL_OWNER_SIZE = 1 MiB`. Alice has published `tool.sh` in the generic registry; the object is
`data/packages/ee/fd/eefd3d…c39d`.

1. Mallory downloads `/api/packages/alice/generic/tool/1.0/tool.sh` (public, no credentials needed).
2. Mallory uploads a filler file of 1 MiB − 1 byte to `/api/packages/mallory/generic/filler/1.0/filler.bin` → `201`. Any
   further upload by mallory now exceeds the owner quota.
3. Mallory sends `POST /v2/mallory/scratch/blobs/uploads?digest=sha256:eefd3d…c39d` with the downloaded bytes as body → `403`.

After step 3 `data/packages/ee/fd/eefd3d…c39d` no longer exists and
`GET /api/packages/alice/generic/tool/1.0/tool.sh` answers `500` (the server log shows `open …/eefd3d…c39d: no such file or
directory`).

Also observed on this build:

- The same request sequence finishing with `PUT /v2/mallory/scratch/blobs/uploads/{uuid}?digest=…` has the same effect.
- When the victim object is a container layer, `GET /v2/alice/img/blobs/sha256:…` answers `404 BLOB_UNKNOWN` afterwards
  and `HEAD` answers `404`.
- With `LIMIT_SIZE_CONTAINER = 1000` and no owner quota, no filler is needed: pushing a copy of a 5000-byte generic file
  of alice's as a container blob is refused with `403` and removes it.
- The package is still returned by `GET /api/v1/packages/alice`.

Read from the source and not triggered: any other error that makes `db.WithTx` return before line 52 takes the same branch
with no quota configured, for example a failing `sess.Begin()` in `txWithNoCheck` (`models/db/context.go:167`) or an error
from `CalculateFileSize` inside the quota check. These are not in the attacker's hands: the session is created without the
request context, so a client disconnect does not make `Begin` fail; it would take a real database outage. With default
settings the requests above return `201` and delete nothing.

### The sibling rollbacks get this right

The other places that roll back a content store write use a flag that starts on the safe side and is set only when this call
created the blob: `createPackageAndAddFile` deletes `if blobCreated && removeBlob` (`services/packages/packages.go:105-123`),
`addFileToPackageWrapper` sets `removeBlob = blobCreated` (`packages.go:231-249`), and `handleCreateManifestResult` 

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
