AI Security: Engineering Defense-in-Depth for Known Risks
This article outlines a practical, engineering-driven approach to AI security, shifting the focus from merely identifying known risks to implementing enforceable controls across the entire AI system lifecycle. It details a defense-in-depth framework covering threat modeling, pre-release gates, supply chain governance, runtime protection, monitoring and audit, and organizational accountability, providing actionable strategies for building secure and resilient AI applications.
As AI models evolve and release cycles accelerate, the primary security challenge is often not the discovery of unknown risks, but the failure to govern risks that are already well understood. Common issues such as unclear data provenance, insufficient evaluation coverage, excessive tool permissions, unconstrained outputs, lack of audit trails, and missing rollback paths have long been topics of industry discussion. The true measure of a system’s security posture is not whether these risks are recognized, but whether they are translated into executable, verifiable, and auditable controls that are embedded throughout the entire lifecycle—from development to runtime.
Therefore, AI security should not be viewed as a single point-detection mechanism or a one-time pre-launch review. Instead, it must be built as a defense-in-depth system featuring pre-release gates, traceable supply chains, runtime isolation, robust monitoring, incident rollback capabilities, and clear organizational accountability. This article details this approach across key domains: threat modeling, release gates, supply chain governance, runtime protection, monitoring and audit, engineering implementation, and organizational processes.
1. Start with a Threat Model: Decompose “Awareness” into Controls
The first step in AI security governance is to clearly define the assets requiring protection and the potential attack surface. A comprehensive threat model should cover at least five layers:
- Data Layer: Focuses on sensitive information, potential data poisoning, and authorization issues within training and retrieval data.
- Model Layer: Addresses capability boundaries, alignment objectives, and evaluation biases.
- Application Layer: Concerns prompt injection, unauthorized outputs, and business logic bypasses.
- Supply Chain Layer: Focuses on model provenance, dependency components, and version drift.
- Runtime Layer: Pertains to tool invocation, secret management, resource abuse, and anomalous behavior.
The deliverable of threat modeling is not just a document, but a set of actionable controls. Examples include: “High-risk tasks require human approval,” “External inputs must pass through policy filters,” “Tool calls operate with least privilege,” “Model and data versions must be traceable,” and “Critical operation logs must be retained and trigger alerts.” Each control item should have a designated owner, a verification method, and explicit blocking conditions. Only by decomposing “known risks” into executable rules can security evolve from a slogan into a true engineering capability.
2. Pre-Release Gates: Red Teaming, Evaluation, and Capability Boundaries
Before a next-generation model reaches a usable state, a multi-layered release gate should be established.
- Provenance and License Validation: Verify the origin, license, and version of the model, datasets, and dependent components.
- Security Evaluation: Run test suites covering adversarial inputs, prompt injection, sensitive data leakage, unauthorized tool calls, and harmful outputs.
- Capability Boundary Check: Explicitly define the scope of tasks the model is permitted to handle, adding extra restrictions for high-risk domains.
- Canary Criteria: Set parameters for canary release, including deployment percentage, metrics to observe, and rollback thresholds.
The critical aspect of these gates is that they must be enforceable. If evaluation reports are only used as reference material and do not influence the release decision, the security review process becomes a formality. From an engineering perspective, gate policies should be codified into executable rules, with CI/CD pipelines automatically determining whether to block a release, proceed with a canary rollout, or trigger manual review. For example:
def release_gate(model, dataset, policy):report = {}report["来源与许可"] = verify_provenance(model, dataset)report["安全评测"] = run_redteam_suite(model, policy.risk_profile)report["能力边界"] = check_capability_limits(model, policy.allowed_tasks)report["依赖检查"] = scan_dependencies(model.runtime)if any(item.blocking for item in report.values()):return "拒绝发布", reportif any(item.requires_review for item in report.values()):return "人工复核", reportreturn "灰度发布", report
This pseudocode illustrates a core principle: risks must be mappable to blocking, review, or canary conditions, and a complete report must be generated for audit purposes.
3. Supply Chain Governance: Traceability for Models, Data, and Dependencies
The AI supply chain is more complex than traditional software because model weights, training data, retrieval data, plugins, and runtime dependencies can all influence final behavior. Key governance practices include:
- Establishing comprehensive inventories of models and datasets, recording their versions, sources, license scopes, and change history.
- Implementing integrity checks and signature verification for critical assets.
- Scanning dependencies for known vulnerabilities and license compliance issues.
- Enforcing a freeze and mandatory review process for high-risk changes.
Governance must also mitigate the hidden risks of “version drift.” Changes to the model, retrieval database, tool permissions, or configuration can all alter system behavior. Therefore, the model version, policy version, data index version, and configuration version should be tracked together within a single release record. This unified logging enables precise localization of issues—whether caused by model changes, data updates, or policy shifts—and supports rapid rollback.
4. Runtime Protection: Least Privilege and Tool Call Isolation
The runtime phase is where risks are most likely to manifest. On the input side, systems should perform content classification, sensitive information detection, and policy filtering. On the output side, they should conduct compliance checks, redact sensitive data, and block high-risk content. For systems with tool-calling capabilities, the principle of least privilege is non-negotiable: grant only the minimum permissions required to complete a task, require additional approval or human review for write operations, external requests, and financial transactions, and implement limits on call frequency, resource consumption, and timeouts.
Tool execution environments should also be isolated. High-risk operations should run within a sandbox. Secrets and credentials must not be directly exposed to the model, and all data returned from external sources should be re-validated. For multi-step tasks, log the input, decision, and result of every step to prevent gradual privilege escalation over a long chain of operations. The goal of runtime protection is not to eliminate all errors, but to contain them within a manageable scope and ensure they can be detected, blocked, and recovered from.
5. Monitoring, Audit, and Incident Response
A security framework must be observable. This requires structured logging, distributed tracing, and audit records that capture model versions, policy hits, tool calls, permission changes, anomalous outputs, and human review decisions. Useful alerting metrics include sensitive information hit rate, unauthorized call attempts, abnormal input ratios, output interception rate, tool failure rate, and unexpected cost spikes. Logs should be tamper-proof and retained for a specified period, with all critical operations traceable to specific versions and accountable roles.
Incident response must be designed in advance:
- High-risk output: Can the model or its tool permissions be isolated quickly?
- Data breach: Can we rotate secrets and scope the impact?
- Supply chain anomaly: Can we roll back to a known-good version?
Regular drills should be conducted to test rollback procedures, notification mechanisms, and role assignments. An incident response plan that has never been tested often fails during a real crisis.
6. Engineering Implementation: Policy-as-Code and Continuous Improvement
Embedding security controls into the development workflow is key to reducing governance overhead. Policies should be managed as code, subject to version control and peer review. Release pipelines should automatically execute security gates, and canary phases should monitor security metrics. During runtime, continuous collection of false positives and negatives should inform and refine the policies. Security KPIs should be reviewed alongside business metrics, ensuring the security team is not solely responsible for the entire framework.
At the organizational level, clear boundaries must be defined for the model provider, application developer, security team, and business units: who is responsible for data authorization, who maintains the evaluation sets, who owns runtime policies, and who leads incident response. A closed loop is formed through regular reviews, red team retrospectives, and incident drills, allowing security capabilities to evolve in lockstep with model capabilities.
In conclusion, the focus of AI security is not on pursuing a single “ultimate detection solution.” It is about acknowledging that risks are persistent and systematically translating known risks into executable controls. Pre-release gates, supply chain traceability, least-privilege runtime, monitoring and audit, and incident rollback together constitute a robust defense-in-depth framework. Only by making security an integral part of the engineering process can we harness the power of advanced models without accepting unacceptable systemic risk.
