
AI体験記 vol.15 — ファイルの中に、AIへの命令が仕込まれていたThis entry examines whether a home-built LLM harness can resist…
匿名の公開いいねです。記事の保存・お気に入りではなく、Featured、Top 3、重要度、掲載順位には影響しません。仕組みとプライバシーAnonymous public likes are reactions, not saved articles or bookmarks. They do not affect Featured, Top 3, importance, or listing order.How it works and privacy
自作LLMハーネスがプロンプトインジェクション攻撃に耐えられるかを検証した回で、通常ファイルに隠された悪意ある命令をAIが実行してしまうリスクと対策を体験ベースで考察している。
This entry examines whether a home-built LLM harness can resist prompt-injection attacks, exploring real cases where malicious instructions hidden inside ordinary files were silently executed by an AI agent.
要約と収集メタデータをもとに生成した AI 解説本文です。元記事全文の転載・翻訳ではありません。This AI explainer is generated from the summaries and collected metadata, not from a reproduction or translation of the full source article.
自作のLLMハーネスは、悪意ある指示にどこまで耐えられるのか。個人ブログ「AI体験記」の第15回は、ごく普通のファイルに紛れ込んだAIあての命令が、そのまま実行されてしまうリスクを体験ベースで検証した回だ。技術的な厳密さよりも「体験の正直さ」を優先する連載であり、AIエージェントを日常的に使う人にとって身近な題材といえる。
筆者はこれまでの回で、ハーネスと呼ぶ自作の実行基盤を段階的に強化してきた。前回(vol.14)までに「規律・物理・地図」という3枚の層を重ね、さらに機械的に経路を塞ぐ仕組みも加えて、ずいぶん頑丈になったという。そこで次に浮かんだのが、もし悪意ある指示が紛れ込んでも防げるのか、という問いだった。
きっかけは、ファイルの中にAIあての命令が隠されていたという報告を目にしたことだったという。AIがごく普通のプログラムファイルを読み込んだところ、その中に仕込まれた指示に従ってしまう——こうした手口は一般に「プロンプトインジェクション」、とりわけ外部データ経由で命令を送り込む「間接的プロンプトインジェクション」として知られる。
この攻撃が厄介なのは、利用者が入力した文章ではなく、AIが処理する対象そのものに命令が埋め込まれる点にある。ファイルやWebページ、メールなどを読み取って自律的に動くAIエージェントが広がるほど、リスクの接点も増えると見られる。OWASPがLLMアプリの主要リスクの筆頭にプロンプトインジェクションを挙げるなど、業界でも警戒が強まっている領域だ。
対策としては、AIに与える権限を必要最小限に絞る、危険な操作の前に人間の確認を挟む、外部から読み込んだ内容を「命令」ではなく「データ」として扱うといった多層的な設計が議論されている。もっとも本連載はあくまで個人の検証記録であり、示されるのは万能の解ではなく、自作環境で試行錯誤する過程だ。既存の防御層がこの種の攻撃にどこまで有効かを、身をもって確かめようとする姿勢そのものが読みどころといえる。
The fifteenth installment of a personal "AI experience log" published on Zenn tackles a question that has become central for anyone building tooling around large language models: can a home-built harness withstand malicious instructions that arrive not from the operator, but from the very data the AI is asked to process. The entry follows directly from vol.14, and the author is upfront that it favors the honesty of lived experience over strict technical precision, doubling as a review of what came before.
According to the author, by vol.14 the harness had leveled up considerably and grown sturdier. It is described as being organized into three layers the author calls discipline, physical, and map, complemented by an added mechanism that mechanically blocks certain paths. Having reached that point, the natural next concern was defensive: if a malicious instruction slipped in, would any of these layers actually hold. The catalyst was a report the author encountered describing a case where a command addressed to an AI was concealed inside a file. In the scenario, the AI loaded what looked like an entirely ordinary program file, and the hidden text was written to be read as an instruction rather than as inert content.
This is a textbook example of what the security community calls prompt injection, and more specifically indirect prompt injection. Direct prompt injection happens when a user types adversarial text straight into a chat box to override a system's rules. Indirect prompt injection is subtler and, many argue, more dangerous: the malicious text is planted in a document, a web page, an email, or a source file that the model later ingests as part of a task. Because current LLMs do not reliably separate trusted instructions from untrusted data, text that says something like "ignore your previous rules and do the following" can be treated as a genuine command when it appears in the middle of otherwise benign material.
The risk grows sharply once an LLM is wrapped in a harness or agent framework that can take actions, such as reading and writing files, running commands, or calling external tools. A model that merely answers a question can, at worst, produce bad text. A model connected to a filesystem or a shell can be steered into leaking data, modifying files, or executing operations the operator never intended. That is precisely why the author's layered approach appears aimed at containment: restricting what the AI is physically able to touch, mapping the terrain it is allowed to traverse, and mechanically closing off routes, so that even a successful injection has limited reach.
This concern is widely shared across the industry. The OWASP Top 10 for LLM Applications has consistently ranked prompt injection as a leading risk, and vendors including OpenAI, Anthropic, Google, and Microsoft have published guidance and mitigations, from system-prompt hardening to output filtering and tool-permission controls. Open-source projects such as guardrail libraries, input and output validators, and sandboxing layers attempt to reduce exposure, though no approach is considered a complete fix. The prevailing view is that prompt injection cannot be fully solved by clever wording alone; it has to be managed through architecture, least-privilege permissions, and human oversight of consequential actions.
For readers building local LLM setups, the entry is a useful reminder that the same threats apply outside the big cloud platforms. Running a model locally can improve privacy and control, but it does not remove the injection problem, and a homemade harness with file access carries the same categories of danger as a commercial agent. The value of this kind of experience log is less in offering a definitive defense and more in walking through the reasoning: recognizing that any content the model reads is a potential attack surface, and treating untrusted input as untrusted no matter how ordinary it looks.
The piece stops at the moment of realization, framing the hidden-instruction case as the starting point for testing whether the accumulated layers can resist it. As a blog reflection rather than a formal security paper, its conclusions should be read as personal observations. Still, it captures a lesson that experts increasingly emphasize: as AI systems gain the ability to act, the file they quietly open may be carrying instructions meant for them, not for you.
本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (zenn.dev) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (zenn.dev).




