← AI Engineering Interview Prep
17 min

AI Security Questions

Nine questions on prompt injection, exfiltration, authorization, red teaming, secrets and supply chain.

Lesson 6 of 11
0 done
In plain English

The main idea: assume the AI can be tricked, and limit what a trick can do. Keep permissions and secrets in code, give tools only the access they need and test your system by attacking it. Never rely on a prompt as your only protection.

Prompt injection
Hidden instructions in content that steer the AI.
Exfiltration
Sneaking data out of a system.
Red teaming
Attacking your own system to find weaknesses.
Picture it
Assume the AI can be tricked
Limit what a trick can do
Keep permissions and secrets in code
Give tools only the access they need
Test by attacking your own system
Never rely on a prompt alone

Security questions are where senior candidates separate themselves. Interviewers look for an architectural stance — assume the model can be manipulated, limit what manipulation can do — and for concrete controls rather than 'add a filter'.

How to approach these questions

  • Begin with the threat: who controls the text the model reads, and what can the agent do?
  • Answer with controls in layers: prevent, detect, correct.
  • Say explicitly that authorization lives outside the model.
Check yourself
Q1What is indirect prompt injection?show answer

In plain words: It is a trick hidden inside content the AI reads, like a web page or email. There is no bad user to block, so you must limit what the AI can do.

Full answer · Instructions hidden in content the agent reads — a web page, email, document, retrieved record or tool output — that attempt to steer its behavior. The attacker never talks to the agent; the content does. It's dangerous because there is no 'bad user' to block, and the model can't reliably distinguish your instructions from instructions embedded in data. Defenses are architectural: isolate untrusted content, restrict tools, authorize outside the model and require approval for sensitive actions.

Q2How can an agent exfiltrate data?show answer

In plain words: Through anything it can write to: email, links, web requests or shared files. Keep private data, outside content and sending apart.

Full answer · Through any channel it can write to: sending email, making HTTP requests, creating links or rendered markdown images whose URLs carry data, writing to shared documents or logs. Combine private data access, untrusted content and an outbound channel in one agent — the 'lethal trifecta' — and an injected instruction can leak data. Break one leg: split the agent, remove the channel, allow-list destinations, or require approval for outbound actions.

Q3Why is authorization outside the model?show answer

In plain words: Because the AI can be fooled, but code cannot. Permission checks in code work every time.

Full answer · The model only proposes actions and can be influenced by what it reads; a prompt rule can be ignored or argued around. Authorization in the tool and service layer is deterministic: it checks the authenticated principal, the resource and the operation, regardless of what the model says. 'The model decided' is never an authorization decision.

Q4What is excessive agency?show answer

In plain words: Giving an agent more tools or freedom than the job needs. A mistake or trick then causes bigger damage. Give only what is needed.

Full answer · Giving an agent more tools, permissions or autonomy than its task needs, so any mistake or manipulation has a large blast radius. Controls: narrow tools around business capabilities, least-privilege short-lived credentials, per-tool limits, budgets, approval workflows for high-impact actions and audit logs. Ask of every tool: what's the worst thing a manipulated agent could do with it?

Q5How would you red-team an agent?show answer

In plain words: Attack the whole system with hidden instructions, bad tools, other customers' data and cost attacks. Turn each failure into a test.

Full answer · Attack the whole system, not just the model: direct and indirect injection through every input channel, tool abuse and malicious tool responses, data exfiltration attempts, privilege escalation, cross-tenant access, loop and cost attacks, and memory poisoning. Automate the scenarios, track attack success rate, turn every finding into a regression test and a design control, and re-run on every release. The key question is what a successful trick can cause, not whether the model can be tricked.

Q6How do you handle secrets in an AI application?show answer

In plain words: Never put secrets in prompts. Tools use short-lived keys kept on the server, and logs hide secrets.

Full answer · Never put long-lived secrets in prompts, context, memory or logs. Tools receive short-lived credentials or run under server-side service identities scoped to least privilege, retrieved from a secrets manager at call time; the model only sees tool names and results. Redact secrets in telemetry, rotate regularly and scan repositories and traces for leaks.

Q7How do you protect sensitive data sent to a model provider?show answer

In plain words: Send only what is needed. Hide private details. Use business terms that do not train on your data. Choose the right region.

Full answer · Minimize and redact what's sent, classify data and filter by sensitivity, use enterprise or API terms with no training on your data and appropriate retention, choose regions that meet residency rules, have data-processing agreements in place, and keep a model gateway where policy and logging are centralized. For regulated data, confirm contractual and regulatory coverage before sending anything.

Q8What is improper output handling and how do you prevent it?show answer

In plain words: It is trusting the AI's output blindly, such as running it as code. Treat it like any outside input and check it first.

Full answer · Using model output as trusted input to another system — rendering it as HTML, executing it as code or SQL, passing it to a shell or following links — which turns a manipulated output into XSS, injection or command execution. Treat output as untrusted: encode on render, parameterize queries, validate against schemas and allow-lists, sandbox any code execution and never let free-form text trigger privileged operations.

Q9How do supply-chain risks apply to agents?show answer

In plain words: Tools, models and plugins are outside code you trust. Check them, pin versions, limit their access and watch what they do.

Full answer · Models, tools, MCP servers, plugins, prompts and dependencies are all third-party code or text the agent trusts. A compromised tool description can steer behavior; an updated server can change what a tool does. Vet sources, pin versions and review changes, scope each integration's credentials, scan dependencies and monitor tool behavior — and don't join a server that reads untrusted content to one holding sensitive access without gates.

Key takeaways
  • ✓Assume the model can be manipulated; limit the blast radius.
  • ✓Lethal trifecta: private data + untrusted content + outbound channel — never all three without a control.
  • ✓Authorization, secrets and policy live in code, not prompts.
  • ✓Red-team the system, automate findings into regression tests.
Hands-on exercise

Threat-model on a whiteboard

  1. Pick an agent that reads email and can issue refunds; draw it and mark every untrusted input.
  2. List five attacks and for each the preventive, detective and corrective control.
  3. Answer 'how can an agent exfiltrate data?' in under 60 seconds with a concrete example.
  4. Write the policy table for its three most dangerous tools.
← MCP, Protocols & Multi-Agent QuestionsEvaluation, Observability & Production Questions →
0 / 11 finished0%