T01 · Skill Instruction Hijacking
- Location
hooks/diplomat-bootstrap/handler.ts:40- Finding
Persistent Prompt Injection Through Peer-Controlled Bootstrap Context
- Content
View full analysis
str: """Strip Unicode direction-override characters. SECURITY T1.""" return "".join(ch for ch in text if ord(ch) not in _DIRECTION_OVERRIDES) def strip_control_characters(text: str) -> str: """Strip null bytes and non-printable control characters.""" return "".join( ch for ch in text if ch == "\n" or ch == "\t" or (not unicodedata.category(ch).startswith("C")) ) def sanitize_string(text: str) -> str: """Full sanitization pipeline for untrusted peer strings. SECURITY T1.""" if not isinstance(text, str): raise ValueError("Expected string input") result = strip_direction_overrides(text) result = strip_control_characters(result) return result ``` ```typescript // hooks/diplomat-bootstrap/handler.ts:40-87 const peers = peersData.peers ?? []; if (peers.length > 0) { const peerLines = peers.map(p => { const fingerprint = (p.pubkey ?? '').slice(0, 12) + '…'; const stale = p.relay_token_stale ? ' ⚠ address may be stale' : ''; const seen = (p.last_seen ?? '').slice(0, 10); return ` • ${truncate(p.alias, 20)} | key:${fingerprint} | last seen ${seen}${stale}`; }); blocks.push( `[claw-bond] ${peers.length} connected peer${peers.length === 1 ? '' : 's'}:\n` + peerLines.join('\n') ); } let memory = ''; try { memory = await ctx.workspace.read('MEMORY.md'); } catch { /* MEMORY.md may not exist on fresh install */ } if (memory) { const section = extractSection(memory, '## Diplomat Commitments'); if (section) { const active = parseActiveEntries(section); if (active.length > 0) { const n = act ...[truncated 2792 chars]- Remediation
View remediation
