Secure by Design and Trustworthy AI
local graph
Chapter 17 — Secure by Design and Trustworthy AI
Section titled “Chapter 17 — Secure by Design and Trustworthy AI”We have covered key examples of adversarial AI attacks in significant detail. This chapter transitions from understanding the adversarial landscape of AI to embedding security and trustworthiness into AI systems from the design phase.
While we’ll focus on the technical details of attacks to help us understand them, we will take a step back and try organizing our examples and understanding around more formal definitions of threats and attacks by using categories and taxonomies devised by leading organizations such as NIST, MITRE, and OWASP. This will provide a foundation to reference the threats and attacks without getting lost in the details new variants will no doubt bring.
We will consolidate these taxonomies into a reference model that we can use to plan and deliver Trustworthy AI, a term that incorporates security and safety. We will discuss the vital role of data and AI ethics in Trustworthy AI and how they relate to security and safety.
Using a sample case study AI application, we will walk through techniques such as threat modeling to illustrate how to develop security from the start and make it relevant to the AI application we’ll build. This will demonstrate how our AI solution is secure by design. Through the methodology, tools, and a practical use case, we aim to equip you with the skills to implement Secure by Design principles effectively.
We will cover the following topics:
- A secure by design methodology for AI to safeguard against threats and risks
- AI attack and threat taxonomies and how they relate to what we have learned so far
- Public taxonomies used in MITRE ATLAS, the NIST AI 100, the OWASP AI Exchange, and the OWASP Top 10 for LLM Applications
- Threat modeling for AI using an extended FoodieAI sample application
- Risk-based threat prioritization, mapping mitigations to standard controls, creating and implementing a security design, and applying tests and verification
- Shifting AI security to the left and applying it to deployment and live operations
- Trustworthy AI and its relationship with AI security
- AI and data ethics and its interplay with AI security and safety as part of Trustworthy AI
Let’s start our conversation by establishing a systematic approach to addressing the threats and attacks we have discussed as part of our secure-by-design methodology.
Secure by design AI
Section titled “Secure by design AI”The increasing number of attacks, the complexity AI brings, compliance requirements, and the need to maintain security posture require a methodology that brings security to the epicenter of introducing new solutions. A term we often use is secure by design, denoting the intentional consideration of security risks and mitigations when building a new solution.
Our secure-by-design AI (SbD AI) methodology is based on Guidelines for secure AI system development, which was jointly developed by the UK and US national cybersecurity agencies NCSC and CISA, respectively. It extends existing secure-by-design approaches in traditional cybersecurity to incorporate Adversarial AI and emphasizes integrating security principles from the earliest stages of AI system development.
SbD AI highlights the need for a proactive approach to security. This approach ensures that AI systems are resilient against threats and aligned with security standards throughout their life cycle. This avoids the pitfalls of late-stage assurance, where the system is already built, and changes are costly to make.
The methodology adopts a contextual and risk-based attitude to securing AI, starting with identifying relevant threats. Not all threats are appropriate or of equal importance. As we saw in previous chapters, just because a research paper has demonstrated a vulnerability in lab settings does not mean this is an easily exploitable attack, nor are they applicable to our solution. For example, our solution may be a Generative AI solution that utilizes third-party LLMs via an API. This will have different risks than a Predictive AI solution with image recognition on an IoT device.
SbD AI uses threat models to bring this contextual and risk-based approach, helping us understand the exploitability and applicability of adversarial risk to our solution.
This helps us prioritize what’s important and relevant and avoid overwhelming organizations, decision-makers, and practitioners with a large volume of research papers. Such a generic approach undermines confidence. It often triggers expensive gold plating, which involves uncritically implementing a vast array of preventive measures that are hard to manage and can introduce their own vulnerabilities due to complexity.
SbD AI is a lean approach that relies on a cycle of standard activities, as shown in the following diagram:

Figure 17.1 – Secure-by-design methodology
The activities are not different from a generic SbD approach, but we incorporate the AI-specific concerns into each one. Let’s review them in more detail:
- Threat modeling: This activity uses a dictionary of threats based on standard industry taxonomies to identify potential security risks. It then applies risk management techniques to prioritize these risks and determine appropriate mitigations. We introduced threat modeling in Chapter 3 and discussed it alongside related frameworks such as STRIDE, PASTA, and attack trees. Modern threat modeling in AI includes risks unique to AI, such as data poisoning, evasion, model inversion, and other Adversarial AI attacks.
- Security design: In this phase, the identified mitigations are mapped to specific security controls and incorporated into the AI solution architecture. This includes designing secure data and MLOps pipelines, access controls, adversarial training, and model architectures that are resilient to attacks. Depending on data sensitivity and the threat model, techniques that we covered in Chapter 10, Privacy-Preserving AI, are considered to protect data and models, including anonymization – differential privacy, federated learning, and so on.
- Secure implementation: This is where the designed controls are implemented, covering both the AI model’s development and deployment. Controls here address risks related to the model training process, such as ensuring data integrity, protecting against backdoors, and securing the supply chain. Secure coding practices, DevSecOps/MLSecOps, and rigorous testing are crucial in this phase.
- Testing and verification: Comprehensive testing and verification are performed to ensure the effectiveness of the implemented security controls. This includes benchmarks, adversarial testing, and red teaming to validate the model’s robustness against attacks and discover vulnerabilities. These will be combined with penetration testing of the AI system and its infrastructure. Formal verification methods may also be employed to prove the correctness of critical components.
- Deployment: The AI system is deployed into production while following a secure deployment process. This involves configuring the production environment securely, applying necessary patches and updates, and ensuring proper access controls are in place. Continuous monitoring and incident response capabilities are set up in this phase.
- Live operations: Once deployed, the AI system is continuously monitored for any signs of attacks or anomalous behavior. Automated alerts are configured to notify relevant personnel of potential security incidents. A well-defined incident response plan is implemented to quickly detect, contain, and recover from security breaches. As discussed in previous chapters, AI brings its own complexities in monitoring, alerting, and incidence response. Advanced custom monitoring and alerting solutions may be introduced here, depending on the solution and threat model. Regular security audits and updates ensure the AI system remains secure throughout its life cycle.
By following this iterative approach, SbD AI enables the development of secure AI systems by design, reducing the risk of vulnerabilities and attacks. It is an ongoing process that requires continuous improvement and adaptation to evolving threats in the rapidly advancing field of AI security.
The list describes a sequence, but it is a cycle since new requirements, continuous improvement, and lessons learned from incident handling will lead to the repetition of all the steps.
Note that the sequence of steps is not absolute. Requirements will change even before deployment, and they may trigger additional threat modeling and security design adjustments.
Furthermore, we will need to perform spikes and evaluations throughout the cycle to support our decisions. These may look like development, testing, and verification activities, such as safety benchmarking of models before choosing one. Still, they are self-contained to support the cycle and can happen at any stage. A special form of testing is red-teaming and offensive security. A top on its own, and beyond the scope of this chapter, the approach adopts an attacker perspective aiming to discover security gaps and vulnerabilities and is a must-do as part of testing.
Note
A secure-by-design methodology for AI represents a paradigm shift in approaching AI security. It moves away from lab-based and research-driven Adversarial AI toward a system, risk-based approach that incorporates Adversarial AI research into proven enterprise security approaches. This enhances the security and reliability of AI systems and aligns with the broader goal of creating trustworthy and resilient digital technologies.
In the following sections, we will use a sample AI solution and walk through these activities. But before we do that, let’s review our dictionary of threats and align it with various industry taxonomies.
Building our threat library
Section titled “Building our threat library”Before delving into threat modeling, we must define our AI threats dictionary and relate it to Adversarial AI. So far, we have used the terms threat and attack interchangeably. Let’s remind ourselves of what each of them means:
- Threats: A threat is a potential cause of harm to a system through intentional actions such as hacking or accidental occurrences such as natural disasters. It signifies possible danger but not the action itself.
- Attacks: An attack involves actively exploiting vulnerabilities in a system, aiming to breach security, inflict harm, or steal data. It’s the practical execution of a threat.
- Vulnerabilities: Vulnerabilities are flaws or weaknesses in a system that can be exploited to gain unauthorized access or cause damage. They are the specific openings that are targeted in attacks.
- Risks: Risk measures the potential for loss or damage when a threat exploits a vulnerability, combining the likelihood of an attack with its potential impact.
We often use attacks and vulnerabilities to define and highlight threats.
To create our threat library, we will summarize the attacks and threats covered in this book. This includes the following:
- Traditional cyberthreats
- Adversarial AI attacks
- Adversarial AI attacks specific to Generative AI
- Supply chain attacks
Let’s start with the traditional cyberattacks and threats.
Traditional cyber security threats
Section titled “Traditional cyber security threats”These are the attacks we explored in Chapter 3 and are what an AI solution will face inherently as a digital solution. Because AI relies on real data, the risks are elevated in AI solutions. We’ve indicated this by including Dev in the Stage column:
| Attack/Threat | Stage | Description | Ch | |
|---|---|---|---|---|
| T01 | Data Leak | Dev, Prod | Unauthorized access and exfiltration of sensitive data. | 3 |
| T02 | Tampering | Dev, Prod | Malicious change of data or artifacts. | 3 |
| T03 | Malware Attacks | Dev, Prod | Use of malware to gain control, damage or exfiltrate data, or stage ransomware attacks. | 3 |
| T04 | Privilege Escalation | Dev, Prod | Gaining access to perform tasks not authorized to do. This includes access via broken access control. | 3 |
| T05 | Denial of Service | Dev, Prod | Disrupt the use of a system by excessive usage or other techniques. | 3 |
Table 17.1 – Traditional cybersecurity threats
As discussed in Chapter 3, reliance on live data makes AI development environments production-like.
Adversarial AI attacks
Section titled “Adversarial AI attacks”This covers the attacks we’ve explored throughout this book, except the ones specific to Generative AI and supply chain attacks, for which we have separate tables:
| ID | Attack/Threat | Stage | Description | Ch |
|---|---|---|---|---|
| T06 | Data Poisoning | Dev | The attacker injects malicious data into development datasets to degrade or influence the model’s performance. This includes base modeling or fine-tuning or data for attacks on RAG in LLM solutions. | 4, 15 |
| T07 | Backdoor Attacks | Dev | A targeted variation of poisoning that aims to insert a specific activation backdoor. | 4, 15 |
| T08 | Model Tampering | Dev, Prod | Tampering with hyperparameters and weights, injecting Trojan horses using custom layers, insecure serialization for Predictive AI, or using model editing techniques such as Rank One Model Editing (ROME) for LLMs, as discussed in Chapter 1 6 | 5, 16 |
| T09 | Model Theft | Dev, Prod | Physical model theft and exfiltration from either a development or production environment. | 3, 8 |
| T10 | Evasion | Prod | Using adversarial inputs to evade the model’s classification leads to general or targeted misclassifications. | 7 |
| T11 | Model Reprogramming | Prod | Exploitation of online training or reinforcement learning to poison a deployed model. | 7 |
| T12 | Model Extraction | Prod | Using inputs/outputs to create a functional equivalent to the target model. | 8 |
| T13 | Model Inversion | Prod | Use of inputs/outputs to create approximations of the model’s training data. | 9 |
| ID | Attack/Threat | Stage | Description | Ch |
| T14 | Membership Inference | Prod | Use of inputs/outputs to infer whether a record was used in the training process. | 9 |
| T15 | Attribute Inference | Prod | Use of inputs/outputs to infer an attribute for a record | 9 |
| T16 | ML DoS | Prod | Use of adversarial samples to make the model unusable. | 3, 7 |
Table 17.2 – Adversarial AI threats (general)
Adversarial AI attacks specific to Generative AI
Section titled “Adversarial AI attacks specific to Generative AI”Since our system and model use an LLM, we have listed some Generative AI-specific threats in the following table:
| ID | Threat | Stage | Description | Ch |
|---|---|---|---|---|
| T17 | Direct Prompt Injection | Prod | Manipulation of a model’s conversational context to bypass the model’s safety measures (jailbreaking). | 14 |
| T18 | Indirect Prompt Injection | Prod | Manipulation of data used in prompts indirectly – that is, an LLM platform with built-in internet access or RAG. | 14, 14 |
| T19 | Data Disclosure | Prod | Use of adversarial techniques to exploit LLMs to divulge system configuration data (such as system prompts and connection data) or data from connected downstream services, including RAG data stores. | 14 |
| T20 | Insecure Output | Prod | Exploitation of unvalidated executable content. | 14 |
| T21 | Excessive Agency | Prod | Exploitation of excessive functionality or permissions given to an LLM in a Generative AI solution. | 14 |
| T22 | Agent Hijacking | Prod | Exploitation of vulnerabilities in autonomous agents to highlight or influence the behavior of the agents. | 14 |
| T23 | Training Data Extraction | Prod | Use of prompt injections to exfiltrate memorized training data. Unlike Model Inversion, the actual training data is extracted without the need for reconstruction. | 16 |
| T24 | Model Replication | Prod | The use of LLMs instructs training to create datasets to train a base LLM to replicate the target model. | 16 |
| T25 | AI Misuse/Abuse | Prod | Use Generative AI to produce harmful, misleading, unsafe, and unethical content. This includes phishing attacks, malware creation, deepfakes, using an LLM to infer private data, and exploiting LLM overreliance. | 12, 13 |
Table 17.3 – Adversarial AI threats specific to Generative AI
Supply chain attacks
Section titled “Supply chain attacks”Finally, we’ve listed the supply chain threats of our model in the following table:
| ID | Threat | Stage | Description | Ch |
|---|---|---|---|---|
| T26 | Supply Chain Model Compromise | Dev, Prod | Exploitation of poisoned or tampered data acquired via the supply chain. This includes the exploitation of unintentional vulnerabilities inherited via transfer learning. | 6, 16 |
| T27 | Supply Chain Data Compromise | Dev, Prod | Exploitation of poisoned or tampered data acquired via the supply chain. This includes stored prompt injection for LLMs. | 6, 16 |
| T28 | Supply Chain Package Vulnerability Exploitation | Dev, Prod | This traditional exploitation of vulnerable components also includes ML/AI frameworks and components with malicious serialization from external sources. | 3, 6 |
| T29 | Supply Chain System Compromise | Dev, Prod | Exploitation of a system (GPU, the cloud, or a development environment) via the supply chain. | 3, 6, 16 |
Table 17.4 – Supply chain threats
Now that we have our library of threats let’s align them with some well-known threat taxonomies and explain the usefulness of the mapping.
Industry AI threat taxonomies
Section titled “Industry AI threat taxonomies”AI threat taxonomies is an active and evolving field that is attempting to provide a standard. There are three leading taxonomies, each with a different focus:
- MITRE ATLAS: This follows MITRE’s ATT@CK example with a catalog of tactics, techniques, and procedures (TTPs) that are used by threat actors against AI systems. MITRE ATLAS helps organizations identify and understand potential AI-specific threats, facilitating the development of effective defense strategies. It helps understand the attack kill chain by relating tactics and techniques. Because it uses industry-standard Structured Threat Information eXpression (STIX), it integrates with threat intelligence (TI) tools. This, in turn, helps connect threat models to TI and monitor when a solution is deployed. You can find out more about ATLAS at https://atlas.mitre.org/.
- NIST AI 100-2 E2023: This is from the National Institute of Standards and Technology (NIST) and provides a catalog of attacks and mitigations for adversarial ML based on a comprehensive review of published research. Regularly updated, the document represents an authoritatively reviewed and widely referenced taxonomy of AI threats. Its 98 pages provide a comprehensive compendium of adversarial AI research. Although it includes techniques and mitigations, in contrast to ATLAS, its nature is research-oriented. You can find the document at https://csrc.nist.gov/pubs/ai/100/2/e2023/final.
- OWASP AI Exchange: The Open Worldwide Application Security Project (OWASP) AI Exchange is a collaborative initiative that provides a reference model on vulnerabilities, attack vectors, and best practices for securing AI systems. The project relies on expert contribution and builds on the work of other OWASP projects, notably the very popular Top 10 for LLM Applications. The project aspires to act as a driving force in aligning other standards, including mappings to ATLAS and NIST. The project is still forming, and it complements the previous taxonomies by applying security controls to threats and attacks, offering a comprehensive set of controls. This makes it an ideal tool for enterprise security programs.
Note
The author is a core team member for the OWASP AI Exchange and co-lead of OWASP Top 10 for LLM Applications. You can find out more about these projects at https://owaspai.org and https://genai.owasp.org/.
By combining these taxonomies, we can take advantage of the strengths that each brings.
AI threat taxonomy mapping
Section titled “AI threat taxonomy mapping”Mapping that library to NIST’s taxonomy and OWASP AI Exchange is relatively straightforward because of the consensus. However, it does highlight some different approaches to threat identification that are worth exploring.
NIST AI taxonomy mapping
Section titled “NIST AI taxonomy mapping”Most entries have a one-to-one mapping with NIST AI 100-2e2023, including data poisoning, backdoor attacks, evasion attacks, model reprogramming, model extraction, prompt injections, data disclosure, and more.
NIST’s taxonomy is more focused on pure Adversarial AI attacks. We include classic cybersecurity threats to aid practical threat modeling and provide more granularity on supply chain attacks.
The NIST taxonomy is also more detailed, with subcategories that have been covered in this book but have been omitted from our threat library. This is intentional; detailed understanding is essential, but too much detail can overwhelm threat modeling without adding value.
Finally, we include more advanced Generative AI attacks related to autonomous agents and model agencies. These are distinct emerging themes that will undoubtedly be included in its next update.
The following table provides a detailed mapping of our threat library and the NIST taxonomy: