Private memories saved without a source are visible to every recall
Description
Memory.remember(private=True) without a source stores a private record whose source is None. The privacy filters in both recall paths test
if not r.private or r.source == source
(lib/crewai/src/crewai/memory/unified_memory.py in the shallow path, lib/crewai/src/crewai/memory/recall_flow.py in the deep RecallFlow path). For such a record, r.source == source reduces to None == None — True — so the record is returned to every default caller (source=None, include_private=False). The privacy flag is effectively void for source-less records.
Reproduction (current main)
storage.save([MemoryRecord(content="secret api key sk-abc123", scope="/notes", embedding=[1.0, 0.0], private=True, source=None)])
mem = Memory(llm=..., storage=storage, embedder=...)
results = mem.recall("secret api key", scope="/notes", depth="shallow", include_private=False)
# -> returns the private record to an unprivileged caller
Same leak through the default depth="deep" path.
Expected behavior
A private record should only be visible when the caller supplies the matching non-None source, or passes include_private=True. Private records saved without a source should be invisible to unprivileged recalls (they opted into privacy; nothing can prove ownership).
Suggested fix
Tighten both filters to not r.private or (source is not None and r.source == source). Legitimate access is unaffected: records with a real source stay visible to that source, and include_private=True still sees everything.
A possible follow-up hardening: warn (or validate) on remember(private=True, source=None) at save time, since such records can then only be retrieved via include_private=True.
Happy to submit a PR with regression tests for both paths.