Skip to content

[Vulnerability] Admin takeover via stale GitHub username #851

Open

Description

@aaqidmasoodi

Severity: High (but conditional)

Affected version: d3348376cba7cef663b0790eaeaa579e6855fb57

Summary

Admin authorisation is based on the mutable username field. If an admin renames their GitHub account, someone else can claim the old username and sign in to /dev/null with it. Because User::isAdmin() only checks whether username is in app.admins, the attacker becomes an admin. The new UpdateStaleUsernames action makes this path more direct by renaming any existing user with the same username before creating the attacker's account.

Affected Code

  • app/Models/User.php:325-330 — isAdmin() compares username with app.admins
  • app/Actions/UpdateOrCreateUser.php:31-40 — runs stale-username handling before updateOrCreate
  • app/Actions/UpdateStaleUsernames.php:16-27 — renames existing users with the same lowercased username

Preconditions

  1. A configured admin renames their GitHub username.
  2. The old GitHub username becomes available.
  3. An attacker claims that old username.

Steps to Reproduce

  1. Admin changes their GitHub username from admin-old to admin-new.
  2. Attacker creates a GitHub account named admin-old.
  3. Attacker signs in to /dev/null with GitHub.
  4. UpdateStaleUsernames renames the existing admin row to _renamed-<github_id>.
  5. The attacker's user is created with username admin-old.
  6. User::isAdmin() returns true for the attacker.

Impact

The attacker gains admin-only capabilities, including moderation and other privileged actions. If the admin's local row was already updated to the new username, the attacker can still claim the old username and become admin.

Suggested Fix

  • Authorize admins using an immutable identifier (github_id) or a dedicated database role/column, never username.
  • Migrate ADMINS configuration from usernames to GitHub IDs.
  • Ensure stale-username cleanup cannot transfer privileged identity.
  • Add a regression test: admin renames account, old username is claimed, attacker must not be an admin.

Activity

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