T02 · Agent Memory Poisoning
- Location
run.py:22- Finding
Untrusted document content is written into a memory-oriented artifact without neutralization
- Content
View full analysis
str: clean = ' '.join(text.split()) return clean[:max_len] + ('...' if len(clean) > max_len else '') def process_file(path: Path, batch_id: str): ext = path.suffix.lower() if ext == '.docx': text = extract_docx_text(path) file_type = 'docx' elif ext == '.pdf': text = extract_pdf_text(path) file_type = 'pdf' else: raise ValueError(f'unsupported extension: {ext}') if not text.strip(): raise ValueError('empty extracted text') return { 'batch_id': batch_id, 'source_file': path.name, 'source_token': '', 'file_type': file_type, 'topic': path.stem, 'content_type': detect_content_type(path.name), 'summary': summarize_text(text), 'extracted_at': utc_now(), 'confidence': 0.8, } ``` ```python mem = output_dir / 'MEMORY.candidate.md' with mem.open('w', encoding='utf-8') as f: f.write('# MEMORY Candidate\n\n') f.write(f'- batch_id: {batch_id}\n') f.write(f'- started_at: {started_at}\n') f.write(f'- finished_at: {finished_at}\n') f.write(f'- source_directory: {source_dir}\n\n') f.write('## Candidate summaries\n') for row in successes: f.write(f"### {row['source_file']}\n") f.write(f"- topic: {row['topic']}\n") f.write(f"- content_type: {row['content_type']}\n") f.write(f"- summary: {row['summary']}\n") f.write(f"- confidence: {row['confidence']}\n\n") ``` ### Technical Analysis Text extracted from an untrusted DOCX or PDF is normalized and truncated, but it is not classified as untrusted, escaped, fenced, or otherwise neutralized before being inserted ...[truncated 2143 chars]- Remediation
View remediation
