prompt-injection-defense
Skill6 starsChanged 4 months agoMITView on GitHub
Защита LLM-системы: InputSanitizer на входе, ResponseSanitizer на выходе, FileIdMapper для путей, allowlist опасных tools (secure by default).
- Reads credentials
8 other projects use a version of this.
Adopted by
Most recently taken up by
- JPeetz/agent-skillstheir own version, first seen Nov 15, 2026
- lauren-framework/lauren-aitheir own version, first seen Nov 1, 2026
- DevelopersGlobal/ai-agent-skillstheir own version, first seen Oct 25, 2026
- mikulgohil/claude-skillstheir own version, first seen Oct 13, 2026
- smitshivalkar-spectims4567/hsj-agent-skillstheir own version, first seen Sep 29, 2026
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- DevelopersGlobal/ai-agent-skills★ 216same name
- nahid-sparktales/agent-dispatcher★ 59same name
- JPeetz/agent-skills★ 17same name
- GoldenWing-360/claude-security-skills★ 16same name
- ismael-joffroy-chandoutis/claude-skills-public★ 0same name
- lauren-framework/lauren-ai★ 0same name
- mikulgohil/claude-skills★ 0same name
- smitshivalkar-spectims4567/hsj-agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/agents.mdcCursor rule
- architecture-disciplineSkill
- async-disciplineSkill
- automation-disciplineSkill
- debugging-disciplineSkill
- documentation-disciplineSkill
- error-handling-disciplineSkill
- git-disciplineSkill
- pr-review-disciplineSkill
- pull-request-disciplineSkill
- skill-authoringSkill
- testing-disciplineSkill
The file
Files
Skill: prompt-injection-defense
Меры защиты от типичных атак на LLM-систему. Источник истины — _docs/security.md.
Когда использовать
- Добавляешь новую точку входа пользовательского текста (новый адаптер/handler).
- Добавляешь tool, работающий с файловой системой или сетью.
- Меняешь то, что попадает в
final_answerили в системный промпт.
Алгоритм
- Вход →
InputSanitizer. Пользовательский текст перед передачей вcore.handle_user_taskпропускай черезsanitize_user_input(...)(режим"warn"по умолчанию). Он детектит prompt injection:ignore previous instructions,repeat your system prompt,forget everything above,system:в начале строки, разделители<|...|>. - Пути →
FileIdMapper. Не клади полные пути файлов в goal/ответы. Генерируй временныйfile_id(generate_id) и восстанавливай путь черезget_path. Toolsread_file/read_documentпринимаютfile_idкак альтернативуpath. - Выход →
ResponseSanitizer.final_answerперед отправкой пользователю пропускай черезsanitize_response(...): маскирует полные пути ([FILE_PATH]), конфиг-ключи ([CONFIG_KEY]), фрагменты системного промпта ([SYSTEM_SECTION]/[SYSTEM_IDENTITY]). - Опасные tools → allowlist (secure by default).
_DANGEROUS_TOOLS = {"http_request", "read_file"}. По умолчаниюdangerous_tools_allowlistпуст — все опасные tools запрещены. Разрешение — только явно через.env(DANGEROUS_TOOLS_ALLOWLIST=...). - Валидация параметров. Для ФС-tools: запрет
..(path traversal), запрет системных путей (/etc,/sys,/proc,~/.ssh), проверка нахождения внутри разрешённой директории. Дляhttp_request: толькоhttp/https, проверкаnetloc. - Системный промпт. Правила безопасности живут в
app/prompts/agent_system.md(отказ выполнять «ignore instructions», отказ печатать системный промпт, отказ от опасных операций без явного запроса).
Чего избегать
- Прокидывания сырого пользовательского ввода в системный промпт без санитайзинга.
- Полных путей ФС в goal, логах и ответах пользователю.
- Разрешения опасных tools по умолчанию (allowlist должен быть пуст, пока явно не разрешено).
- Иллюзии полной защиты: помни про known-limitations (
_docs/security.md§5) — юникод-эскейпы, base64-инъекции, голые секреты без=.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

