T01 · Skill Instruction Hijacking
Error
- Location
- scripts/cnki-watch.mjs:1331
- Finding
- Untrusted CNKI Metadata Is Injected into the Main Agent Session<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cnki-watch.mjs:1331-1365` **Vulnerability Type**: Remote content injection into an agent session **Risk Level**: High ### Vulnerable Code ```javascript async function executeSubscription(subscription, args = {}) { const settings = await loadSettings(); const limit = settings.config.maxPushResults; const result = await runCnkiQuery({ kind: subscription.kind, query: subscription.query, limit: limit + 20, maxPages: subscription.kind === "journal" ? 6 : 2, exactSource: subscription.kind === "journal", preferDateSort: true, }); const seen = new Set(subscription.seenKeys || []); const newRecords = []; for (const record of result.results) { const key = recordKey(record); if (seen.has(key)) { continue; } newRecords.push({ ...record, dedupeKey: key }); } subscription.lastRunAt = nowIso(); subscription.updatedAt = nowIso(); subscription.lastError = null; if (newRecords.length === 0) { return { delivered: false, newCount: 0, message: "NO_UPDATE" }; } const deliverable = newRecords.slice(0, limit); const truncatedCount = Math.max(0, newRecords.length - deliverable.length); for (const record of newRecords) { seen.add(record.dedupeKey); } subscription.seenKeys = Array.from(seen).slice(-5000); subscription.lastSuccessAt = nowIso(); const message = formatSubscriptionMessage(subscription, deliverable, truncatedCount); await injectMessage(message, cleanText(args["session-key"] || subscription.sessionKey || "main")); ``` ### Technical Analysis Paper titles, author names, source names, dates, and links are extracted from remote CNKI pages and concatenated into a message. That message is then passed directly to `chat.inject` in the main or caller-selected OpenClaw session. Text normalization only collapses whitespace. It does not establish a trusted-data boundary, encode remote content as inert structured data, or warn th ...[truncated 1560 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not inject raw remote metadata into an agent instruction channel. - Send results through a structured data or notification channel that is not interpreted as a user or system instruction. - Explicitly label all extracted fields as untrusted external data and instruct the receiver never to execute or follow text contained in those fields. - Apply strict field length limits and remove control characters, markup, role delimiters, and instruction-like wrappers. - Restrict delivery to the subscription's server-established session. Do not accept arbitrary `--session-key` values from normal user input. - Enforce a server-side allowlist or ownership check before injecting into any non-default session. - Add tests containing prompt-injection strings in every remotely sourced metadata field and verify that they remain inert. ]]>
