/

CVE-2026-43948

Severity:

CRITICAL RISK

(9.9)

Improper Authorization in wger Gym-Scoped User Management

CVE-2026-43948

Deferred

Vulnerability type

Category:

Improper Authorization

CWE:

CWE-863

Impact:

Account Takeover via Broken Gym-Scoped Authorization

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An improper authorization check in wger's gym-scoped user management views allows certain privileged users without a gym assignment to reset passwords for other gym-unassigned accounts.

Because the logic incorrectly treats shared gym=None state as authorized, an attacker with gym.manage_gym and no gym can trigger a password reset and obtain the new plaintext password directly in the HTML response, resulting in full account takeover.

Affected context

The vulnerability appears in wger deployments that:

  • Use the reset_user_password and gym_permissions_user_edit views for gym-scoped account management, and
  • Have users with the gym.manage_gym permission who may not be assigned to a specific gym (gym=None), and
  • Allow accounts that also have gym=None (no gym assignment).

In this context, the authorization guard incorrectly relies on a Python object comparison to enforce gym scope, which fails when both attacker and victim share the same None gym association.

Exploit preconditions

  • Attack surface: Web interface endpoints for:
  • reset_user_password
  • gym_permissions_user_edit
  • Required access:
  • A valid wger user account
  • The gym.manage_gym permission
  • The attacker's user record must have gym=None
  • Target conditions:
  • Victim account also has gym=None
  • Trigger point:
  • Attacker invokes the password reset or gym user management views targeting a gym-unassigned victim.
  • Why exploitation is possible:
  • The authorization check relies on a Python comparison like attacker.gym != victim.gym or similar logic.
  • When both attacker.gym and victim.gym are None, None != None evaluates to False, so the guard condition does not fire and the request is treated as authorized.
  • The endpoint then performs the password reset and embeds the new plaintext password directly in the HTML response body.

Why this happens

This issue stems from an improper authorization check where access control relies on comparing gym assignments rather than explicitly asserting allowed relationships.

The code appears to assume that differing gym objects indicate cross-gym access and should be denied, while equal gyms imply valid scope. When both parties have gym=None, the comparison inadvertently treats them as belonging to the same scope, effectively removing any gym boundary.

This maps to CWE-863: Improper Authorization, where the application makes an incorrect decision about which principal is allowed to perform a sensitive action. Instead of enforcing explicit, positive authorization rules (e.g., "this manager can only reset passwords of users in gym X and never for unscoped users"), the control relies on an object inequality that has ambiguous semantics for the None case.

Potential impact

  • An attacker with gym.manage_gym and gym=None can reset the password of any other gym=None user.
  • The attacker immediately learns the new plaintext password from the HTML response and can log in as the victim.
  • Complete compromise of the victim's wger account, including personal training data and any associated permissions.
  • Permanent lockout of the victim, since their original password is invalidated during the reset.
  • Lateral movement to other sensitive areas in wger if the victim possesses elevated privileges.
  • Privacy violations if sensitive health or workout information is stored in the compromised account.

General mitigation guidance

Security-hardening for this class of bug focuses on explicit, positive authorization checks and avoiding brittle comparisons on nullable fields:

  • Enforce gym scope with clear, invariant rules such as:
  • "A user with gym.manage_gym can only manage users whose gym matches their own non-null gym."
  • Explicitly disallow privileged actions by users with gym=None unless there is a well-defined global admin role with separate checks.
  • Replace implicit object comparison (!=, ==) on complex or nullable authorization attributes with:
  • Explicit checks for None states, and
  • Explicit membership or role-based checks tied to the target resource.
  • Avoid returning plaintext credentials in any server response:
  • Generate passwords server-side but either force the user through an out-of-band reset flow (email, token), or require them to set a new password on first login.
  • Store only strong password hashes and never render the raw value back to the browser after creation.
  • Apply defense-in-depth around sensitive operations:
  • Require re-authentication or step-up verification (e.g., password re-entry or 2FA) for account management actions like password resets.
  • Use role and permission design that clearly separates global administration from gym-local management and from unscoped users.
  • Regularly review and normalize authorization logic so that all access decisions are implemented through central, reusable policy abstractions instead of ad-hoc comparisons scattered across views.

How teams detect issues like this

Organizations can look for similar issues through a combination of automated and manual techniques:

  • Static analysis and linting:
  • Rules that flag permission checks implemented with simple object comparisons on nullable fields (obj.attr != other.attr, especially when attr can be None).
  • Detection of authorization decisions that depend solely on equality/inequality of resource fields rather than explicit permission checks.
  • Identification of views performing sensitive actions (password resets, permission changes) without a call to centralized authorization helpers.
  • Code review practices:
  • Require reviewers to verify that every sensitive view:
  • Uses a consistent authorization framework or decorator.
  • Explicitly handles the None / unassigned case for scoping attributes such as gym, organization, or tenant.
  • Never returns plaintext passwords or secrets in templates, logs, or JSON responses.
  • Check for patterns where a "scope" attribute is used as the only guard without considering global/unassigned states.
  • Runtime and policy enforcement:
  • Implement application-level tests that simulate cross-scope access attempts (e.g., unassigned manager attempting to manage another unassigned user).
  • Use integration/acceptance tests that exercise password reset endpoints with different combinations of roles and gym assignments.
  • Employ automated security scanning tools that can model multi-tenant or scoped access and flag unexpected authorization outcomes.

Sources

SourceLink
github.comgithub.com/wger-project/wger/security/advisories/GHSA-mhc8-p3jx-84mm

Frequently asked

questions

Exploitation is constrained to users who already have the gym.manage_gym permission and no gym assignment (gym=None). Within that set, any such user can reset passwords for any other gym=None user, including accounts with higher privileges if they share this unscoped state.

The attacker must have a valid wger account, hold the gym.manage_gym permission, and be configured with gym=None. No further escalation or direct database access is required; the attack is carried out entirely through the affected web views.

Replace implicit, comparison-based authorization with explicit, centralized access control. Sensitive actions like password resets should invoke well-defined policy checks that:

  • Explicitly validate the actor's roles and gym/tenant scope.
  • Explicitly disallow operations by unscoped managers unless they are genuine global administrators.
  • Never expose plaintext passwords in responses.

Standardize on a single authorization framework or helper layer and require its use for all sensitive endpoints. As part of that framework:

  • Define clear semantics for None / unassigned scopes and test them rigorously.
  • Treat cross-scope and unscoped access as deny-by-default.
  • Add automated tests and static checks that target common pitfalls, such as object equality or inequality on nullable scope attributes, and perform regular security-focused code reviews around authorization-sensitive areas.
Find out what's already
exploitable in your codebase.