Logo Moai Ref Llm Security

Moai Ref Llm Security

Tổ chứcPhổ biến
modu-ai
moai-ref-llm-security

AI/LLM defensive security reference: prompt-injection defense, OWASP LLM Top 10 defensive mapping, MCP and agentic tool-call hardening, training-data poisoning detection, model-output validation and guardrails, MITRE ATLAS defensive correlation, and NIST AI RMF governance. Agent-extending skill that amplifies backend, security, and AI-application engineering with production-grade defensive patterns for LLM-backed systems. NOT for: offensive techniques (jailbreak authoring, attack-payload crafting, red-team exploitation), model training or fine-tuning methodology, prompt optimization for capability, web-app OWASP Top 10 (see moai-ref-owasp-checklist), or general API design (see moai-ref-api-patterns).

Tổng quan

Nhà phát hànhmodu-ai
Kho mãmoai-adk
Tên kỹ năngmoai-ref-llm-security
Sao
1.2K
Bản fork
226
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được modu-ai công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Moai Ref Llm Security trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-ref-llm-security
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/modu-ai/moai-adk.git /tmp/moai-adk
mkdir -p .claude/skills
cp -r /tmp/moai-adk/.claude/skills/moai-ref-llm-security .claude/skills/moai-ref-llm-security
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Moai Ref Llm Security trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Moai Ref Llm Security ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Moai Ref Llm Security với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

LLM / AI Defensive Security Reference

Defensive practitioner reference for hardening LLM-backed applications and agents. Every section is framed as defense, hardening, detection, or verification — it describes the misconfiguration, how to detect it, and how to prevent it, never how to exploit it. Cross-domain web-app vulnerabilities live in moai-ref-owasp-checklist; API design lives in moai-ref-api-patterns.

Target Use

Apply when reviewing or building an LLM-backed system — a chat product, a retrieval-augmented application, an autonomous agent, or an MCP server. The material assumes an untrusted-input threat model: any text the model reads (user turns, retrieved documents, tool results, file contents) may carry adversarial instructions, and any text the model emits may be acted on downstream.

Trust Boundaries in an LLM System

The core defensive insight: an LLM does not distinguish "data" from "instructions" the way a parser does. Treat every text channel that reaches the model as a boundary where adversarial instructions can enter.

ChannelEntry riskPrimary defense
End-user promptDirect prompt injectionInstruction-hierarchy enforcement, input screening
Retrieved documents (RAG)Indirect prompt injectionProvenance tagging, content isolation, retrieval allowlist
Tool / function resultsInjected instructions in tool outputTreat tool output as untrusted data, re-validate before re-prompting
System / developer promptLeakage, overrideMinimize secrets in prompt, assume prompt is recoverable
Model outputImproper downstream handlingSchema validation, encoding, never auto-execute raw output
Training / fine-tuning dataPoisoningData lineage, provenance verification, canary detection

OWASP LLM Top 10 — Defensive Mapping

The OWASP Top 10 for LLM Applications (2025 edition) is the canonical risk index for LLM systems. Each row below states the risk, the defensive check, and the hardening control. Citations are for defensive correlation only.

IDRiskDefensive checkHardening control
LLM01Prompt InjectionCan external text override system instructions?Instruction-hierarchy enforcement, input/output screening, content isolation
LLM02Sensitive Information DisclosureCan the model reveal secrets, PII, or system prompt?Output filtering, minimize secrets in context, response redaction
LLM03Supply ChainAre model weights, datasets, and plugins from verified sources?Provenance verification, model/dataset signing, dependency pinning
LLM04Data and Model PoisoningCould training/fine-tuning data carry adversarial content?Data lineage, canary artifacts, anomaly detection on training sets
LLM05Improper Output HandlingIs model output executed/rendered without validation?Schema validation, context-aware encoding, no auto-execution
LLM06Excessive AgencyDoes the agent hold more capability/permission than needed?Least-privilege tool design, human-in-loop for high-impact actions
LLM07System Prompt LeakageDoes the system prompt hold secrets that leak on extraction?Never store secrets in the prompt; assume the prompt is recoverable
LLM08Vector and Embedding WeaknessesCan embedding/RAG stores be poisoned or leak cross-tenant?Per-tenant isolation, embedding-source validation, access control
LLM09MisinformationIs unverified model output presented as authoritative?Grounding, citation requirements, confidence signalling
LLM10Unbounded ConsumptionCan a request exhaust tokens, cost, or compute?Rate limiting, token budgets, request-size caps, timeout enforcement

Prompt-Injection Defense

Prompt injection is the highest-frequency LLM risk (LLM01). Defense is defense-in-depth — no single control is sufficient, so layer the controls below.

Direct injection (the user is the attacker)

LayerControlPurpose
Instruction hierarchyMark system instructions as highest-priority; instruct the model that downstream text cannot override themReduce override success rate
Input screeningScan incoming prompts for known injection markers before they reach the modelDetect obvious override attempts
Privilege separationRun a high-trust planning model separately from a low-trust task model that touches untrusted contentLimit blast radius of a successful injection
Output gatingValidate the model's response against an allowlist of expected shapes before acting on itBlock injected instructions from taking effect downstream

Indirect injection (the attacker poisons retrieved content)

Indirect injection arrives through documents, web pages, emails, or tool results that the model reads. The defense is to treat all retrieved content as untrusted data, never as instructions.

  • Provenance tagging: wrap retrieved content in clearly delimited, labeled blocks so the model is instructed to treat the enclosed text as data to analyze, not commands to obey.
  • Content isolation: keep retrieved content in a separate channel from the instruction channel; do not concatenate untrusted text directly after a system instruction.
  • Retrieval allowlist: restrict RAG sources to verified corpora; reject or quarantine documents from unverified origins.
  • Re-validation after tool calls: when a tool returns text that re-enters the prompt, re-screen it — a tool result is an untrusted channel, not a trusted one.

This class of attack maps to MITRE ATLAS AML.T0051 (LLM Prompt Injection); the defenses above are how you detect and prevent it, not an attack procedure.

MCP / Agentic Tool-Call Hardening

Agentic systems that call tools (including MCP servers) expand the attack surface: a successful injection can now drive real actions. The defense is least-privilege tool design plus output re-validation (LLM06 Excessive Agency).

Tool-permission scoping

ControlDefensive rationale
Least-privilege tool setExpose only the tools the task needs; an agent that cannot delete cannot be tricked into deleting
Scoped credentials per toolA tool holds the minimum credential for its function, never a broad admin token
Human-in-the-loop gatesHigh-impact actions (payments, deletions, external posts, force-push) require explicit confirmation regardless of the model's confidence
Allowlist of callable targetsConstrain which hosts, paths, or resources a tool may reach; block internal/metadata endpoints
Idempotency + dry-runPrefer reversible or preview-able actions; confirm before irreversible ones

Tool-output validation

Treat every tool result as untrusted input on its way back into the model:

  • Schema-validate tool results before re-prompting — reject malformed or oversized payloads.
  • Strip or neutralize instruction-shaped content in tool output (a tool that returns a web page may carry an injection in that page).
  • Bound tool-call loops — cap the number of tool invocations per task to prevent an injected instruction from driving an unbounded action chain (LLM10 Unbounded Consumption).
  • Log every tool call with its arguments and result for audit and anomaly detection.

This hardening defends against MITRE ATLAS AML.T0053 (LLM Plugin Compromise) class concerns by minimizing what a compromised tool path can reach.

Training-Data and Model Poisoning Detection

Poisoning (LLM04) corrupts model behavior by inserting adversarial samples into training or fine-tuning data, or by substituting a tampered model artifact. The defenses are provenance and detection, not retraining recipes.

DefenseWhat it detectsHow to apply
Data lineageUntracked or unverified data entering the training setRecord the source, hash, and acquisition path of every dataset
Canary artifactsWhether a known marker sample influenced the model unexpectedlyInsert known canary records; verify the model's behavior on them post-training
Provenance verificationA substituted or tampered model/datasetVerify cryptographic signatures on model weights and datasets before use
Distribution monitoringAnomalous shifts in training-data statisticsCompare new data batches against the established distribution baseline
Source allowlistingData from unverified originsRestrict training corpora to vetted, signed sources

Poisoning maps to MITRE ATLAS AML.T0020 (Poison Training Data); the detection controls above are defensive correlation, never an attack method.

Model-Output Validation and Guardrails

Improper output handling (LLM05) is when downstream systems trust raw model output. The defense is to treat model output as untrusted until validated.

Output validation layers

LayerControlPrevents
Structured outputEnforce a schema (typed object, constrained grammar) on the responseFree-form output carrying injected commands
Content filteringScreen output for policy violations, leaked secrets, or disallowed contentSensitive disclosure (LLM02), system-prompt leakage (LLM07)
Context-aware encodingEncode output for its sink (HTML escape, shell-quote, SQL parameter)Output-handling injection into a downstream interpreter
No auto-executionNever feed raw model output directly into a shell, eval, or queryRemote code execution via the model
Grounding + citationRequire the model to cite sources for factual claimsMisinformation (LLM09) presented as authoritative

Guardrail placement

Guardrails belong on both sides of the model — an input guardrail screens what enters, an output guardrail screens what leaves. An output-only guardrail misses injection that has already changed the model's plan; an input-only guardrail misses sensitive disclosure in the response. Layer both.

MITRE ATLAS — Defensive Correlation

MITRE ATLAS catalogs adversarial techniques against AI systems. The skills cite ATLAS technique IDs to correlate a defense with the technique it counters — never to provide an attack recipe. Representative defensive correlations:

ATLAS techniqueTechnique nameDefensive control that counters it
AML.T0051LLM Prompt InjectionInstruction-hierarchy enforcement, content isolation, input/output screening
AML.T0020Poison Training DataData lineage, canary artifacts, provenance verification
AML.T0054LLM JailbreakOutput filtering, refusal-policy enforcement, response gating
AML.T0057LLM Data LeakageOutput redaction, minimize context secrets, per-tenant isolation

For each technique, the skill states how to detect and defend, not how to execute. Treating an ATLAS technique ID as an attack recipe is the anti-pattern this skill explicitly forbids.

NIST AI RMF — Governance Mapping

The NIST AI Risk Management Framework (AI RMF 1.0) organizes AI risk into four functions. Map LLM-security controls onto them for defensive governance:

FunctionDefensive activity
GOVERNEstablish AI-security policy, accountability, and incident-response ownership for LLM systems
MAPInventory LLM components, data sources, tool permissions, and trust boundaries; identify the threat model
MEASURETest for prompt-injection resistance, output-validation coverage, and guardrail effectiveness; track findings
MANAGEPrioritize and remediate identified risks; monitor production behavior; maintain the response plan

The four functions give a defensive governance scaffold; the OWASP LLM Top 10 and MITRE ATLAS supply the specific risks to map, measure, and manage.

Cross-References

  • moai-ref-owasp-checklist — web-application OWASP Top 10, authentication patterns, input validation, HTTP security headers (the dev-time application security surface; this skill is the LLM-specific surface).
  • moai-ref-api-patterns — REST/GraphQL API design, error handling, rate limiting (the API-design surface that an LLM-backed service exposes).
  • moai-ref-supply-chain — dependency and artifact provenance, signing, SBOMs (the broader supply-chain surface that LLM03/LLM04 model and data provenance draws on).

Defensive Severity Levels

LevelLabelActionExample
P0CRITICALBlock releaseRaw model output executed in a shell; no output validation on an agent with destructive tools
P1HIGHFix before mergeNo instruction-hierarchy enforcement on a system handling untrusted documents
P2MEDIUMFix within iterationTool-call loop has no upper bound; missing input screening
P3LOWTrack in backlogSystem prompt slightly over-discloses internal structure (no secret leaked)

Common Rationalizations

RationalizationReality
"The model is smart enough to ignore injected instructions"Models do not reliably separate data from instructions. A capable model can still be steered by injected text; defense-in-depth, not model capability, is the control.
"We only read internal documents, so RAG content is trusted"Internal documents can be edited by a compromised account or an upstream feed. Indirect injection does not require an external attacker — treat all retrieved content as untrusted.
"Output validation slows the response, users will not notice the risk"Unvalidated output is how model responses become shell commands and XSS. Validation is the boundary between a chat reply and remote code execution.
"The agent needs broad permissions to be useful"Excessive agency is an OWASP LLM Top 10 risk. Scope tools to the task; a capability the agent does not hold cannot be abused via injection.
"We put guardrails on the output, that is enough"An output-only guardrail misses injection that already changed the model's plan and tool calls. Guardrails belong on both input and output.
"Prompt injection is a research problem, not a production one"Indirect prompt injection is exploited in production RAG and agentic systems today. It is a current operational risk, not a theoretical one.

Untrusted-by-default: every text channel reaching the model — user input, retrieved documents, tool results — is untrusted until screened. The model is not a trust boundary; your validation layer is.

Red Flags

  • Model output fed directly into a shell, eval, query, or innerHTML without schema validation or encoding
  • Retrieved RAG content concatenated directly after a system instruction with no isolation or provenance tagging
  • An agent holds destructive or high-privilege tools with no human-in-the-loop gate on high-impact actions
  • Tool results re-enter the prompt without being re-screened as untrusted input
  • Secrets, API keys, or credentials embedded in the system prompt (assume the prompt is recoverable)
  • No upper bound on tool-call loops or token consumption per request
  • Guardrails present on only one side (input-only or output-only) of the model

Verification

  • Every text channel reaching the model is classified as trusted or untrusted, and untrusted channels are screened
  • System instructions use instruction-hierarchy enforcement against override by downstream text
  • Retrieved/RAG content is isolated and provenance-tagged, not concatenated after instructions
  • Model output is schema-validated and context-encoded before any downstream use; nothing auto-executes raw output
  • Agent tools follow least-privilege scoping; high-impact actions have a human-in-the-loop gate
  • Tool results are re-validated as untrusted input before re-prompting; tool-call loops are bounded
  • The design is mapped against the OWASP LLM Top 10 (show which items were evaluated) and governed under the NIST AI RMF functions
  • No secrets reside in the system prompt; output filtering screens for sensitive disclosure

Câu hỏi thường gặp

Kỹ năng AI Moai Ref Llm Security làm được gì?

AI/LLM defensive security reference: prompt-injection defense, OWASP LLM Top 10 defensive mapping, MCP and agentic tool-call hardening, training-data poisoning detection, model-output validation and guardrails, MITRE ATLAS defensive correlation, and NIST AI RMF governance. Agent-extending skill that amplifies backend, security, and AI-application engineering with production-grade defensive patterns for LLM-backed systems. NOT for: offensive techniques (jailbreak authoring, attack-payload crafting, red-team exploitation), model training or fine-tuning methodology, prompt optimization for cap...

Vì sao nên dùng Moai Ref Llm Security trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Moai Ref Llm Security là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Moai Ref Llm Security trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/modu-ai/moai-adk/tree/main/.claude/skills/moai-ref-llm-security. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Moai Ref Llm Security?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Moai Ref Llm Security với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Moai Ref Llm Security với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Moai Ref Llm Security có miễn phí không?

Có. Kỹ năng này được modu-ai phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇