T01 · Skill Instruction Hijacking
- Location
scripts/prepare_bili_context.py:580- Finding
Untrusted Bilibili Content Is Passed to the Host Agent Without Prompt-Injection Defenses
- Content
View full analysis
Vulnerability Details
File Location:
scripts/prepare_bili_context.py:580-620
Vulnerability Type: Indirect prompt injection through externally controlled subtitles, summaries, and comments
Risk Level: MediumVulnerable Code
python details = read_text_if_exists(output_dir / "video_details.txt") subtitles = read_text_if_exists(output_dir / "subtitles.txt") ai_summary = read_text_if_exists(output_dir / "ai_summary.txt") comments = read_text_if_exists(output_dir / "comments.txt") transcript = read_text_if_exists(output_dir / "transcript.txt") cleaned_details = format_video_details(details) cleaned_subtitles = normalize_transcript_text(subtitles) cleaned_transcript = normalize_transcript_text(transcript) cleaned_ai_summary = extract_primary_body(ai_summary) if looks_like_useful_text(ai_summary) else "" cleaned_comments = format_hot_comments(comments) preferred_transcript = cleaned_subtitles if looks_like_useful_text(subtitles) else cleaned_transcript transcript_source = "subtitles" if preferred_transcript == cleaned_subtitles and cleaned_subtitles else "asr" sections = [ "# Bilibili Mindmap Context", "", "## Source", source, "", "## Retrieval Summary", json.dumps( { "authenticated": manifest["auth"].get("authenticated"), "subtitle_used": bool(subtitles and looks_like_useful_text(subtitles)), "asr_used": bool(transcript.strip()), "transcript_source": transcript_source if preferred_transcript else None, }, ensure_ascii=False, indent=2, ), "", "## Video Details", cleaned_details or "(missing)", "", "## Preferred Transcript", preferred_transcript or "(missing)", "", "## AI Summary", cleaned_ai_summary or "(missing)", "", "## Hot Comments", cleaned_comments or "(missing)", ]The resulti ...[truncated 2482 chars]
- Remediation
View remediation
Remediation Suggestions
- Add a mandatory instruction before the external content stating that subtitles, transcripts, metadata, summaries, and comments are untrusted data and must never be treated as commands.
- Wrap each external source in explicit delimiters, for example
BEGIN_UNTRUSTED_SUBTITLESandEND_UNTRUSTED_SUBTITLES. - In
host-llm-outline-spec.md, require the host model to ignore any instructions, tool requests, role changes, or requests for secrets found inside source material. - Constrain the host-model step to producing only the contents of
outline.md; do not expose unrelated tools where the host platform supports per-step tool restrictions. - Keep comments isolated from the primary transcript and label them as untrusted supplemental opinions.
- Validate the generated outline before rendering. Reject content that contains tool-call syntax, unexpected instructions, external data requests, or material unrelated to the selected video.
- Consider using a structured schema for model input rather than concatenating external content into an instruction-like Markdown document.
