Beyond the Model: Building Secure and Trustworthy AI

AI innovation is moving fast, but security cannot be an afterthought. Explore AI security risks, open-source tools and practical DevSecOps strategies for building secure and trustworthy AI solutions. Because the future of AI is not just about intelligence — it’s about trust.

Manish Soni

12/2/202613 min read

a computer chip with the letter a on top of it
a computer chip with the letter a on top of it

Generative AI is moving rapidly from experimentation into everyday enterprise workflows. Organizations are deploying large language models to draft content, answer questions, analyze documents, and support employees, while retrieval-augmented generation connects models to internal knowledge and agentic systems can use tools or take actions on a user’s behalf. These capabilities create meaningful opportunities, but they also make security an essential part of adoption. A system that can interpret requests, draw on external information, and act across business applications may expose sensitive data or produce harmful outcomes if its behavior is manipulated or its surrounding controls are weak.

Securing AI requires attention to risks that do not fit neatly within traditional application security practices. Conventional AppSec typically examines deterministic code paths, validates inputs, enforces authentication and authorization, and addresses established vulnerability classes such as SQL injection and cross-site scripting. AI systems, by contrast, generate probabilistic outputs and rely on models shaped by training data and model weights. They also blur the distinction between data and instructions: natural-language content may be interpreted as a command, even when it comes from an untrusted document or web page. This creates opportunities for prompt injection, unintended disclosure, and misuse that cannot always be resolved through familiar code-level checks alone.

The security boundary therefore extends beyond the application code. Teams need to assess the data used to train or ground models, protect model assets, constrain prompts, and secure retrieval pipelines that select and deliver external content. They must also govern the tools available to AI agents, limit permissions, monitor actions, and evaluate outputs before those outputs influence people or systems. Effective controls combine established security principles with measures designed for model behavior, changing context, and operational oversight. The goal is not to halt experimentation or prevent useful AI capabilities from reaching users. It is to help organizations adopt generative AI, language models, and autonomous systems with safeguards proportionate to their risks, preserving innovation while strengthening confidentiality, integrity, and trust.

Unsecured AI applications can create risks that extend well beyond inaccurate answers. A customer-facing support chatbot that exposes another customer’s order history can undermine confidence, trigger complaints, and damage a company’s reputation. Even when a disclosure is accidental, customers may view it as evidence that the organization cannot protect their information. An internal assistant can cause similar harm if it summarizes confidential human resources documents for employees who lack permission to view them.

Business and competitive risks also arise when sensitive information enters prompts or retrieval systems without adequate controls. Employees may share product plans, customer records, or source code with an AI tool, allowing proprietary data to be retained, exposed, or reused in unintended ways. A leak can weaken a company’s market position and create contractual or legal consequences. Retrieval-augmented generation (RAG) systems require particular care: weak access checks may let a user retrieve documents simply because they are indexed, even when that user is not authorized to see them.

Operationally, AI agents can turn a mistaken instruction into a real system change. An agent with broad privileges might alter production settings, delete records, or initiate workflows, while repeated or runaway actions can overload services and cause downstream outages. For example, a finance team’s invoice-processing agent might be manipulated by a malicious email into changing a supplier’s payment details. Human review, scoped permissions, and approval gates help limit the impact of such actions.

Financial exposure includes unexpectedly high token consumption, denial-of-wallet attacks that drive up usage charges, and the cost of investigating and containing incidents. Regulatory fines may follow when personal or protected data is mishandled. Security threats also include direct data exfiltration and compromised model artifacts, such as altered weights or software components that behave unpredictably. Together, these scenarios make AI security a practical business requirement: controls must address data access, model integrity, spending limits, monitoring, and recovery before systems are deployed at scale.

The OWASP Top 10 for Large Language Model Applications provides a useful framework for connecting AI threats with practical controls. Prompt injection, including direct attacks and jailbreaks, occurs when crafted input persuades a model to override its system instructions or bypass safeguards. Indirect injection embeds hostile directions in retrieved documents, emails, or web pages, which can hijack an agent’s behavior when content is treated as trusted. OWASP maps this risk to Prompt Injection; mitigations include separating instructions from data, screening retrieved content, limiting tool access, and testing adversarially.

Sensitive Information Disclosure covers leakage through generated answers, application logs, and training data. Access controls, data minimization, redaction, and careful retention practices reduce exposure. System Prompt Leakage is a related risk: prompts may be extracted or inferred, so passwords, keys, personal data, and other secrets should never be placed in system instructions. Treat prompts as discoverable and enforce confidentiality outside the model.

Data and Model Poisoning describes tampered training or fine-tuning examples that alter model behavior, introduce backdoors, or weaken safeguards. Dataset provenance, validation, controlled training pipelines, and post-training evaluation help detect manipulation. Supply Chain Vulnerabilities include compromised pretrained models, malicious model files, plugins, and third-party datasets. The OWASP Supply Chain category points to source verification, dependency review, artifact scanning, and trusted registries as important defenses.

Excessive Agency arises when an AI agent has broader permissions than its task requires. Under OWASP’s Excessive Agency category, use least privilege, human approval for consequential actions, scoped credentials, and tool allowlists. Unbounded Consumption covers resource exhaustion and denial-of-service through excessive or repeated requests. OWASP recommends limits on input size, tokens, time, and spending, alongside monitoring and rate controls. Other categories, including Improper Output Handling and Vector and Embedding Weaknesses, reinforce the need to validate model outputs and secure retrieval stores. Applying these categories together turns threat awareness into layered safeguards across data, models, tools, and operations.

AI security begins with protecting the information systems use and the models they rely on. Data security covers training and inference information: organizations should classify sensitive data, encrypt it in transit and at rest, collect only what is needed, and set retention limits. These controls reduce exposure through datasets, prompts, logs, and outputs. Model security addresses integrity and trustworthiness. Teams should verify model artifacts, document provenance, restrict access to models and weights, and evaluate behavior for weaknesses such as unsafe responses, bias, or leakage. Application security then connects these safeguards to the product. Input and output validation, secure prompt design, and established secure coding practices help prevent malicious content from exploiting AI features or reaching users unchecked.

Cloud infrastructure security provides the environment in which AI services operate. Strong identity controls, least-privilege permissions, network isolation, managed secrets, and useful audit logging can limit unauthorized access and support investigation. These measures apply across model hosting, data pipelines, APIs, and supporting services. Agentic AI introduces additional concerns because systems may use tools or take actions on a user’s behalf. Tool permissions should be narrowly scoped, execution should occur in sandboxes where practical, and explicit action boundaries should govern operations such as sending messages, modifying records, or spending funds. Human approval can be required for consequential actions. Without these limits, a compromised or misdirected agent may turn an input-level weakness into a real-world impact.

AI governance ties technical protections to organizational responsibility. Clear policies define acceptable use, risk classification, oversight, accountability, and processes for monitoring and incident response. Frameworks such as the EU AI Act, the NIST AI Risk Management Framework, and ISO/IEC 42001 offer complementary ways to structure compliance and management, though obligations depend on context and jurisdiction. The six domains are interdependent: governance sets expectations, while engineering teams implement controls across data, models, applications, infrastructure, and agents. For example, a data-retention policy needs technical enforcement in storage and logging systems, and model evaluations should inform deployment decisions. No single safeguard addresses every failure mode. A layered approach combines preventive, detective, and responsive controls, reducing reliance on any one component and helping organizations adapt as systems and threats evolve.

Open-source AI security tools help teams assess risks throughout the development and deployment of generative AI systems. Some focus on adversarial testing, others on privacy or model-file integrity, and several add runtime protections. Used together, they support a broader security program rather than serving as interchangeable solutions.

NVIDIA garak (https://github.com/NVIDIA/garak) is an LLM vulnerability scanner that probes models for weaknesses such as hallucination, data leakage, prompt injection, and jailbreaks. Teams can use its probes to identify failure patterns before release and compare model behavior across configurations. Promptfoo (https://github.com/promptfoo/promptfoo) evaluates prompts and LLM applications through configurable tests and red-team scenarios. Its automated test suites can run in continuous integration, helping developers detect regressions when prompts, models, or application code change.

LLM Guard (https://github.com/protectai/llm-guard) provides input and output scanners for risks including prompt injection, toxic content, exposed secrets, and personally identifiable information (PII). It can be integrated into application pipelines to inspect user requests and model responses. Microsoft Presidio (https://github.com/microsoft/presidio) focuses on privacy, detecting and anonymizing PII in text and images. It is useful when preparing data for model use or reducing sensitive information in prompts, logs, and generated content.

ModelScan (https://github.com/protectai/modelscan) examines machine-learning model files for unsafe serialization and malicious code, supporting checks before models are loaded or shared. Microsoft PyRIT, the Python Risk Identification Tool (https://github.com/Azure/PyRIT), automates red teaming of generative AI systems. Security and assurance teams can use it to explore attack scenarios and document weaknesses across models and applications.

NVIDIA NeMo Guardrails (https://github.com/NVIDIA/NeMo-Guardrails) adds programmable controls to conversational systems, using Colang to define permitted interaction flows and responses. Meta’s LlamaFirewall (https://github.com/meta-llama/PurpleLlama) provides guardrails for detecting prompt injection and risky agent behavior, particularly in systems that take actions. Together, these tools cover multiple lifecycle stages: ModelScan checks artifacts, Presidio protects data, garak and PyRIT probe systems, Promptfoo validates changes, and runtime scanners and guardrails help control interactions. Selection should reflect the application’s threat model and be paired with human review.

Managed cloud services can help enterprises apply security controls consistently across generative AI applications. Amazon Bedrock Guardrails lets teams define safeguards for models accessed through Bedrock, including content filters, denied topics, sensitive information handling, and prompt attack detection. Depending on configuration, it can block or mask personally identifiable information (PII) and assess whether responses are grounded in supplied sources. Guardrails can be invoked with supported Bedrock model requests and connected to application workflows, centralizing policy while keeping controls near hosted models.

Azure AI Content Safety provides services for detecting harmful text and images, with configurable severity thresholds and blocklists. It can support moderation of user inputs and model outputs in applications built with Azure AI services, while prompt shields help identify direct and indirect prompt attacks. Groundedness detection can help assess whether responses align with source material in supported scenarios. Google Cloud Model Armor offers screening for prompts and responses, including checks for unsafe content, sensitive data, prompt injection, and grounding or hallucination risks. It integrates with Google Cloud’s generative AI ecosystem and application services, allowing organizations to apply policies around model interactions.

These managed tools can shorten deployment timelines by providing provider-maintained capabilities rather than requiring every detector to be built and operated in-house. Centralized policy enforcement supports consistent controls across teams, while provider updates and scalable infrastructure can reduce operational burden. Configurable filters and logging may also help organizations align processes with internal governance and compliance requirements; however, using a service does not by itself establish regulatory compliance.

Trade-offs include dependence on one cloud provider, usage costs, added request latency, and less flexibility than bespoke or open-source components. Coverage and behavior vary by model, language, configuration, and integration, so testing against real workflows remains essential. Enterprises should select managed controls when rapid rollout, provider integration, and centralized administration are priorities. Self-hosted or open-source defenses may suit strict data-residency needs, specialized policies, or workloads requiring deeper customization, provided teams can maintain them. In either case, layered protection is preferable: combine cloud safeguards with application-level authorization, input validation, monitoring, human review where appropriate, and independently evaluated defenses against emerging attacks.

AI security is most effective when it is built into the software development lifecycle rather than added just before launch. At the commit stage, developers can run static checks on application code, dependencies, and infrastructure-as-code, while reviewing changes to prompts, model configurations, and data handling. Model artifacts should also be scanned before deployment. Tools such as ModelScan can help identify unsafe or unexpected components, including serialized model files that may contain executable code. These checks provide an early opportunity to reject risky artifacts and investigate their origin before they enter a production environment.

A sample pipeline moves a change from commit through testing, staging, and production, with controls at each transition. Automated tests first check functionality, data flows, and access permissions. Security tests then assess model and application behavior: garak can probe for vulnerabilities, while Promptfoo can run repeatable evaluations of prompts and responses, including adversarial cases. Results are recorded against defined safety thresholds. CI/CD security gates block a release when critical vulnerabilities are found, required evaluations fail, or safety performance falls below the agreed minimum. Infrastructure-as-code scanning checks cloud resources for misconfigurations, and deployment identities receive only the permissions needed for their specific tasks. Approved builds can proceed to staging for further review before controlled production rollout.

Protection continues at runtime. Input guardrails can detect or constrain sensitive data, malicious instructions, and unsupported requests; output guardrails can screen responses for unsafe content, privacy leakage, or policy violations. Continuous monitoring should track prompts, responses, latency, costs, and anomalous usage patterns, with appropriate privacy controls and retention limits. Alerts and incident procedures help teams respond to abuse, unexpected model behavior, or sudden spending increases. Security teams and developers share responsibility for these controls: developers maintain secure code and tests, while security specialists define requirements, review risk, and support threat modeling. Together, they establish ownership for exceptions, monitor changing threats, and use incidents and evaluation results to improve safeguards throughout the AI system’s lifecycle.

Retrieval-augmented generation (RAG) and AI agents can expose sensitive information or take unintended actions unless access is controlled throughout the system. Apply document-level permissions before retrieval, not merely after an answer is generated: each query should respect the requesting user’s identity and entitlements. Secure the vector database with tenant isolation, encryption in transit and at rest, and filtered queries that prevent cross-tenant or unauthorized results. These controls should extend to indexes, backups, metadata, and administrative interfaces. Test permission boundaries regularly, including cases where documents are re-indexed or users change roles, and ensure that retrieved content cannot override system policies.

Agents also need narrowly scoped permissions for every tool and data source. Grant only the access required for a defined task, use allowlists to restrict executable tools and destinations, and validate parameters before any call is made. For high-impact operations, require human approval rather than relying on the model’s confidence. Separate planning from execution, and use policy checks to reject actions that exceed approved limits. Sandboxing reduces the consequences of mistakes, while rate limits and explicit timeouts help contain runaway or repeated operations. These safeguards apply even when an action appears routine, since a compromised prompt or inaccurate response can influence an agent’s decisions.

Consider a DevOps agent that manages cloud infrastructure. Give it a scoped role limited to approved accounts and resources, with read access by default and narrowly defined permissions for routine updates. Require a human reviewer to approve every production change. Block destructive commands, such as deleting databases or removing backups, unless a documented exception and separate approval exist. Run commands in a sandbox, validate proposed plans against infrastructure policy before execution, and verify results afterward. Maintain tamper-resistant audit logs recording prompts, retrieved documents, tool calls, approvals, policy decisions, and outcomes. Review these records to investigate incidents, detect unusual behavior, and refine controls. A clear record of each decision makes the system more accountable and helps operators identify whether a failure arose from access, retrieval, policy, or execution.

A practical AI security architecture can combine open-source and self-managed tools into a layered system rather than relying on a single model provider or control. Ollama can host models locally or within a private environment, helping keep prompts and data inside an organization’s infrastructure. Users and applications should reach those models through LiteLLM, which provides a unified gateway for routing requests across models and applying authentication, rate limits, and spending budgets. Network segmentation, identity-based access, secrets management, and least-privilege permissions remain essential foundations around these components.

Before a request reaches a model, an application can use Presidio to detect and redact personally identifiable information, and LLM Guard to inspect inputs for risks such as injection attempts or sensitive content. These checks should be configured for the organization’s use cases, with clear handling rules for blocked or transformed requests. Model responses should also pass through output scanning before users see them, including checks for sensitive data or disallowed content. If the system allows tools or external actions, enforce explicit allowlists, scoped credentials, and human approval for consequential operations; model instructions alone are not an adequate access control.

Testing and monitoring complete the architecture. Garak can scan models for known vulnerability patterns, while Promptfoo supports repeatable evaluations and regression tests as prompts, models, or safeguards change. Langfuse can provide traces and observability across requests, and support evaluation of system behavior over time. Together, these tools create multiple opportunities to prevent, detect, and investigate failures without making expensive commercial platforms the only option. However, a self-managed stack transfers substantial responsibility to the operating team: components must be securely configured, patched, monitored, and tested; logs must be protected and retained appropriately; and alerts need owners and response procedures. Open-source tools also have coverage limits, and scanning cannot guarantee safe behavior. Organizations should validate controls against their threat model, measure false positives and missed risks, and maintain a fallback plan for outages or newly discovered vulnerabilities.

Technology consultants, cloud architects, and engineering teams can help customers translate AI security concerns into practical controls. A coordinated engagement can address models, data, infrastructure, applications, and operational processes rather than treating AI as an isolated component.

Assess risks and design secure foundations

An AI security assessment typically reviews use cases, data flows, model providers, access controls, interfaces, and regulatory obligations. Teams identify vulnerabilities such as exposed credentials, unsafe inputs, sensitive-data leakage, excessive permissions, and weaknesses in third-party dependencies. Deliverables may include a prioritized risk register, threat model, control-gap analysis, and remediation plan. These findings give leaders a clear view of risk and a defensible basis for investment.

Cloud and security architects then design an enterprise AI architecture aligned with business requirements. Activities include defining trust boundaries, identity and authorization patterns, encryption, network isolation, logging, model and data governance, and resilient deployment options. Architecture diagrams, reference patterns, and implementation guidance help engineering teams build systems that are scalable, compliant, and secure by design.

Embed security in delivery and testing

AI DevSecOps services integrate security checks into development and release workflows. Teams can establish model and dataset inventories, scan code and dependencies, validate configurations, manage secrets, and apply approval gates. Pipeline templates, policies, and operating procedures make security repeatable while helping teams detect issues earlier.

AI red teaming and automated security testing examine how systems behave under adversarial or unintended use. Consultants define test scenarios, assess prompt injection, jailbreaks, data extraction, and unsafe outputs, then document reproducible findings and mitigation priorities. Retesting verifies that fixes work and supports measurable risk reduction.

Protect retrieval, agents, and data

For retrieval-augmented generation and agentic AI, engineers review document ingestion, retrieval permissions, tool access, action limits, and human approvals. Secure designs reduce cross-user data exposure and constrain agents to authorized tasks. Data privacy programs map sensitive information, establish retention and minimization controls, and define consent, access, and incident-response practices. Outputs can include data-flow maps, privacy controls, and governance procedures.

A practical roadmap begins with assessment, proceeds to target architecture, and then moves into implementation. Red teaming and automated testing validate controls before broader deployment. Ongoing governance—through monitoring, periodic reassessment, policy updates, and incident exercises—keeps protections aligned as models, data, and business needs change.

© Manish Soni 2026