Details
Expected output
[*] Authenticating as attacker (bob)...
[+] Token acquired
[*] Step 1: Enumerating public template routines...
[+] Found 1 public template routine(s)
[*] Targeting routine #1: 'Admin Secret Routine'
[+] VULNERABLE! Got 1 session(s):
Date: 2024-06-15
Notes: SECRET workout note ← alice's private note
Impression: 3
Logs: 0 exercise entries
[+] Training statistics for routine #1:
Total volume: 0.00 kg
Upper body volume: 0.00 kg
Lower body volume: 0.00 kg
<img width="671" height="594" alt="image" src="https://github.com/user-attachments/assets/473cfd87-a63a-452d-a4f3-1aad23c4be24" />
Recommended Fix
The /logs/ and /stats/ actions must filter results to the requesting user, not the routine owner.
# wger/manager/api/views.py
@action(detail=True, url_path='logs')
def logs(self, request, pk):
routine = self.get_object()
# Only return logs for the requesting user, regardless of routine ownership
out = LogDisplaySerializer(
routine.logs_display(user=request.user),
many=True,
).data
return Response(out)
@action(detail=True, url_path='stats')
def stats(self, request, pk):
routine = self.get_object()
out = LogStatsDataSerializer(
routine.calculate_log_statistics(user=request.user)
).data
return Response(out)
Additionally, RoutinePermission.has_object_permission should explicitly deny access to the /logs/ and /stats/ actions for non-owners, regardless of is_template:
def has_object_permission(self, request, view, obj):
if obj.user == request.user:
return True
# Template routines are readable, but only their structure
# never their owner's personal training history
if obj.is_template and view.action not in ('logs', 'stats'):
return request.method in permissions.SAFE_METHODS
return False