Summary
Wger contains a broken access control issue that lets any authenticated user read another user's private workout logs and training statistics via the /logs/ and /stats/ routine actions.
When routines are marked as templates, permission checks mistakenly allow cross-user data disclosure, exposing sensitive fitness history to unauthorized accounts.
Affected context
This vulnerability arises in Wger's API layer, specifically within the RoutineViewSet where the custom /logs/ and /stats/ actions are exposed.
It affects deployments where routines can be marked is_template=True, and any authenticated user can invoke these actions against routines they do not own.
In this context, the view returns workout history tied to the routine's owner rather than the requesting user, causing unintended data exposure.
Exploit preconditions
- Attack surface: Wger web/API interface, particularly the
/logs/and/stats/endpoints on routine resources. - Required access: Any authenticated Wger account; no special roles or ownership of the target routine are needed.
- Trigger point: Calling the
/logs/or/stats/actions on a routine object the attacker does not own, especially whereis_template=Trueis set. - Why exploitation is possible: The object-level permission logic (
RoutinePermission.has_object_permission) grants read access based solely on the template flag and does not correctly bind logs and stats responses to the requesting user's own data.
Why this happens
The issue is rooted in broken object-level access control logic that misinterprets template routines as universally readable for all data associated with them.
Under CWE-639: Authorization Bypass Through User-Controlled Key, the API allows attackers to reference a routine identifier they do not own and still retrieve data, because the permission check does not validate ownership for the /logs/ and /stats/ actions.
It also reflects CWE-863: Incorrect Authorization, where the system checks only a coarse-grained condition (is_template=True) instead of enforcing that sensitive derived data (workout logs and stats) is limited to the requesting principal.
Abstractly, this pattern occurs when resource-level flags (like "template") are reused for user-facing permissions without differentiating between public structure and private, user-specific content.
Potential impact
- An attacker may view another user's private workout session notes.
- An attacker could read detailed exercise history and training statistics for arbitrary users.
- User privacy can be compromised by exposing sensitive health and fitness-related information.
- Attackers may correlate activity patterns or infer personal habits and schedules from training logs.
General mitigation guidance
Effective mitigation focuses on enforcing strict, user-bound authorization for all actions that return user-specific data.
Common defensive patterns include:
- Separating permissions for template metadata from permissions for user-owned content derived from those templates.
- Implementing object-level access checks that confirm both routine access and that the returned logs or stats belong to the requesting user.
- Designing API actions so that user-specific queries are keyed by the authenticated principal rather than by arbitrary resource identifiers supplied by the client.
- Applying least-privilege principles so that authenticated users can only read data explicitly scoped to their own account unless a clear "public" designation exists.
- Centralizing authorization logic for sensitive views to avoid duplicated or inconsistent permission checks.
How teams detect issues like this
Detection often involves a combination of code-centric and behavioral analysis:
- Static analysis or manual review focused on object-level permission classes and custom view actions, checking that ownership and user scoping are enforced consistently.
- Looking for API endpoints where user-specific data is returned based on resource IDs without cross-checking the authenticated user, especially when flags like
is_templateor "public" are used. - Adding security-focused tests that simulate requests from non-owners to routines, ensuring
/logs/and/stats/-style endpoints do not leak other users' data. - Monitoring access logs for patterns where many different routine IDs are queried by a single account, indicating possible enumeration for data harvesting.
- Utilizing automated security testing tools that can crawl the API and attempt ID-based access control bypasses against user-scoped resources.

