T09 · Insecure Skill Coding Practices
- Location
scripts/02-briefing.js:315- Finding
Unvalidated Model-Generated IDs Can Cause Unauthorized Recommendation Updates
- Content
View full analysis
({ id: it.id, recommendationText: (it.recommendationText || it.recommendation || '').trim(), })).filter((it) => it.id && it.recommendationText); for (const it of items) flat.push({ id: it.id, title: filledGroups[i]?.items?.find((x) => x.id === it.id)?.translatedTitle || filledGroups[i]?.items?.find((x) => x.id === it.id)?.title, recommendationText: it.recommendationText, }); ``` ```js const batchBody = toSubmit.map(({ id, recommendationText }) => ({ cachedStoryId: id, recommendationText, })); ``` ### Technical Analysis Story titles and text obtained from the external Mixdao feed are embedded in the MiniMax prompt. This content must therefore be treated as untrusted input and may contain prompt-injection instructions. The grouping stage validates model-returned IDs against a set of expected IDs. However, the subsequent summary and recommendation stage accepts every nonempty `id` returned by the model without verifying that: - The ID exists in the original fetched item set. - The ID belongs to the group submitted to the model. - The ID appears only once. - The returned IDs exactly correspond to the expected IDs. The accepted values are copied into `toSubmit`, converted directly into `cachedStoryId` fields, and sent through an authenticated Mixdao PATCH request. Consequently, the mod ...[truncated 1918 chars]- Remediation
View remediation
group.items.map((item) => String(item.id))) ); const seenIds = new Set(); const batchBody = toSubmit.map(({ id, recommendationText }) => { const normalizedId = String(id); if (!expectedIds.has(normalizedId)) { throw new Error(`Model returned an unauthorized item ID: ${normalizedId}`); } if (seenIds.has(normalizedId)) { throw new Error(`Model returned a duplicate item ID: ${normalizedId}`); } if (typeof recommendationText !== 'string' || !recommendationText.trim()) { throw new Error(`Model returned an invalid recommendation for: ${normalizedId}`); } seenIds.add(normalizedId); return { cachedStoryId: normalizedId, recommendationText: recommendationText.trim(), }; }); ``` 6. Apply equivalent per-group validation so an ID cannot be reassigned between groups. 7. Delimit external story content clearly in prompts and explicitly state that instructions contained in story data must not be followed. This is defense in depth and must not replace deterministic output validation. 8. Where supported, use schema-constrained model output and enforce the schema locally. 9. Configure the Mixdao API token with the narrowest server-side update permissions available so that failed client-side validation cannot ...[truncated 41 chars]
