Volume 13 · Chapter 7 — AI-Native Software Architecture & Agentic Engineering Handbook
AI Security and Governance
7.1 Introduction
AI systems introduce novel security threats and governance obligations on top of the usual application concerns. Because an LLM is non-deterministic, manipulable through language, and often connected to data and tools, the attack surface is different - and in regulated domains, responsible-AI governance is a requirement, not a nicety. This chapter covers the AI-specific threats, their defenses, and the governance that makes enterprise AI trustworthy and compliant.
7.2 The AI Threat Landscape
The recognized LLM-specific risks (as catalogued by the OWASP Top 10 for LLM applications) include prompt injection, sensitive-data disclosure, insecure output handling, training-data poisoning, excessive agency (over-privileged agents), and supply-chain risks in models and plugins. The unifying theme is that the model cannot be trusted to enforce security itself - the controls must live in the surrounding system.
7.3 Prompt Injection - the Signature Threat
Prompt injection smuggles malicious instructions into the model’s input - directly (“ignore your instructions…”) or indirectly through content the app feeds the model (a poisoned document or web page). It is the signature LLM vulnerability because the model cannot reliably separate trusted instructions from untrusted data. Defenses are layered: never trust model output as authority, enforce access control and permissions in code, constrain and validate agent tool use, separate and delimit untrusted data, validate outputs, and treat retrieved content as untrusted.
7.4 Data Privacy and Leakage
AI systems can leak data two ways: exposing data a user should not see (solved by enforcing authorization at retrieval, not the prompt) and leaking sensitive data to the model provider or into logs and training (solved by data classification, PII handling, using enterprise-protected models that do not train on your data, and careful logging). Data classification and access control are the foundation.
7.5 Responsible AI Principles
Governance rests on responsible-AI principles: fairness (avoiding harmful bias), transparency (explainability and citations), privacy, human oversight, and accountability. These are not abstract - in a bank, an AI that influences credit or fraud decisions must be fair, explainable, auditable, and subject to human review, or it fails both ethics and regulation.
flowchart TB
Input["User input + retrieved content\n(UNTRUSTED)"] --> Guard["Guardrails\n(validation, injection defense)"]
Guard --> Model["LLM"]
Model --> OutGuard["Output validation + filtering"]
OutGuard --> Action{"Consequential?"}
Action -- "Yes" --> Human["Human approval"]
Action -- "No" --> Done["Proceed"]
Authz["Access control (in code, at data)"] -.-> Model
Audit["Audit log of all interactions"] -.-> Model 7.6 AI Governance and Compliance
Enterprise AI governance includes model approval and risk assessment before deployment, version management, ongoing performance and safety evaluation, identity-based access control to models and data, comprehensive audit logging, and alignment with regulations (data protection, and increasingly AI-specific regulation). Governance treats AI as a managed capability with accountability, not an ungoverned experiment.
How do you secure an enterprise AI application?
I secure it by recognizing that the model itself cannot be trusted to enforce security - it is non- deterministic and manipulable through language - so I place the real controls in the surrounding system, addressing the AI-specific threats layered on top of normal application security. Against prompt injection, the signature LLM threat, I never treat model output as authoritative for security decisions, I enforce access control and permissions in code rather than by instructing the model, I constrain and validate any tool/function the model can call (for agents, tools are the boundary where injection turns into real damage), I clearly separate and delimit untrusted data from instructions, and I treat all user input and retrieved content as untrusted. Against data leakage I enforce authorization at retrieval so the model only ever receives data the user is entitled to (the model cannot leak what it never got), and I protect sensitive data from leaking to providers or logs by classifying data, handling PII carefully, using enterprise-protected models that do not train on our data, and logging carefully. I add input and output guardrails - validation, content filtering, and checks that answers are grounded - and I keep a human in the loop for consequential actions. For agents I apply least-privilege tools and prevent excessive agency. Everything is auditable: I log AI interactions comprehensively for detection, forensics, and compliance. And I govern the models themselves - approval and risk assessment before deployment, version management, and ongoing safety/quality evaluation. Underpinning it all is responsible- AI practice: fairness, transparency (citations/explainability), privacy, oversight, and accountability, which in a regulated domain are obligations, not options. The unifying principle I’d stress is that AI security is achieved by engineering controls around an untrusted, manipulable model - access control at the data layer, injection defenses, tool constraints, output validation, human oversight, and audit - rather than by trusting the model to behave, because it can always be wrong or manipulated.
What is "excessive agency" and how do you prevent it?
Excessive agency is the risk that an AI system - typically an agent - is given too much capability, autonomy, or permission, so that when it behaves unexpectedly (through hallucination, a bad plan, or prompt-injection manipulation) it can take harmful, possibly irreversible actions that it should never have been able to take. It is one of the recognized LLM-application risks, and it grows precisely as we give models more tools and more autonomy. Examples: an agent with a broadly-scoped database credential that lets it delete records when it only needed to read; a tool that can send money or emails without any approval; or an agent trusted to act on its own unverified output. I prevent it with least privilege and bounded autonomy at every level. Tools are minimal and narrowly scoped - the agent gets only the specific functions it needs, and each tool has only the permissions required for its legitimate purpose (read-only where possible, scoped to the user’s own data). Each tool enforces its own authorization in code against the actual user’s identity, so the agent cannot exceed what the user could do. Consequential or irreversible actions require human approval through a human-in-the-loop checkpoint, using risk-based automation so only genuinely low-risk actions run unattended. I bound the agent’s operation (step limits, timeouts, cost caps) so it cannot run away. And I never let the model’s unverified output directly drive a sensitive action without validation. Essentially, I match the agent’s power to act with strict limits on what it can do, verification of what it proposes, and human oversight for high stakes - so that even when the agent is wrong or manipulated, the blast radius is contained. Preventing excessive agency is about designing the agent so its worst possible action is acceptable, which is the mindset of assuming it will sometimes misbehave.
What does responsible-AI governance look like in a regulated enterprise?
In a regulated enterprise, responsible-AI governance is a formal, enforced practice that treats AI as a managed capability with accountability, aligned to both ethics and regulation, rather than an ungoverned experiment. It rests on the responsible-AI principles - fairness (avoiding harmful or discriminatory bias, which matters enormously where AI influences decisions like credit or fraud), transparency and explainability (being able to show why the system produced an output, supported by citations and logging), privacy (protecting personal and sensitive data), human oversight (a human accountable for and able to review consequential decisions), and accountability (clear ownership of AI outcomes). Operationally this becomes concrete controls: a model approval and risk-assessment process before any model or AI feature goes to production, evaluating its risks, biases, and failure modes; version management of models and prompts as controlled assets; ongoing evaluation and monitoring of quality, safety, bias, and hallucination in production, not just at launch; identity-based, least-privilege access control to models and data; comprehensive audit logging of AI interactions so decisions can be traced and reviewed by auditors and regulators; and human-in-the-loop review for high-stakes automated decisions. It also requires alignment with data-protection law and increasingly with AI-specific regulation, and often an AI governance body or review process that assesses new AI use cases. For a bank specifically, an AI that touches lending or fraud must be demonstrably fair, explainable, auditable, and human-supervised, or it fails compliance regardless of its accuracy. The key point I’d make is that governance is what makes enterprise AI trustworthy and compliant - it provides the oversight, evaluation, access control, auditability, and accountability that turn a powerful but risky technology into one an organization can responsibly deploy in a regulated context, and it must be designed in from the start, not retrofitted.
7.7 Banking AI Security Scenario
A bank’s AI platform is secured on the assumption that the model is untrusted and manipulable. User input and retrieved documents are treated as untrusted to resist prompt injection; authorization is enforced at data retrieval so the model only sees permitted data; agent tools are least-privilege and enforce their own authorization; and consequential actions require human approval. Sensitive data is classified and protected, an enterprise-protected model that does not train on the bank’s data is used, and every AI interaction is logged for audit. Governance wraps it all: model approval and risk assessment, version management, ongoing bias and safety evaluation, and human review of high-stakes decisions - satisfying both the bank’s security bar and its regulatory obligations.
Chapter Revision Notes
- AI adds novel threats (OWASP LLM Top 10) - the model cannot enforce its own security.
- Prompt injection is the signature threat; defend in layers and treat all input/retrieved content as untrusted.
- Prevent leakage by enforcing authorization at retrieval and protecting data from providers/logs.
- Prevent excessive agency with least-privilege tools, code-enforced authorization, and human approval.
- Govern AI: model approval, versioning, evaluation, access control, audit, and responsible-AI principles.