Skip to content

[Bug]: Admin account username and password can be changed on dev demo server #4754

Open

Description

@BudsieBuds

🐛 Bug Description

On the dev demo server (https://dev.opensourcepos.org), users logged in as the default user (admin) are able to modify both the username and the password of the account.

Because the server is publicly accessible for testing and evaluation using well-known default credentials (admin / pointofsale), allowing these fields to be updated allows any visitor to lock everyone else out of the demo environment until the container is reset.

✅ Expected Behavior

On demo deployments (or when lockdown flags are enabled):

  • The default demo admin account credentials should be protected from modification.
  • Changes to the demo admin's username should be blocked (or the username field rendered readonly/disabled).
  • Password changes on the demo admin account should be blocked (e.g. returning Employees.error_updating_demo_admin or Employees.error_password_change_disallowed).

📊 Additional AI Generated Information & Code Analysis

Missing Username Restriction:
In app/Controllers/Employees.php, postSave() unconditionally updates $employeeData['username'] from POST input. Even if password changes are restricted, there is currently no check preventing changing the username of person ID 1 / demo admin.

Demo Environment Flag Status:
In app/Controllers/Employees.php, DISALLOW_PASSWORD_CHANGE only gates password changes if the environment variable is explicitly set to true:

if (!empty($this->request->getPost('password')) && ENVIRONMENT != 'testing' && filter_var(getenv('DISALLOW_PASSWORD_CHANGE'), FILTER_VALIDATE_BOOLEAN)) {
    return $this->response->setJSON([
        'success' => false,
        'message' => lang('Employees.error_password_change_disallowed'),
        'id'      => $employeeId
    ]);
}

On dev.opensourcepos.org, this variable either is not set or set to false, allowing password updates to succeed.

Existing Unused Language Strings:
The language files in app/Language/*/Employees.php already contain localized strings designed for this protection that are currently unused in the controller:

'error_updating_demo_admin' => 'You can not change the demo admin user.'
'error_deleting_demo_admin' => 'You can not delete the demo admin user.'
'error_password_change_disallowed' => 'Password changes are disabled in this demo.'

Activity

  1. objecttothis commented on Oct 23, 2026

    @objecttothis
    Member

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Still present (no demo-admin protection implemented).

    In app/Controllers/Employees.php::postSave():

    • username is unconditionally read from POST and included in $employeeData['username'] for both the "password changed" and "password not changed" branches — there is no check for the demo admin account (e.g. person_id === 1) before allowing the username to change.
    • The only password-change gate is:
      if (!empty($this->request->getPost('password')) && ENVIRONMENT != 'testing' && filter_var(getenv('DISALLOW_PASSWORD_CHANGE'), FILTER_VALIDATE_BOOLEAN)) { ... }
      which only blocks password changes when DISALLOW_PASSWORD_CHANGE is explicitly set truthy — it doesn't specifically protect the demo admin account, and if the env var isn't set on the demo server, this check is a no-op.
    • The language strings Employees.error_updating_demo_admin, Employees.error_deleting_demo_admin, and Employees.error_password_change_disallowed exist in app/Language/*/Employees.php but error_updating_demo_admin / error_deleting_demo_admin are not referenced anywhere in Employees.php (only error_password_change_disallowed is used, and only behind the env flag above).

    No PR is currently linked to this issue. The described vulnerability (anyone able to change the demo admin's username/password when DISALLOW_PASSWORD_CHANGE isn't set) appears to still be exploitable on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions