BUG: changeAppointmentStatus has no ownership check - any therapist can accept or decline another therapist's session

Aperta
#177 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@Varadraj75 ci sta già lavorando.

Dal 5/3/2026.

  • #178 di @Varadraj75 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
dart, supabase

Direzione di ricerca

Inizia in therapist/lib/repository/supabase_therapist_repository.dart intorno alla riga 58 e ispeziona changeAppointmentStatus, incluso il modo in cui l'ID del terapeuta autenticato viene ottenuto da Supabase Auth. Riproduci l'aggiornamento con sessioni appartenenti a due terapeuti; il lavoro è completato quando un terapeuta può modificare solo la propria sessione e la sessione di un altro terapeuta rimane invariata o restituisce un errore di autorizzazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is there an existing issue for this?
  • I have searched the existing issues
What happened?

📌 Issue Overview

changeAppointmentStatus updates a session's status by id alone with
no check that the session belongs to the currently authenticated therapist.
Any authenticated therapist who knows another session's UUID can accept,
decline, or modify it. RLS is also disabled on the session table, so
there is no database-level safety net either.

🔍 Steps to Reproduce

  1. Authenticate as Therapist A
  2. Obtain any session UUID assigned to Therapist B
  3. Call changeAppointmentStatus with Therapist B's session ID and
    status = 'declined'
  4. Therapist B's session is modified without any authorization error

SQL proof — this is exactly what the current code executes:

-- No ownership check — succeeds for ANY session ID
UPDATE session SET status = 'declined' WHERE id = '';
--  Success — modified without auth check

RLS check:

SELECT tablename, rowsecurity FROM pg_tables
WHERE schemaname = 'public' AND tablename = 'session';
-- returns: session | false   (no database-level protection)

🎯 Expected Behavior

changeAppointmentStatus should only update sessions where therapist_id
matches the currently authenticated therapist's ID. Any attempt to modify
another therapist's session should fail silently (0 rows affected) or
return an authorization error.

🚨 Actual Behavior

Any authenticated therapist can accept, decline, or modify any session in
the database by supplying its UUID.

therapist/lib/repository/supabase_therapist_repository.dart, line 58:

await _supabaseClient.from('session')
    .update({'status': status})
    .eq('id', appointmentId); //  no ownership check

📷 Screenshot

N/A

💡 Suggested Improvements

Add .eq('therapist_id', _supabaseClient.auth.currentUser!.id) to scope
the update to the authenticated therapist only:

await _supabaseClient.from('session')
    .update({'status': status})
    .eq('id', appointmentId)
    .eq('therapist_id', _supabaseClient.auth.currentUser!.id); //  ownership check
Record
  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
Lingua principale
Dart
Stelle
30
Fork
49
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/NeuroTrack

Tutte le issue di AOSSIE-Org/NeuroTrack

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.