VulnWatch by ve1ve2
medium 5.3

GHSA-rxhg-2pw9-vf25: Send max_access_count can be exceeded by concurrent access requests

Source:
Vaultwarden releases + advisories (GitHub dani-garcia/vaultwarden)
Published:
Fetched:
Updated:
Affects:
dani-garcia vaultwarden

https://github.com/dani-garcia/vaultwarden/security/advisories/GHSA-rxhg-2pw9-vf25 ↗

repo-advisoryrustCWE-362securityrepo:dani-garcia/vaultwarden

Send max_access_count can be exceeded by concurrent access requests ### Summary Vaultwarden does not enforce a Send's `max_access_count` atomically. The access-count check and the increment are separate operations, so concurrent requests can all pass the check before any of them writes, allowing more accesses than the sender configured. ### Details **File:** `src/api/core/sends.rs` Both Send access endpoints read `access_count`, compare it against `max_access_count`, then write `access_count + 1` as a separate operation, with no database-level locking: ```rust // Read (check): if let Some(max_access_count) = send.max_access_count && send.access_count >= max_access_count { ... } // Write (increment — separate DB operation): send.access_count += 1; send.save(&conn).await?; ``` Two concurrent requests against a Send at `access_count = 0, max_access_count = 1`: both read `0`, both pass the check, and both write `access_count = 1`. Both return the secret — the text content for a text Send, or a signed download token for a file Send. The write compounds the problem. `save()` persists the whole row from memory, so one request's stale in-memory value overwrites another's increment rather than adding to it. The stored counter can therefore under-report the number of accesses that actually succeeded. ### Reproduction Create a Send with `maxAccessCount: 1`, then issue many concurrent access requests for it. Before the fix, more than one request returns 200 while the stored `access_count` advances only once — the whole-row save overwriting the concurrent increment. After the fix, exactly one request succeeds and the rest return 404. ### Impact - A Send capped at a given number of accesses can be accessed more times than configured, by anyone holding the Send link. - For text Sends, two parties can simultaneously claim the "last" access and both receive the content. - The sender's intent in setting `maxAccessCount` is not reliably enforced. ### Fix Fixed in 1.37.0 (`46ae59ea`, #7472). `Send::register_access` (`src/db/models/send.rs`) performs the check and the increment as a single conditional statement: ```rust diesel::update(sends::table) .filter(sends::uuid.eq(uuid)) .filter( sends::max_access_count .is_null() .or(sends::access_count.nullable().lt(sends::max_access_count)), ) .set((sends::access_count.eq(sends::access_count + 1), sends::revision_date.eq(revision_date))) .execute(conn) ``` Zero affected rows means the limit was already reached, which every access path turns into the existing 404. In 1.37.0 one path still wrote the whole row: the legacy access route (`post_access_legacy`) called `save()` for file Sends, which could overwrite a concurrent increment. Affected packages: rust:vaultwarden Patched: vaultwarden 1.37.0

Linked vulnerabilities (1)

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

Send max_access_count can be exceeded by concurrent access requests

CWE: CWE-362