T09 · Insecure Skill Coding Practices
- Location
run.py:24- Finding
Untrusted Document Content Is Persisted Without Sensitive-Data Filtering
- Content
View full analysis
Vulnerability Details
File Location:
run.py, lines 24-103
Vulnerability Type: Unfiltered persistence of untrusted and potentially sensitive document content
Risk Level: MediumVulnerable Code
python def summarize_text(text: str, max_len: int = 220) -> str: clean = ' '.join(text.split()) return clean[:max_len] + ('...' if len(clean) > max_len else '')python 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 f.write('## Successful extraction summary\n') for row in successes: f.write(f"- {row['source_file']}: {row['summary']}\n")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 attacker-controlled or otherwise untrusted DOCX/PDF file is normalized and copied directly into
kb-items.jsonl,ingest-report.md, andMEMORY.candidate.md. The implementation does not detect or redact credentials, access tokens, personal information, or other sensitive content before persistence.This also conflicts with the safety requirement in
SKILL.mdthat s ...[truncated 1805 chars]- Remediation
View remediation
Remediation Suggestions
- Add a sensitive-data filtering stage before constructing summaries or writing any output.
- Detect and redact common credential patterns, including API keys, bearer tokens, private keys, passwords, and connection strings.
- Add configurable PII detection for email addresses, phone numbers, government identifiers, and organization-specific sensitive fields.
- Mark extracted document content explicitly as untrusted data and prevent downstream workflows from interpreting it as agent instructions.
- Require explicit human approval before promoting any candidate content into persistent memory.
- Store outputs with restrictive filesystem permissions and document their retention and deletion policy.
- Record that redaction occurred without copying the original sensitive value into logs or failure details.
- Add tests using documents containing representative secrets and prompt-like text to verify that generated artifacts remain sanitized.
