GITEA.DEV · CVE-2026-120991 · Package
FIX → 28.4.0
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.
first public Nov 15, 2026 · 2 sources
Check it with your coding agent
It reads this page and tells you if your code or app is affected.
Only Gitea instances that set a package storage quota (LIMIT_TOTAL_OWNER_SIZE or LIMIT_SIZE_CONTAINER) are exposed; the default unlimited setting is not affected. A non-admin account is needed to trigger it, and the attacker must hold the complete bytes of the target object, which public packages and public base-image layers make easy to get.
Not affected if default-config, no-package-quota
Who cares container-registry, gitea, package-registry, self-hosted
gitea --version and whether [packages] sets LIMIT_TOTAL_OWNER_SIZE or LIMIT_SIZE_CONTAINER in app.ini; the flaw needs one of them set.>= 1.20, <= 28.3.0.Upgrade to 28.4.0
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 still false and deletes an object this request never created. Both and reach this path.
Are you affected?
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
InfraStack checks it against your stack and answers on your report, with the evidence and the fix.
28.4.0.existsPOST /v2/{owner}/{image}/blobs/uploads?digest=…PUT …/blobs/uploads/{uuid}?digest=…The attacker needs:
[packages] LIMIT_TOTAL_OWNER_SIZE or LIMIT_SIZE_CONTAINER set (both default to unlimited, so a default instance is not affected);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.
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:
// 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.
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.
LIMIT_TOTAL_OWNER_SIZE = 1 MiB. Alice has published tool.sh in the generic registry; the object is
data/packages/ee/fd/eefd3d…c39d.
/api/packages/alice/generic/tool/1.0/tool.sh (public, no credentials needed)./api/packages/mallory/generic/filler/1.0/filler.bin → 201. Any
further upload by mallory now exceeds the owner quota.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:
PUT /v2/mallory/scratch/blobs/uploads/{uuid}?digest=… has the same effect.GET /v2/alice/img/blobs/sha256:… answers 404 BLOB_UNKNOWN afterwards
and HEAD answers 404.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.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 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
NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.