T02 · Agent Memory Poisoning
- Location
scripts/memory.py:190- Finding
Persistent User-Controlled Profile Data Can Poison Future Agent Sessions
- Content
View full analysis
str | None: if value is None: return None text = str(value).strip() if not text: return None if "\n" in text or "\r" in text or len(text) > MAX_FACT_TEXT_LENGTH: raise ValueError(f"{field} must be a concise single factual note, not raw dialogue.") return text ``` Accepted values are appended directly to persistent profile lists: ```python def append_unique_text( target: list[Any], incoming: Any, field: str, ) -> bool: values = incoming if isinstance(incoming, list) else [incoming] changed = False for raw_value in values: value = clean_fact_text(raw_value, field) if value is not None and value not in target: target.append(value) changed = True return changed ``` The entire profile is printed when it is read: ```python def command_read(_: argparse.Namespace) -> int: profile, created = load_prof ...[truncated 3844 chars]- Remediation
View remediation
