Security teams should start with visibility into every component in the GenAI stack, including models, vector databases, prompts, third-party libraries, and tools. Then they should apply scoped access, strong input validation, sandboxing for script execution, and human approval before risky actions. The core goal is to reduce prompt injection, data leakage, and unintended tool use before users can abuse the system.
Why RAG Security Depends on Retrieval, Not Just the Model
RAG changes the security problem because the model is only one part of the trust boundary. The safer pattern is to treat retrieval, indexing, document permissions, and vector storage as first-class security components, especially when the system may surface content a user was never meant to see. NHI Management Group’s Permission-Aware RAG Guide is a useful starting point for that control model.
When RAG is permission-blind, the application can turn ordinary search into oversharing at scale. The retrieval layer must respect the same access rules that govern the source system, because embeddings and indexes can expose information even when the original application never intended to return it directly. That is why RAG hardening is partly an authorization problem, not only a prompt or model problem.
Why Plugins Expand the Attack Surface
Plugins and tools extend the application’s authority beyond text generation. They can read data, call APIs, trigger workflows, and move information between systems, which means the security posture depends on what each tool can do and how tightly it is scoped. A broader plugin ecosystem needs the same discipline as any third-party extension architecture, including sandboxing, scoped tokens, and explicit approval for higher-risk actions. NHI Management Group’s AI Agent Tool and Plugin Security Guide and Plugin and Extension Architecture Security Guide for SaaS Builders both map cleanly to this problem.
The practical risk is not only malicious code. A trusted plugin can still become unsafe if it receives overbroad credentials, weakly validated arguments, or output that is fed back into downstream actions without mediation. In GenAI systems, a plugin is often the difference between an embarrassing answer and a material business action, so tool permissions must be treated as production authority, not convenience plumbing.
How to Reduce Prompt Injection, Leakage, and Unsafe Actions
The most effective control pattern is layered. Start with visibility over what the application can reach, then narrow the data it can retrieve, then constrain the actions it can take, and finally add human approval where the action has external effect. For RAG, that usually means permission-aware retrieval, source trust checks, and filtering before content enters the prompt. For plugins, it means scoped access, strict input validation, and execution isolation for any code or script path. NHI Management Group’s RAG Security Guide and GenAI Data Security Risks and Mitigations Guide are useful references for this layered approach.
For teams building AI assistants with tools, the hard question is not whether the model can answer, but whether the system can safely refuse, delay, or narrow the next step. That becomes especially important when a prompt injection attempt is designed to make the model fetch hidden documents, call an internal API, or pass secrets into a tool chain. The safer design assumes prompts are untrusted input and that action boundaries need stronger controls than text boundaries.
Risk and Threat Considerations
RAG and plugins create a compound exposure because the attacker can aim at retrieval, prompting, or tool execution depending on which control is weakest. If permissions are loose, the system can disclose data it should not surface. If tool scopes are broad, the system can misuse legitimate access to perform actions the user never intended. The security issue is therefore not just model manipulation, but the amplification of a small injection into data leakage or unsafe operational change.
Failure mechanism: An attacker supplies crafted content, or manipulates retrieved content, so the model ingests untrusted instructions or over-shares sensitive material, then uses plugin authority to execute an action with excessive scope.
Impact: The application may leak confidential data, invoke the wrong tool, or carry out an unintended workflow step with real business consequences.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 and NIST AI 600-1 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-6 — Least Privilege | RAG and plugin scopes should be limited to the minimum authority needed. |
| IA-5 — Authenticator Management | Plugins and RAG components often depend on tokens, keys and other secrets. | |
| SC-7 — Boundary Protection | RAG pipelines and plugin calls cross trust boundaries that need filtering and isolation. | |
| Recommendation — Restrict retrieval, tool and API access to the least privilege required. Manage, rotate and revoke credentials used by RAG and plugin services. Segment model, retrieval and tool paths at enforced trust boundaries. | ||
| NIST AI 600-1 | Generative AI Risk Management Profile | This profile directly addresses GenAI governance, testing and incident handling. |
| Recommendation — Apply GenAI risk controls for testing, provenance and incident response. | ||
| OWASP API Security Top 10 | API5 — Broken Function Level Authorization | Plugin and tool calls can expose privileged functions to weak authorization. |
| Recommendation — Enforce function-level authorization on every tool and plugin action. | ||
Practitioner Guidance
What to verify: Confirm that retrieval respects document-level permissions, that vector and index access is not broader than the source data, and that every plugin has a documented purpose and bounded scope. If a tool can reach production systems, treat it as a high-impact control point and require explicit approval for sensitive actions.
Decision rule: If the model can only answer by reaching across systems, decide first whether that cross-system reach is actually needed. If it is, constrain the tool path, validate inputs before execution, and keep a human in the loop for actions that change data, send messages, or trigger external workflows.
Practitioner takeaway: Secure GenAI by controlling the data it can see and the actions it can take, because the largest failures in RAG and plugin designs usually come from overbroad trust, not from the model alone.
Related resources from NHI Mgmt Group
- Retrieval-augmented Generation
- What is the difference between prompt engineering and retrieval augmented generation for identity security use cases?
- How should security teams use retrieval augmented generation to answer SDK and documentation questions accurately?
- How should security teams use retrieval-augmented generation to answer product and policy questions without exposing sensitive internal data?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org