/

CVE-2026-40474

Severity:

HIGH RISK

(7.6)

Access Control / Authorization Bypass in wger Gym

CVE-2026-40474

Analyzed

Vulnerability type

Category:

Access Control / Authorization Bypass

CWE:

CWE-284, CWE-862

Impact:

Vertical Privilege Escalation to Global Configuration Control

Severity:

HIGH RISK

(7.6)

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

A missing authorization check in wger's GymConfigUpdateView allows any authenticated user to modify the global gym configuration, despite a declared permission requirement.

Because GymConfig is an ownerless singleton and its save() method triggers bulk updates to user profile gym assignments, this flaw enables vertical privilege escalation to installation-wide configuration control.

Affected context

The vulnerability appears in wger deployments where:

  • Version 2.5 or below is in use.
  • The GymConfigUpdateView is exposed to authenticated users through the web UI.
  • GymConfig acts as a global, ownerless configuration singleton affecting all users.

In this context, the view declares permission_required = 'config.change_gymconfig' but inherits from WgerFormMixin instead of WgerPermissionMixin, so the declared permission is not actually enforced at runtime.

Exploit preconditions

  • Attack surface: Web application endpoint backing the GymConfigUpdateView.
  • Required access: Any authenticated account; elevated roles or admin status are not required.
  • Trigger point: Submitting a request that updates the GymConfig object via the vulnerable view.
  • Why exploitation is possible: The view defines a permission requirement but does not use the mixin that enforces it, causing the framework to skip the authorization check and accept updates from users who lack config.change_gymconfig.

Why this happens

The root cause is a misconfigured authorization pattern where the intended permission model is not wired into the actual view logic.

Conceptually, the developer relied on a declarative field (permission_required) but omitted the enforcement mechanism (WgerPermissionMixin), so no runtime check validates whether the caller holds the required permission.

This maps to CWE-284: Improper Access Control and is closely related to CWE-862: Missing Authorization, because access to a sensitive operation (editing a global singleton configuration) is not restricted to appropriately privileged roles.

The GymConfig singleton magnifies the impact: any unauthorized change operates at a global scope and may trigger side effects in save() that propagate changes across all user profiles.

Potential impact

  • Any authenticated user may change global gym configuration values.
  • User profile gym assignments can be bulk-updated without administrative approval.
  • Users may be reassigned to unintended gyms, disrupting access control or audit expectations.
  • Application-wide behavior tied to GymConfig may be altered, affecting billing, reporting, or policy enforcement.
  • Attackers could use configuration changes as a stepping stone for further misconfiguration or social engineering (e.g., misleading gym names or settings).

General mitigation guidance

Effective mitigation centers on enforcing access control at the same layer where sensitive operations are exposed and ensuring that configuration singletons are guarded by strong, explicit checks.

Pattern-based defensive measures include:

  • Ensuring that all views handling privileged actions (like global configuration updates) inherit from and invoke the proper authorization mixins or middleware that enforce declared permissions.
  • Implementing centralized access-control helpers so that permissions are not enforced ad hoc in each view, reducing the chance of mismatched configuration.
  • Treating global configuration singletons as highly sensitive resources, protecting them with administrator-only permissions and limiting the number of code paths that can modify them.
  • Applying the principle of least privilege so that normal user roles have no write access—direct or indirect—to application-wide settings.
  • Adding server-side validation that compares the acting user's role/permissions against a whitelist before allowing configuration writes, even if the UI already attempts to hide these options.

How teams detect issues like this

Detection generally involves examining how permission requirements are connected to the actual enforcement mechanisms and identifying sensitive endpoints that lack proper checks.

Useful strategies include:

  • Static analysis rules that flag views or controllers declaring permission metadata (e.g., permission_required) without inheriting from or invoking the corresponding enforcement mixin or decorator.
  • Code review checklists that require reviewers to confirm that every configuration, admin, or global-setting endpoint explicitly enforces authorization at the server side.
  • Policy-based linting in CI that scans for direct access to high-impact models (like singletons or global config records) and ensures those operations pass through standardized authorization helpers.
  • Runtime logging and alerting on configuration changes, including actor identity and source IP, to spot unexpected modifications from low-privileged accounts.
  • Periodic security tests or penetration tests focusing on "horizontal" access from basic accounts to admin or configuration features, verifying that UI constraints match backend enforcement.

Sources

SourceLink
github.comgithub.com/wger-project/wger/commit/47ee5af93b3ced24b9f94b0a8b9296b50bc9523f
github.comgithub.com/wger-project/wger/releases/tag/2.5
github.comgithub.com/wger-project/wger/security/advisories/GHSA-xppv-4jrx-qf8m

Frequently asked

questions

The vulnerability is broadly exploitable within the authenticated user base: any user who can log into the affected wger instance and reach the GymConfigUpdateView can attempt to change the global configuration, regardless of their assigned role.

No. The flaw arises precisely because the declared config.change_gymconfig permission is never enforced, so ordinary authenticated users without administrative privileges can perform actions that should be restricted to admins.

The safest pattern is to centralize authorization and ensure that sensitive views or controllers both declare and enforce permissions through a tested, common mechanism—such as a dedicated permission mixin, decorator, or middleware—not via ad hoc logic. Sensitive models like global configurations should only be writable through these guarded pathways.

Prevention typically involves establishing a clear access-control architecture (roles, permissions, and enforcement layers), using a small number of standardized mechanisms to check permissions, and backing this with automated checks. Incorporating security-focused code review, static analysis rules that detect unenforced permission declarations, and regular tests of administrative endpoints can greatly reduce the risk of similar vulnerabilities.

Find out what's already
exploitable in your codebase.