A list of best ai security practices is only useful if it survives contact with a real production deployment. This guide collects the practices that experienced teams actually adopt, mapped against the canonical frameworks (OWASP LLM Top 10, NIST AI RMF, MITRE ATLAS) so you can defend each control during an audit. It is structured as a checklist by lifecycle phase rather than as a survey, so engineering and security leads can use it as a gap analysis against current state. Once you know which phases have gaps, the interactive AI-Sec toolchain builder recommends concrete tools to cover each lifecycle stage under your constraints.
Phase 1: Threat Modeling Before Implementation
| Practice | Why It Matters |
|---|---|
| Map every external input the model can see | Indirect prompt injection enters through retrieved docs, emails, web pages, MCP tool outputs |
| Classify each tool call by blast radius | ”Read calendar” is not the same risk as “send email”; controls scale to consequence |
| Identify trust boundaries in agent loops | Agents cross boundaries silently — list every one explicitly |
| Document assumed-untrusted vs assumed-trusted data | Most LLM incidents trace to a trust assumption that turned out wrong |
The single highest-leverage practice in this phase: write down which inputs are trusted and which are untrusted, and treat anything retrieved from the world as untrusted by default. The OWASP AI Exchange, which now hosts the AI Security and Privacy Guide, covers this framing in detail. You cannot threat-model an asset you cannot see, so pair this phase with continuous discovery: the AI security posture management tools inventory every model across your accounts, flag over-permissioned endpoints, and map what each one can reach.
Phase 2: Defense-in-Depth at the Boundary
| Practice | Tool Examples |
|---|---|
| Run a prompt-injection scanner on every input | Lakera Guard, Llama Prompt Guard 2, NeMo Guardrails |
| PII redaction on inputs and outputs | Nightfall AI, Microsoft Presidio, Bedrock Guardrails PII filters |
| Output validation for structured contracts | Pydantic schema enforcement, Guardrails AI |
| Rate limit per identity, not per IP | Standard API gateway pattern, scoped to user |
A guardrail at the boundary catches the high-volume, low-sophistication attacks that make up the majority of injection attempts in the wild. It will not stop a determined attacker on its own — that is the point of defense in depth. For benchmarked guardrail comparisons see our AI firewall and guardrail solutions comparison; offensive technique coverage is on aisec.blog.
Phase 3: Pre-Deployment Adversarial Testing
| Practice | Why |
|---|---|
| Run Garak or PyRIT in CI against every model change | Catches regressions where a fine-tune reopens previously-fixed jailbreaks |
| Maintain a private prompt-injection corpus | Public corpora train models that pass them; private corpora catch real risk |
| Score releases on attack success rate | Numeric gate is harder to argue with than “felt safe” |
| Red team the application, not just the model | Most exploitable bugs live in the wrapper, not the weights |
A practice often skipped: re-run the full adversarial suite after every prompt template change. Template edits are responsible for a large fraction of post-deployment regressions. See our coverage of open-source LLM security testing for tooling specifics. Testing a model’s behaviour is not the same as verifying the artifact you loaded: gate model ingestion on a serialization scan and keep a standards-formatted inventory of what you ship, both compared in the AI-SBOM and model bill-of-materials tools guide.
Phase 4: Identity, Authorization, and Secrets
| Practice | Pattern |
|---|---|
| No long-lived service accounts for agents | Workload identity + short-TTL tokens |
| Per-action authorization checks | Cerbos, OpenFGA, Auth0 FGA |
| Tools run with the minimum scope needed | One narrow API key per tool, not one broad key |
| Secrets never visible to the model | Secret broker injects credentials at tool-call time |
The principle: an injected prompt that captures the agent’s credentials should still not be able to do significant damage. If your current architecture would fail this test, fix identity before adding more guardrails.
Phase 5: Runtime Observability
| Practice | Tool Examples |
|---|---|
| Capture full traces of every agent run | Langfuse, Arize Phoenix, Helicone |
| Alert on anomalous tool-call patterns | Custom rules over trace store |
| Behavioral drift detection across model versions | WhyLabs, Phoenix evaluations |
| Sample and human-review production conversations | No tool replaces this |
Most teams underinvest here until an incident forces it. The cost of trace storage is small; the cost of being unable to answer “what did the agent do during the breach window” is enormous.
Phase 6: Incident Response Specific to AI
| Practice | Detail |
|---|---|
| Maintain a model rollback path | Point production to previous model + prompt template within minutes |
| Have a kill switch for tool use | Disable specific tools without taking the whole app down |
| Track AI incidents in a structured log | Helps detect repeat patterns; feeds the next threat model |
| Disclose responsibly when user data is affected | Standard breach disclosure applies; don’t treat AI incidents differently |
Public AI incidents are tracked by ai-alert.org; reviewing recent disclosures is a useful exercise for any team writing its own response playbook.
Phase 7: Governance and Compliance
| Practice | Framework Mapping |
|---|---|
| Document risk controls against NIST AI RMF | Required for federal procurement and increasingly for enterprise |
| Track EU AI Act applicability per use case | High-risk classifications drive substantial controls |
| Bias and fairness testing where applicable | Required by sector regulators in finance and HR |
| Vendor AI risk reviews | Treat third-party AI like any other third-party software |
Governance is not optional for organizations subject to regulator scrutiny. The frameworks are still maturing but the direction is set. For governance platform options see Holistic AI and similar platforms.
What to Skip
A few practices appear on most “best practices” lists but contribute little:
- Banning specific words at the prompt boundary. Trivially bypassed; high false-positive rate.
- Single-vendor “AI security platform” lock-in. The space moves too fast; modular stacks adapt; monolithic ones don’t.
- Static rule-only defenses. Static rules have a place in the stack; on their own they age poorly.
Update Cadence
This checklist is reviewed quarterly. The largest changes between versions tend to come from new attack classes (recent quarters: indirect injection via MCP tools, agent-loop drift, retrieval-side poisoning) rather than from new frameworks. The frameworks themselves update annually at most.
Related across the network
- How to Use Tor Browser Safely: A Practical Setup Guide — anonguide.com