Part 08›
✎

14. Security, Privacy, Transparency and Accountability#

Level: Practitioner · Reading time: 19 min · Exercise: 90 min Prerequisites: System Quality: End-to-End Tests and Guardrails

In one sentence: After this chapter you can run a five-stage threat model over an LLM feature, apply the two design principles that limit most damage, and state what you tell users about the model and who answers for its decisions.

Why this matters#

Three more questions arrive in the same month.

The first is security. The second is privacy. The third is transparency and accountability.

The core idea#

Security protects a system from people who intend to harm it. Requirements fall into three classes, the CIA triad: confidentiality (only authorized people read sensitive data), integrity (data and decisions are not tampered with), and availability (the service keeps running). Kästner notes that ML adds new things to protect: training data, models, prompts, and telemetry (chapter 28).

Privacy means that a person decides which personal information other parties get, and what they may do with it. Security is necessary for privacy and not sufficient for it. A system can break its privacy promises without any attacker, by selling data it promised to guard (chapter 28).

Transparency means telling the people affected that a model is involved and what it does. Accountability means a named person or role answers for each kind of automated decision, and an affected person can appeal it.

Kästner's conclusion about ML security is sobering. Attack and defense form an arms race, and broad guarantees at the model level are unlikely (chapter 28). The practical rule is to assume the model can be tricked and to secure the system around it. That is the same reasoning as chapter 08 on guardrails.

How it works, step by step#

1. Know the five attacks specific to ML#

Attack What the attacker does In a support product
Evasion Crafts an input that looks harmless and produces the prediction they want A message phrased so the triage model routes it to a low-priority queue
Poisoning Manipulates training data, to degrade the model or to plant a back door Flooding the system with mislabeled reports
Model extraction Queries a model repeatedly to learn a copy of it Rebuilding the routing model from its answers
Model inversion and membership inference Recovers training data, or learns whether a record was in it Extracting an earlier customer's text from a fine-tuned model
Prompt injection and jailbreaking Puts instructions inside data the model will read, or talks it past its safeguards The ticket sentence that asks for a refund

Kästner compares prompt injection to SQL injection and cross-site scripting: data and instructions end up in one channel (chapter 28). He also emphasizes how many routes lead to training data. Public data sets, crowd labels, and telemetry can all be influenced without breaking in.

Defending the model itself is covered in Defenses and Guardrails in part 04. This chapter stays at the system level.

2. Threat-model the whole system#

Start from a security mindset: any component may be compromised, any user may misbehave, any input may be malicious. Perfect security is out of reach, so the goal is to reduce risk (chapter 28).

The mindset does not come naturally to every developer, and many dislike the negative thinking it asks for. Kästner's remedies are training, building security into the process, and above all bringing in experts (chapter 28).

Threat modeling is a structured review of a system's design for security threats, done early in design or as an audit. Kästner describes five stages (chapter 28):

  1. Attacker goals and capabilities. Teenagers trying to bypass a filter for bragging rights and a state-backed team with patience and budget call for different defenses. The more likely attacker may deserve more attention than the stronger one.
  2. System structure. Draw a data-flow diagram that includes every store, the training and serving components, and monitoring. Show how training and inference data can be influenced, including by the people who label it.
  3. Threats. Inspect every component and connection against a checklist. The book names STRIDE, a method from Microsoft with six categories: spoofing an identity, tampering with data, repudiation, in which a user denies an action, information disclosure, denial of service, and elevation of privilege (chapter 28).
  4. Risk. Rate each threat by likelihood and by damage if it succeeds, on rough scales, and rank by the product. The absolute scores do not matter. The order does.
  5. Implement and test defenses. Prefer proven standards and libraries over new security ideas, and bring in experts (chapter 28). Some weaknesses are coding mistakes, such as unsanitized input or a misused cryptographic library. The OWASP Top 10 for web applications and MITRE's CWE list the common ones, and static analysis, which reads code without running it, catches many during continuous integration, a practice marketed as DevSecOps (chapter 28).

3. Apply the two design principles#

4. Monitor, and test as an attacker#

Intrusion detection watches for unusual behavior. Kästner notes that the 2017 Equifax breach would have shown up early in network traffic, if an intrusion-detection system had not been offline on an expired certificate (chapter 28). For an agent, the equivalent signals are odd tool-call patterns and data volumes.

Red teaming has experts attack a system on purpose and report what they find. It complements threat modeling and tested defenses. It does not replace them, and Kästner thinks the term is overused for work that deserves a more structured method (chapter 28).

5. Design for privacy#

6. Be transparent, and name who is accountable#

Kästner separates transparency about the model's existence from transparency about how it works (chapter 29). In a 2015 study he cites, 62 percent of surveyed Facebook users did not know that an algorithm curated their feed rather than showing every post, and many reacted with surprise and anger when told. He also cites reports of managers who did not know that an automated tool had discarded applicants before they saw them.

Before writing a notice, name its goal: trust at the right level, so that users know when to check the model; support for an appeal; or a feeling of autonomy and dignity. Kästner warns that trust the system has not earned puts users at risk, and says to test the design with users (chapter 29).

  1. Say that a model is involved, where it affects people. Hiding it removes the chance to appeal, and users feel deceived when they find out.
  2. Explain at a useful level. Users form a mental model of how a system decides, correct or not, and they need some understanding to point out a mistake. For high-stakes decisions such as loans, hiring, or housing, Kästner considers explicit explanations and a stated level of certainty important. For low-stakes ones, such as spelling correction, automation without explanation can be acceptable (chapter 29). Show sources next to generated claims.
  3. Weigh the risk of gaming. A counterfactual helps a person change what they can (see chapter 13). It also tells a student how an automatic grader works, or a spammer which words to avoid. Models built on robust, causally related features invite the behavior you want. Models built on weak proxies invite gaming, and hiding their workings is only security by obscurity (chapter 29).
  4. Keep oversight real and allow appeals. Reviewing every decision is too expensive at scale, and even a complaints team can be costly. Kästner's test: if oversight costs too much to afford, the product may not be viable in its planned form (chapter 29). The principle lists in chapter 23 include human alternatives and human oversight.
  5. Assign an owner to each decision type, and keep the records from chapter 12, so that any decision can be reconstructed.
  6. Blame a decision, not "the algorithm". Harm traces back to human choices about the system's design, evaluation, and safeguards. A producer that integrates third-party models or data is responsible for the whole product, as a car maker is for defective tires (chapter 29).

What the practitioners say#

Pitfalls#

  1. Giving a model-driven agent broad tool access. Fix: least privilege. Only the tools the task needs.
  2. Trying to make the model impossible to trick, and stopping there. Fix: assume it can be tricked, and bound the damage in code.
  3. Threat-modeling the model alone. Fix: the whole data flow, including labels and telemetry.
  4. Detection by a second prompt as the only defense. Fix: standard controls around it, and tests with hostile input.
  5. Sending raw customer data to a model provider. Fix: redact, minimize, and check the terms.
  6. Transparency buried in a policy. Fix: a short notice at the point of use, and a route to a human.
  7. Oversight that rubber-stamps. Fix: evidence next to each action and a volume a person can read.

Try it#

  1. Write a one-page threat model for one feature: the attacker, their capability, a data-flow sketch, and five threats with likelihood and damage scores.
  2. Implement two mitigations in plain code: one that narrows the attack surface, one that applies least privilege.
  3. Write a three-sentence disclosure for users, and name the appeal path.

You are done when the threats are ranked, when each mitigation has a test with hostile input, when the disclosure says what the model does and what a person can do about it, and when every automated decision type has a named owner. Stretch goal: have a colleague who did not build the feature run a fifteen-minute red team against it, and turn each finding into a test.

Key takeaways#

Self-check#

  1. Which attack plants instructions in data that a model will read, and which well-known older attacks does it resemble?
  2. Why rank threats by a product of two rough scores if the scores are made up?
  3. A model-driven agent has access to every internal tool. Which principle is violated?
  4. A system is secure and still breaks privacy. How?
  5. What two things does transparency about a model cover, according to the book's chapter 29?
Show answers 1. Prompt injection. It resembles SQL injection and cross-site scripting, where data and instructions share one channel. 2. Because the ranking is what matters. The absolute values are judgments, and a consistent relative order is enough to decide what to fix first. 3. Least privilege. The agent should hold only the access its task requires, so that a tricked agent can do little. 4. By its own actions, without any attacker: using or sharing data in ways the user did not agree to. 5. That the model exists at all, and how it works.

Sources#

Next#

→ Threat Modeling LLM Applications and Agents in part 04, because agents that call tools widen the attack surface that this chapter's method needs to cover.