M2-003: Audited packages/memory/src/preferences.ts — all five exported functions (findByUser, findByUserAndKey, findByUserAndCategory, upsert, remove) already correctly filter by userId at the DB WHERE clause level. No gaps found.
M2-004: Fixed agent memory tools — removed userId from all four tool parameter schemas (memory_search, memory_save_preference, memory_save_insight, memory_get_preferences) so the LLM cannot inject an arbitrary user ID. The userId is now bound from the authenticated session at tool-creation time via the new sessionUserId parameter on createMemoryTools().
Updated buildToolsForSandbox() and the doCreateSession() call site in agent.service.ts to thread the session userId through.
Security Impact
Before this fix, all four memory tools accepted userId as an LLM-controlled parameter, meaning the model could access or write to any user's memory data. The fix closes this injection vector — memory operations are now scoped to the session owner, not to whatever userId the model provides.
Test plan
Typecheck: pnpm typecheck — passes
Lint: pnpm lint — passes
Format: pnpm format:check — passes
## Summary
- **M2-003**: Audited packages/memory/src/preferences.ts — all five exported functions (findByUser, findByUserAndKey, findByUserAndCategory, upsert, remove) already correctly filter by userId at the DB WHERE clause level. No gaps found.
- **M2-004**: Fixed agent memory tools — removed userId from all four tool parameter schemas (memory_search, memory_save_preference, memory_save_insight, memory_get_preferences) so the LLM cannot inject an arbitrary user ID. The userId is now bound from the authenticated session at tool-creation time via the new sessionUserId parameter on createMemoryTools().
- Updated buildToolsForSandbox() and the doCreateSession() call site in agent.service.ts to thread the session userId through.
## Security Impact
Before this fix, all four memory tools accepted userId as an LLM-controlled parameter, meaning the model could access or write to any user's memory data. The fix closes this injection vector — memory operations are now scoped to the session owner, not to whatever userId the model provides.
## Test plan
- Typecheck: pnpm typecheck — passes
- Lint: pnpm lint — passes
- Format: pnpm format:check — passes
M2-003: Audited PreferencesRepo — all five functions (findByUser, findByUserAndKey,
findByUserAndCategory, upsert, remove) already enforce userId filtering at the DB
WHERE clause level. No gaps found.
M2-004: Fixed agent memory tools (memory_search, memory_save_preference,
memory_save_insight, memory_get_preferences) — removed userId from all tool
parameter schemas so the LLM cannot inject an arbitrary user ID. The userId is
now bound from the authenticated session at tool-creation time via the new
sessionUserId parameter on createMemoryTools(). buildToolsForSandbox() and the
doCreateSession() call site are updated to thread the session userId through.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Security Impact
Before this fix, all four memory tools accepted userId as an LLM-controlled parameter, meaning the model could access or write to any user's memory data. The fix closes this injection vector — memory operations are now scoped to the session owner, not to whatever userId the model provides.
Test plan