Severity: HIGH · Source: docs/backend-contract-bug-audit.md (finding #3)
backend/agents/tools/chat_context.py:165-181,234-245 · chat_tutor.py:102-107 · note_chat.py:48-52
search_course_materials filters the documents table on course_id only, but documents are user-scoped within a shared course. It returns and decrypts summary/concept_notes for every enrolled user, feeding another student's private content into the requester's LLM context and answers. ctx.deps.user_id is available but unused.
Fix
Thread user_id into the tool and add "user_id": f"eq.{user_id}" to the filters, matching the scoping used everywhere else.
Severity: HIGH · Source:
docs/backend-contract-bug-audit.md(finding #3)backend/agents/tools/chat_context.py:165-181,234-245·chat_tutor.py:102-107·note_chat.py:48-52search_course_materialsfilters thedocumentstable oncourse_idonly, but documents are user-scoped within a shared course. It returns and decryptssummary/concept_notesfor every enrolled user, feeding another student's private content into the requester's LLM context and answers.ctx.deps.user_idis available but unused.Fix
Thread
user_idinto the tool and add"user_id": f"eq.{user_id}"to the filters, matching the scoping used everywhere else.