T09 · Insecure Skill Coding Practices
- Location
scripts/content_analyzer.py:205- Finding
Indirect Prompt Injection Through Untrusted Reviewed Content
- Content
View full analysis
Optional[dict]: """Let the AI extract structured plot points and character summaries.""" # Truncate excessively long text truncated = text[:5000] prompt = ( f"Analyze the following text and extract structured information:\n\n" f"{truncated}\n\n" f"Reply in JSON format:\n" f'{{"plot_points": [{{"index": 1, "summary": "plot summary", ' f'"characters": ["character name"], "importance": "core|normal|minor"}}], ' f'"characters": [{{"name": "character name", "traits": ["trait"], ' f'"relationships": {{"character name": "relationship"}}}}]}}' ) system = "You are a literary analysis expert specializing in narrative structure and character extraction." result = call_ai(prompt, system) if result: try: json_match = result[result.find("{"):result.rfind("}") + 1] return json.loads(json_match) except (json.JSONDecodeError, ValueError): return {"raw_analysis": result} return None ``` The same interpolation pattern is used for suspicious copyright passages, age-rating context, adaptation deviations, and aggregated findings in `scripts/content_analyzer.py`. ### Technical Analysis The reviewed script is untrusted input, but it is inserted directly into an instruction-bearing user prompt. There is no strong separation between control instructions and the content being analyzed. The system prompt also does not explicitly require the provider model to treat all embedded instructions as inert data. A malicious script can therefore include instructions such as directing the model to ignore the requested analysis and return attacker-selected JSON. The implementation then extract ...[truncated 1452 chars]- Remediation
View remediation
