CVE-2026-77633: Cloudreve: Storage-quota TOCTOU race allows quota bypass and storage-based denial of service
Summary Cloudreve v4 splits the storage-quota check (reading the user's used bytes and comparing them to MaxStorage) and the charge (incrementing users.storage) into two non-atomic steps in the PrepareUpload code path. This creates a Time-of-Check to Time-of-Use (TOCTOU) race condition.
Published Sep 22, 2026
Affected packages
github.com/cloudreve/Cloudreve/v4
- Ecosystem
- Go
- Affected
- < 4.0.0-20260715025621-7329602751c0
- Fixed in
- 4.0.0-20260715025621-7329602751c0
- Check
go list -m github.com/cloudreve/Cloudreve/v4
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
Cloudreve v4 splits the storage-quota check (reading the user's used bytes and comparing them to MaxStorage) and the charge (incrementing users.storage) into two non-atomic steps in the PrepareUpload code path. This creates a Time-of-Check to Time-of-Use (TOCTOU) race condition. Any authenticated user — including an unprivileged account in the default User group — can concurrently issue several upload-session requests that all read the same stale used snapshot, each pass the check, and then each contribute their declared size to users.storage. The end result is that the total approved capacity exceeds the group's MaxStorage many times over.
The same primitive is trivially amplifiable into a storage-based denial of service. During PrepareUpload, Cloudreve reserves the declared size against users.storage before any bytes are written, so an attacker can push the reserved amount far beyond the host's physical disk (tested: a 1 GiB-quota account reserved 17 GiB in a single 20-way burst), and can then materialise the reservation by completing chunked uploads to actually write the excess bytes to disk. Amplification to the host's free space fills the disk and denies uploads for every user of the instance.
Exploitation requires only a valid session with Files.Write permission. No administrator configuration, no non-default storage policy, and no elevated privileges are needed. The default deployment (local storage policy, default User group) is affected.
Technical details
PrepareUpload in pkg/filemanager/fs/dbfs/upload.go splits quota enforcement across two stages:
Stage A — the check (snapshot compare, no lock) — pkg/filemanager/fs/dbfs/validator.go:
func (f *DBFS) validateUserCapacity(ctx context.Context, size int64, u *ent.User) error {
capacity, err := f.Capacity(ctx, u) // reads "used"
if err != nil { return ... }
return f.validateUserCapacityRaw(ctx, size, capacity)
}
func (f *DBFS) validateUserCapacityRaw(ctx context.Context, size int64, capacity *fs.Capacity) error {
if capacity.Used + size > capacity.Total { // snapshot compare only; no lock, no reservation
return fs.ErrInsufficientCapacity
}
return nil
}capacity.Used comes from the in-memory *ent.User that was hydrated once at the beginning of the request — pkg/filemanager/fs/dbfs/dbfs.go:
func (f *DBFS) Capacity(ctx context.Context, u *ent.User) (*fs.Capacity, error) {
...
res.Used = f.user.Storage // captured at request start
res.Total = requesterGroup.MaxStorage
return res, nil
}No SELECT is issued at check time, no row lock is taken on the user row, and pending upload sessions are not counted.
Stage B — the charge (single unconditional UPDATE, outside the tx) — pkg/filemanager/fs/dbfs/upload.go → inventory/tx.go → inventory/user.go:
// PrepareUpload: check (A) ... then, many statements later ...
if err := f.validateUserCapacity(ctx, req.Props.Size, ancestor.Owner()); err != nil {
return nil, err
}
...
if err := inventory.CommitWithStorageDiff(ctx, dbTx, f.l, f.userClient); err != nil { ... } // charge (B)
// inventory/user.go
c.client.User.Update().Where(user.ID(uid)).AddStorage(diff).Exec(ctx) // SQL: storage = storage + diffBetween A and B the code performs storage-policy load-balancing, save-path generation, encryption-metadata generation, transaction start, placeholder-file/entity creation, and metadata upsert. This leaves a wide race window. N concurrent PrepareUpload requests each read the same stale Used snapshot at A, each pass their independent quota check, and then each add their own size to users.storage at B. The committed total is up to N × size above MaxStorage.
Three defensive controls that would each independently close the race are missing:
- The check and the charge are not enclosed in the same transaction with a
SELECT ... FOR UPDATEon the user row. - The charge is a plain
storage = storage + :sizeUPDATE, not an atomic conditional update of the formUPDATE users SET storage = storage + :size WHERE id = :uid AND storage + :size <= :max_storage. Usedis computed only from committed entities. Concurrent pending upload sessions (which have already been reserved by the accounting model) are not counted, so races among sessions that haven't yet completed are invisible to each other.
Credited to newugly.
References
- https://github.com/cloudreve/cloudreve/security/advisories/GHSA-xj3h-wwxq-gfcj
- https://nvd.nist.gov/vuln/detail/CVE-2026-77633
- https://github.com/cloudreve/cloudreve/commit/7329602751c00bb4136fe9ad8b364d0df70773df
- https://github.com/cloudreve/cloudreve/releases/tag/4.18.0
- https://github.com/advisories/GHSA-xj3h-wwxq-gfcj
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-77637
Cloudreve: Privilege Scope Bypass: State-Mutating Admin Operations Accessible via Read-Only OAuth Scope
low3.8Sep 22, 2026CVE-2026-79913
Cloudreve: SSRF guard bypass: checkIP does not decode IPv6-transition wrappers (NAT64, IPv4-compatible, 6to4) reaching internal and cloud-metadata addresses
medium6.5Sep 22, 2026CVE-2026-54563
Cloudreve WebDAV (`/dav`) has Path Traversal / Broken Access Control — scoped DAV credential escapes its configured account root
high7.1No fixAug 26, 2026GHSA-vx2m-jpxr-xv7w
Cloudreve has Broken Access Control - Revoked Share Access Still Allows Signed File URL Generation via Cached context_hint
medium5.3No fixAug 24, 2026GHSA-w8j7-39hp-8x59
Cloudreve's remote download file paths can escape the selected destination directory
medium5.5No fixAug 24, 2026CVE-2026-55495
Cloudreve: Path Traversal in WOPI PUT_RELATIVE Allows Arbitrary File Creation in Owner Account
medium4.3No fixJul 24, 2026
