Security for AI Apps implementation checklist
This checklist outlines the technical verification steps required to secure LLM-integrated applications against prompt injection, data leakage, and infrastructure vulnerabilities before moving to a production environment.
Prompt Injection Mitigation
0/5Implement Delimiter Separation
criticalEnclose user input within distinct delimiters (e.g., triple quotes or XML tags) in the prompt template to help the LLM distinguish between developer instructions and user-provided data.
Deploy an Injection Detection Layer
criticalIntegrate a dedicated security tool like Rebuff or a secondary 'judge' LLM to analyze incoming user prompts for known injection patterns before they reach the primary model.
Enforce Input Schema Validation
criticalUse Zod or Pydantic to strictly validate the structure, type, and length of user inputs to prevent unexpected payloads from being processed by the LLM.
Apply Least-Privilege System Instructions
recommendedAudit the system prompt to ensure it explicitly instructs the model to ignore any user commands that attempt to override its core security constraints or access internal tools.
Test Against Indirect Injection
criticalVerify that data fetched from third-party APIs or external websites is treated as untrusted user input and passed through the same sanitization pipeline as direct user prompts.
Data Privacy and PII Protection
0/5Implement Pre-Inference PII Scrubbing
criticalUse a library like Microsoft Presidio or LLM Guard to identify and redact Personally Identifiable Information (PII) from user prompts before they are sent to external LLM providers.
Disable Provider Data Training
criticalVerify in the LLM provider's settings (e.g., OpenAI Enterprise or Azure OpenAI) that user data is not utilized for model training or retained beyond the required retention period.
Audit Few-Shot Prompt Context
criticalScan the hardcoded examples in your prompt templates to ensure no production secrets, internal database schemas, or sensitive employee data are included as context.
Validate Data Localization Compliance
recommendedConfirm that the LLM provider's data center region aligns with your organization's residency requirements (e.g., GDPR data processing within the EU).
Encrypt Data in Transit and Rest
criticalEnsure all communication with LLM APIs occurs over TLS 1.3 and that any locally cached prompt history is encrypted using AES-256.
Output Guardrails and Moderation
0/5Enable Native Moderation APIs
criticalPipe all LLM generated content through a moderation endpoint (e.g., OpenAI Moderation API) to block responses containing hate speech, self-harm, or illegal content.
Verify Output Structural Integrity
recommendedUse Guardrails AI or NeMo Guardrails to validate that the LLM output conforms to the expected JSON schema or code format before it is parsed by the application.
Filter Sensitive Information Leakage
recommendedImplement regex-based scanners on the LLM output to detect and block the accidental disclosure of internal IP addresses, API keys, or proprietary internal terminology.
Set Token Response Limits
recommendedConfigure a strict 'max_tokens' parameter on all inference calls to prevent resource exhaustion and mitigate potential Denial of Wallet attacks via excessively long responses.
Sanitize Output for XSS
criticalApply standard HTML escaping to LLM-generated text before rendering it in a web UI to prevent the execution of malicious scripts injected via the model output.
Infrastructure and Secret Management
0/5Centralize API Key Storage
criticalMove LLM provider API keys from environment variables into a managed secret store like AWS Secrets Manager, HashiCorp Vault, or Azure Key Vault.
Implement User-Level Rate Limiting
criticalApply rate limits based on the authenticated user ID rather than IP address to prevent a single compromised account from draining your LLM API credits.
Rotate Production API Credentials
recommendedEstablish an automated rotation policy for all LLM service keys and verify that legacy keys are immediately revoked upon rotation.
Use IAM Roles for Cloud LLMs
criticalWhen using services like AWS Bedrock or Vertex AI, utilize IAM roles and service accounts instead of static access keys to follow the principle of least privilege.
Isolate AI Microservices
recommendedDeploy LLM-handling logic in an isolated network segment (VPC) with restricted egress to only the specific domains required by the LLM providers.
Monitoring and Incident Response
0/5Log Inference Metadata
criticalRecord prompt/response pairs, token usage, and latency in a secure, centralized logging system (e.g., Datadog, ELK) while ensuring PII is masked in the logs.
Alert on High Refusal Rates
recommendedConfigure monitoring alerts for when the LLM or moderation layer returns a high frequency of 'safety-related' refusals, which may indicate an active injection attempt.
Establish an Emergency Kill Switch
criticalImplement a feature flag or configuration toggle that can instantly disable LLM functionality across the application without requiring a full code redeploy.
Perform Red-Teaming Exercises
recommendedConduct a scheduled 'jailbreak' test where security engineers attempt to bypass current guardrails using techniques from the OWASP LLM Top 10.
Monitor Token Usage Anomalies
recommendedSet up automated alerts for token consumption spikes that exceed the 95th percentile of historical usage to detect automated abuse or recursive loop bugs.