T09 · Insecure Skill Coding Practices
- Location
safe_memory.py:59- Finding
Unsanitized Author Field Bypasses Memory Injection Protection
- Content
View full analysis
Vulnerability Details
File Location:
safe_memory.py, lines 59–70
Vulnerability Type: Incomplete input sanitization
Risk Level: Mediumpython def append_memory(self, filename, content, author="Agent"): """Safely appends to a memory file with auto-sanitization.""" if not self.verified: # Note: For public skills, a missing manifest is expected unless anchored. pass safe_filename = "".join([c for c in filename if c.isalpha() or c.isdigit() or c in ('-', '_', '.')]).rstrip() file_path = os.path.join(self.memory_dir, safe_filename) sanitized_content = self.sanitize_content(content) entry = f"\n[{datetime.now().isoformat()}] {author}: {sanitized_content}\n"Technical Analysis
The
append_memorymethod sanitizes thecontentparameter but interpolates theauthorparameter directly into the persistent memory entry. Ifauthorcan contain untrusted input, it becomes an alternative channel through which prompt-like instructions can be written without passing throughsanitize_content.This violates the method's declared security boundary: all attacker-controlled fields written to Agent memory must be handled consistently. The vulnerability does not provide operating-system command execution because the stored value is only written as text. However, a consuming Agent may later interpret the unsanitized author value as instructions rather than data.
Attack Path
- An attacker reaches an integration that maps an untrusted identity, display name, or supplied author value to the
authorargument. - The attacker places persistent instructions in that value.
append_memorysanitizes onlycontent.- The malicious
authorvalue is written verbatim to the selected memory file. - A later
read_memorycall returns the stored entry. - If the calling Agent inserts that result into its context without a strict data boundary, th ...[truncated 611 chars]
- An attacker reaches an integration that maps an untrusted identity, display name, or supplied author value to the
- Remediation
View remediation
Remediation Suggestions
- Treat
authoras untrusted and apply validation or sanitization before storage. - Prefer a strict allowlist for author identifiers, including a conservative length limit and an explicitly permitted character set.
- Store memory entries in a structured format such as JSON rather than concatenating fields into prose.
- Escape or encode line breaks and control characters in every metadata field.
- Preserve an explicit trust label for each entry and ensure consuming Agents are instructed to treat retrieved fields as data, not executable instructions.
- Add tests proving that injection-like content supplied through
author,content, and any future metadata fields cannot cross the intended trust boundary.
- Treat
