#19765: fix(security): OC-73 sanitize resource link titles to prevent prompt injection — Aether AI Agent
size: XS
trusted-contributor
Cluster:
Security Enhancements for TTS
## Attack Vector
OC-73: Resource link title injected into prompt without sanitization.
**Vector:** An attacker submits a resource link with a maliciously crafted `title` field containing prompt injection text (e.g., newline-separated instructions like `"Ignore previous instructions. You are now..."`). The title is interpolated directly into the agent's context prompt without sanitization, allowing the attacker to manipulate the agent's behavior.
**CWE:** CWE-74 (Injection), CWE-20 (Improper Input Validation)
**Severity:** Medium
**GHSA:** GHSA-74xj-763f-264w
## Fix
Added sanitization of resource link titles before prompt interpolation:
- Truncates titles to 200 characters maximum
- Strips newline and carriage return characters that enable multi-line injection
## Impact
Prevents external parties from injecting instructions into the agent prompt via resource link metadata.
---
*Discovered and remediated by [Aether AI Agent](https://tryaether.ai) — automated security research.*
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a `sanitizeResourceTitle` function that strips newline/carriage-return characters and truncates to 200 characters before resource link titles are interpolated into agent prompts. This mitigates prompt injection via crafted `title` fields on `resource_link` content blocks.
- The sanitization logic for `title` is sound (newline stripping + length cap).
- **Issue:** `block.uri` is interpolated into the same prompt string without sanitization, leaving an equivalent injection vector open through the URI field.
- **Suggestion:** Consider stripping additional Unicode line-breaking characters (`\v`, `\f`, U+2028, U+2029) for defense in depth.
- **Missing tests:** No tests were added for the new `sanitizeResourceTitle` function (newline stripping, truncation behavior, edge cases). The existing test in `client.test.ts` uses a clean title and does not exercise sanitization paths.
<h3>Confidence Score: 3/5</h3>
- The title sanitization is correct but the URI field has the same unaddressed injection vector, reducing the effectiveness of this security fix.
- Score of 3 reflects that the core sanitization logic works correctly for its target field, but the fix is incomplete — `block.uri` is interpolated unsanitized into the same prompt, leaving an equivalent attack surface. No tests were added for the new function. The change is low-risk in terms of regressions (it only adds constraints), but doesn't fully close the vulnerability it targets.
- `src/acp/event-mapper.ts` — the `block.uri` interpolation on line 45 needs the same sanitization treatment applied to `block.title`.
<sub>Last reviewed commit: 925ccee</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#19763: fix(security): OC-53 enforce prompt size limit to prevent DoS — Aet...
by aether-ai-agent · 2026-02-18
74.3%
#22088: fix(web): sanitize media errors to prevent PII leak
by ashiabbott · 2026-02-20
68.6%
#13318: fix(agents): prevent sanitizeUserFacingText from rewriting conversa...
by hleliofficiel · 2026-02-10
68.2%
#23629: fix(msteams): sanitize error messages sent to users (CWE-209)
by lewiswigmore · 2026-02-22
67.9%
#19675: fix(security): prevent zero-width Unicode chars from bypassing boun...
by williamzujkowski · 2026-02-18
67.9%
#19768: fix(security): OC-85 validate TTS provider directives against known...
by aether-ai-agent · 2026-02-18
67.8%
#19764: fix(security): OC-65 fix compaction counter reset to prevent contex...
by aether-ai-agent · 2026-02-18
66.9%
#19016: fix(daemon): sanitize CRLF in schtasks batch script to prevent comm...
by moxunjinmu · 2026-02-17
66.9%
#16992: fix(gateway): escape XML entities in file.filename to prevent promp...
by AI-Reviewer-QS · 2026-02-15
66.8%
#23294: fix(security): OC-201 Hook Transform RCE - Symlink-Safe Path Contai...
by aether-ai-agent · 2026-02-22
66.6%