Security Architecture
Design controls that protect data, tools, models, and users.
Security Architecture
AI applications may process customer records, financial information, medical reports, business documents, credentials, proprietary data, and valuable model artifacts. Protecting these assets—and the people affected by AI decisions—is a core responsibility of an AI Solution Architect.
Security is not a feature added after development. It is a continuous design and operating discipline that begins with requirements and threat modeling, continues through implementation and testing, and remains active during deployment, monitoring, incident response, and retirement.
What Is Security Architecture?
Security architecture is the overall plan for reducing unacceptable risk across an AI solution. It defines trust boundaries, protected assets, likely threats, required controls, responsible owners, evidence, and recovery procedures.
- Verify human and service identities
- Authorize only necessary actions and data access
- Protect information in transit, at rest, and during processing
- Secure applications, APIs, models, tools, pipelines, and infrastructure
- Detect suspicious behavior and preserve useful audit evidence
- Limit damage and recover safely from security incidents
- Meet applicable contractual, legal, privacy, and business requirements
The goal is not to claim that risk is zero. It is to identify risk, reduce it with proportionate controls, make residual risk visible, and prepare the organization to respond when controls fail.
Security Objectives
| Objective | Meaning in an AI Solution |
|---|---|
| Confidentiality | Only authorized identities can access sensitive data, prompts, models, and secrets |
| Integrity | Data, code, prompts, models, configurations, and results are protected from unauthorized change |
| Availability | Authorized users can access required services despite failures or attacks |
| Privacy | Personal data is used lawfully, minimally, transparently, and for approved purposes |
| Accountability | Important actions and decisions have owners and auditable evidence |
| Safety | AI behavior and tool actions remain within approved limits and fail safely |
Defense in Depth
No single control is sufficient. Defense in depth uses independent layers so that one mistake or bypass does not immediately expose the complete system.
Identity -> Authorization -> Network boundary -> API validation
-> Data and model controls -> Tool sandbox/allowlist -> Output controls
-> Safe logs and monitoring -> Human approval -> Incident responseCore Security Components
Authentication
Authentication verifies a human or service identity. Common approaches include organizational single sign-on, multi-factor authentication, OAuth or OpenID Connect, workload identities, client certificates, and short-lived tokens. API keys are identifiers or secrets, not a complete user identity system.
Authorization
Authorization determines what an authenticated identity may do. Apply least privilege using role-, attribute-, or policy-based rules, and enforce permissions at the service and data layers. A user's access restrictions must also apply to retrieved documents and AI tool actions.
Encryption and Key Management
Use approved encryption for network communication and stored sensitive data. Manage keys separately from the protected data, restrict key usage, rotate where required, and record access. Passwords should be salted and hashed with a suitable password-hashing algorithm rather than reversibly encrypted.
Secrets Management
API credentials, database passwords, signing keys, and certificates belong in a managed secret store—not source code, prompts, container images, notebooks, or logs. Prefer short-lived workload credentials over long-lived shared secrets.
Secure APIs
Authenticate and authorize requests, validate schemas and sizes, limit rates and resource consumption, use timeouts, avoid verbose error leakage, enforce tenant boundaries, and return only required information. Treat all external input as untrusted.
Network and Infrastructure Security
Segment environments and sensitive services, minimize public endpoints, control inbound and outbound traffic, harden hosts and containers, patch supported software, scan images, and restrict administrative access. Default-deny rules reduce accidental exposure.
Logging, Detection, and Response
Collect security-relevant events such as authentication failures, permission changes, sensitive access, unusual model usage, tool actions, configuration changes, and denied requests. Protect logs from tampering and exclude unnecessary secrets or personal data.
AI-Specific Assets and Threats
| Area | Example Threat | Design Response |
|---|---|---|
| Prompts and context | Prompt injection changes intended behavior | Separate instructions from untrusted content and enforce policy outside the model |
| Retrieval | Private documents leak across users or tenants | Apply authorization filters before retrieval and verify sources |
| Model output | Unsafe, sensitive, or fabricated content is returned | Validate output, apply policy controls, cite sources, and escalate high-risk cases |
| Tools and agents | Model triggers an unauthorized or destructive action | Use narrow allowlists, scoped credentials, limits, simulation, and human approval |
| Training data | Poisoned or unauthorized data changes behavior | Track provenance, permissions, quality checks, and dataset versions |
| Model artifacts | Tampered or malicious model is deployed | Use trusted sources, signatures, scanning, registry controls, and approvals |
| Model endpoint | Extraction, denial of service, or abusive automation | Rate limits, monitoring, access controls, quotas, and anomaly detection |
| Feedback loops | Attacker manipulates data used for improvement | Validate, moderate, isolate, and review feedback before reuse |
Prompt Injection and Tool Safety
Instructions contained in user input, websites, emails, or retrieved documents can attempt to override system behavior. Because model output is probabilistic, a prompt alone is not a security boundary.
- Label and separate trusted instructions from untrusted content.
- Enforce authorization and business rules in deterministic application code.
- Give tools narrowly scoped identities and explicit parameter schemas.
- Allowlist destinations and actions; deny dangerous capabilities by default.
- Set iteration, time, token, financial, and resource limits.
- Require human approval for consequential, external, or irreversible actions.
- Validate tool inputs and outputs and log every attempted action safely.
Data Security and Privacy Lifecycle
Classify -> Minimize -> Obtain permission -> Collect securely -> Control access
-> Process for approved purpose -> Retain only as needed -> Delete and verify- Classify sensitive, personal, regulated, confidential, and public data.
- Collect only what the approved use case requires.
- Redact or tokenize sensitive fields before model use when possible.
- Preserve user, tenant, document, and row-level permissions during retrieval.
- Define provider usage, retention, residency, deletion, and training policies.
- Prevent sensitive content from entering prompts, caches, analytics, logs, or test datasets unnecessarily.
- Support required access, correction, export, retention, and deletion processes.
Security Architecture Process
1. Identify Assets and Requirements
List sensitive data, models, prompts, intellectual property, credentials, tools, infrastructure, users, and essential business processes. Record applicable privacy, compliance, contractual, and availability requirements.
2. Map Data Flows and Trust Boundaries
Show where data enters, changes, crosses networks or organizations, reaches model providers, is stored, appears in logs, and is deleted. Mark privileged components and external dependencies.
3. Threat-Model the Solution
Consider likely actors, attack paths, misuse, failure impact, and existing controls across identities, APIs, data, models, supply chain, tools, tenants, infrastructure, and operations. Prioritize using likelihood and impact.
4. Select and Assign Controls
Choose preventive, detective, and recovery controls that reduce priority risks. Assign an owner, implementation location, validation method, and expected evidence to each important control.
5. Test and Review
Perform code and configuration review, dependency and secret scanning, access testing, adversarial AI evaluation, abuse-case testing, penetration testing where appropriate, and recovery exercises before release.
6. Monitor and Improve
Track control health, suspicious behavior, vulnerabilities, provider changes, model updates, incidents, and lessons learned. Security assumptions must be revisited as threats and the architecture evolve.
Secure API-Key Example
This simplified example reads an expected key from the environment and uses a constant-time comparison. Production APIs should normally use a managed identity system, secret store, rotation, rate limiting, audit logging, and scoped permissions.
import os
import secrets
EXPECTED_API_KEY = os.environ["SERVICE_API_KEY"]
def is_authorized(provided_key: str | None) -> bool:
if not provided_key:
return False
return secrets.compare_digest(provided_key, EXPECTED_API_KEY)
request_key = os.getenv("REQUEST_API_KEY")
print("Access granted" if is_authorized(request_key) else "Access denied")A Simple Analogy
A bank protects valuable assets with multiple layers: identity checks, role-specific access, vaults, cameras, alarms, transaction limits, separation of duties, audit trails, and response procedures. Customers, tellers, managers, and security teams receive different permissions.
An AI system requires the same layered thinking. Locks alone are insufficient; identities, data movement, actions, monitoring, recovery, and accountability must work together.
Incident Readiness
Assume that credentials may leak, dependencies may be compromised, unsafe output may reach users, or a tool may attempt an improper action. Prepare response procedures before an incident occurs.
- Define alert ownership and severity levels.
- Preserve useful evidence without spreading sensitive data.
- Support rapid credential revocation and key rotation.
- Provide model, tool, integration, and feature kill switches.
- Contain affected tenants, services, models, or data paths.
- Communicate through approved legal, privacy, support, and leadership processes.
- Recover from known-good versions and verify controls afterward.
- Run blameless reviews and track corrective actions to completion.
Common Challenges
- Large volumes of sensitive and unstructured information
- Complex permissions across tenants, documents, tools, and services
- Long-lived credentials and excessive privileges
- Misconfigured cloud services, networks, storage, or logging
- Rapid model, dependency, and provider changes
- Prompt injection, unsafe output, data poisoning, and agent misuse
- Insider threats and compromised service identities
- Balancing usability, delivery speed, observability, privacy, and risk
Best Practices
- Build security and privacy requirements into the project from the beginning.
- Threat-model assets, data flows, trust boundaries, abuse cases, and AI-specific risks.
- Use strong authentication, short-lived identities, least privilege, and separation of duties.
- Encrypt sensitive data and manage secrets and keys outside code and prompts.
- Validate input and output, enforce size and rate limits, and fail safely.
- Treat retrieved content and model output as untrusted; enforce policy outside the model.
- Restrict tools with allowlists, scoped credentials, budgets, and human approval.
- Secure the software, data, and model supply chain with provenance and version controls.
- Patch supported systems, scan continuously, and test controls and recovery procedures.
- Collect useful audit evidence without exposing secrets or unnecessary personal data.
- Document residual risk, owners, exceptions, incident procedures, and review dates.