Careers / Prep packs

Senior level

LLM and GenAI Engineer interview questions and prep

Senior LLM/GenAI engineers build production systems that safely prompt large models, retrieve data via RAG, evaluate outputs, enforce guardrails, and balance cost with latency. Interviews test deep knowledge of LLM attack surfaces, system design for safety and performance, and ability to ship secure, evaluated applications under real constraints.

  • 30 questions
  • 8 skills
  • 10 labs

Skills this role needs

  • Prompt injection attack & defenseCore vulnerability in LLM apps; engineers must recognize and block multi-stage, encoded, and indirect injection vectors.
  • RAG security and poisoningRetrieval systems are attack entry points; must secure ingestion, embedding, retrieval ranking, and cross-tenant isolation.
  • Agent hijacking and tool controlLLM agents with tool access create new threat models; engineers must design permission boundaries and validate tool calls.
  • Output validation and safetyModel output is untrusted; must implement schema validation, filter XSS/SQL injection paths, and handle agent-generated credentials.
  • Evaluation and guardrailsSenior role requires designing metrics to catch failures, red-teaming applications, and implementing runtime guards.
  • LLM cost and latency optimizationProduction systems must balance safety with performance; senior engineers trade off token count, caching, and model choice.
  • Memory and state managementPersistent agent memory, chat history, and context windows create injection, poisoning, and leakage risks at scale.
  • System design for multi-agent and supply chainComplex systems with spawned agents, MCP tools, and third-party dependencies require threat modeling across boundaries.

Labs to practise

Hands-on labs on this site that match the work in this role. They run in the browser.

Courses that help

Tutorials to read

30 interview questions

Answer in your own words first, then open what a strong answer covers. Sign in to practise with AI feedback.

  1. You are designing a RAG system for a financial advisor chatbot. Walk through how you would secure the ingestion pipeline, retrieval ranking, and embedding storage to prevent both poisoning and cross-tenant data leakage.

    What a strong answer covers
    • RAG poisoning vectors (document upload, indexing, retrieval)
    • Embedding cache isolation and multi-tenancy
    • Data validation at ingestion vs. query time
  2. Your team built a system prompt into the model context, and a user tried 20 different jailbreak techniques to extract it. What patterns would you look for in logs, and what guardrail would you add to make extraction attempts detectable or costly?

    What a strong answer covers
    • Jailbreak detection (frequency, encoding, role-play patterns)
    • Rate limiting and anomaly detection on prompt-attack signals
    • System prompt hardening (refusal, circular context, decoys)
  3. Describe a production incident where an LLM agent with database access was tricked into running a query it shouldn't have. What permission model and tool-call validation would you deploy to prevent similar hijacks?

    What a strong answer covers
    • Agent permission boundaries and least-privilege tool access
    • Tool call validation, approval workflows, and human-in-the-loop
    • Logging and sandboxing for tool execution
  4. Your chatbot renders LLM output as HTML in a web UI. An adversary crafted a prompt that makes the model output an HTML payload. Walk through the attack surface: where does the injection occur, and what defenses belong at each layer?

    What a strong answer covers
    • LLM-output injection (model→HTML rendering pipeline)
    • Output schema validation, HTML escaping, and content-security-policy
    • Separation of model data from executable content
  5. You need to evaluate whether a new model checkpoint is safe for production. Describe your red-teaming and evaluation strategy, including how you'd measure refusal rate, jailbreak resilience, and false-positive guardrail triggers.

    What a strong answer covers
    • Automated and manual red-teaming (prompt injection, role-play, encoding)
    • Metric design (refusal rate, false-positive cost, latency impact)
    • A/B testing guardrails without poisoning production logs
  6. Your system uses a shared embedding cache to speed up RAG retrieval across all users. A researcher shows you a timing side-channel that leaks which documents other users queried. How would you detect and patch this vulnerability without rebuilding the cache?

    What a strong answer covers
    • Cross-tenant cache leakage via timing, side channels, or state reuse
    • Cache isolation, per-user cache keys, and timing-safe operations
    • Trade-off between performance and isolation (padding, bucketing)
  7. An attacker crafts a PDF with hidden Unicode characters that, when summarized by your LLM, causes it to leak a secret from its context window. Explain the attack chain and design an ingestion filter to block it.

    What a strong answer covers
    • Hidden character and visual prompt injection (Unicode, zero-width, invisible markup)
    • Document preprocessing, Unicode normalization, and redaction of context
    • Testing adversarial documents without manual review overhead
  8. Your agentic system spawns sub-agents dynamically. A user discovers they can send a message that gets forwarded to a child agent in a way that makes the child misinterpret the user's command as a system instruction. What's the fix?

    What a strong answer covers
    • Multi-agent message passing and instruction confusion
    • Explicit boundary markers (agent cards, instruction separation)
    • Logging and replay detection for recursive hijacks
  9. You're reviewing a code change generated by an AI coding assistant. The assistant produced a function that parses user input directly into a database query and passes generated tokens to the auth layer. List the flaws and explain how you'd enforce these checks in CI/CD.

    What a strong answer covers
    • AI-generated code vulnerabilities (injection, token forgery, schema bypass)
    • AI-aware security scanning (detecting LLM output trust, hallucination)
    • CI/CD rules for LLM-generated code review and dependency verification
  10. Your chatbot supports file upload and uses the uploaded document as context for LLM queries. An attacker uploads a file containing an indirect prompt injection (instructions hidden in a table or summary). How does the attack work, and what's your defense?

    What a strong answer covers
    • Indirect injection via RAG (document→context→prompt)
    • Data vs. instruction separation, document provenance tracking
    • Redaction and sanitization of untrusted document context
  11. You need to reduce inference latency for a high-volume RAG chatbot without sacrificing safety. Propose a caching and batching strategy that works with your guardrails. What guardrail checks are safe to skip, and what must stay?

    What a strong answer covers
    • Latency optimization (prompt caching, batch processing, model selection)
    • Cost vs. safety trade-offs (which guardrails are non-negotiable)
    • Cache invalidation and guardrail consistency across batches
  12. A user discovers that by sending the same prompt across multiple conversations, they can average out your refusal guardrail and get the model to eventually comply. How would you detect and block this attack pattern?

    What a strong answer covers
    • Cross-conversation adversarial patterns (repetition, gradual escalation)
    • Anomaly detection and rate limiting across user sessions
    • Memory poisoning prevention and conversation isolation
  13. Your system maintains persistent agent memory (conversation history, learned user preferences). An attacker poisons the memory with false instructions that influence future queries. Design a defense that doesn't require discarding all history.

    What a strong answer covers
    • Memory poisoning via tool output or user message injection
    • Memory versioning, audit trails, and rollback mechanisms
    • Per-statement memory validation and instruction vs. data separation
  14. You're integrating a third-party MCP tool that your LLM agent will use autonomously. The vendor-provided tool description is lengthy and includes examples. What's the attack surface, and what validation would you add before connecting it?

    What a strong answer covers
    • Tool poisoning via description, examples, and return values
    • Tool sandboxing, permission boundaries, and schema validation
    • MCP security review (rogue servers, tool deserialization, hidden side effects)
  15. Your LLM agent has a function that fetches URLs from the internet to answer user questions. An adversary tricks the agent into making requests to internal services (SSRF). Walk through the attack and your mitigation.

    What a strong answer covers
    • LLM-driven SSRF via agent tool misuse
    • URL allowlist/denylist, DNS validation, and request filtering
    • Agent instruction clarity and tool scoping (no internal URLs in instructions)
  16. You need to implement an approval workflow where a human reviews agent actions before they execute. An attacker finds a way to make the approval summary inaccurate so the human approves a harmful action. How would you design the approval loop to be tamper-proof?

    What a strong answer covers
    • Approval summary spoofing and human-in-the-loop bypass
    • Cryptographic integrity of approval payloads, action logging
    • Separation of approval message from actual action parameters
  17. Your system uses a fine-tuned model trained on proprietary data. An attacker discovers they can extract training examples word-for-word by carefully crafting prompts. What safeguards would you add during fine-tuning and deployment?

    What a strong answer covers
    • Training data extraction and memorization risks
    • Differential privacy, data deduplication, and synthetic data techniques
    • Output filtering and membership inference defenses
  18. You're building a system that accepts a user's GitHub issue and generates code to resolve it. An attacker submits a poisoned issue that tricks the coding agent into introducing a vulnerability. Describe the attack and how you'd lock down the agent's execution environment.

    What a strong answer covers
    • Indirect prompt injection via external data (GitHub issues, comments, PRs)
    • Agent sandboxing, code review gates, and limited tool permissions
    • Separation of issue text from executable instructions
  19. Your chatbot uses embeddings to retrieve relevant documents from a large corpus. An attacker crafts a document with specific text that, when embedded, ranks highly for queries it shouldn't match (embedding poisoning). How would you detect and prevent this?

    What a strong answer covers
    • Embedding poisoning (adversarial text that manipulates retrieval ranking)
    • Embedding space validation, cosine similarity thresholds, and anomaly detection
    • Re-ranking with cross-encoders or semantic verification
  20. Your system context window is 4K tokens. A user figures out that by sending a very long prompt, they can push the system instructions out of the context window, changing the model's behavior. How would you mitigate context overflow attacks?

    What a strong answer covers
    • Context overflow and system prompt eviction
    • Prompt restructuring (always-on instruction prefix, attention anchoring)
    • Token budget enforcement and input length validation
  21. You need to log and audit all agent actions for compliance, but logging too much creates a performance bottleneck and privacy risk. Design a logging strategy that balances security, compliance, and performance.

    What a strong answer covers
    • Agent action logging without performance degradation
    • PII redaction and privacy-preserving audit trails
    • Log retention, tamper-proofing, and anomaly detection on logs
  22. Your chatbot integrates a calculator tool and a database query tool. An attacker crafts a prompt that makes the agent confuse the two tools, using the calculator interface to construct a database query. How would you prevent tool confusion?

    What a strong answer covers
    • Tool confusion and cross-tool parameter injection
    • Tool interface clarity, type validation, and schema enforcement
    • Agent instruction specificity and tool use logging
  23. You're designing a multi-tenant LLM service where each tenant has a custom system prompt. A user discovers they can craft a prompt that makes the model output another tenant's system prompt or data. How would you isolate tenants?

    What a strong answer covers
    • Multi-tenant isolation and cross-tenant prompt/data leakage
    • Per-tenant tokenization and embedding spaces
    • Instruction injection between tenants and context window boundaries
  24. Your system uses a large context window to include user chat history. An attacker injects false instructions into earlier messages, then queries. How would you distinguish legitimate history from injected instructions?

    What a strong answer covers
    • Memory poisoning via conversation history
    • Message origin tracking, cryptographic signing of historical messages
    • Instruction vs. data framing and boundary enforcement
  25. You need to ship a safety update (new guardrail) to production without retraining the model. Describe a deployment strategy that minimizes false positives while catching real harms.

    What a strong answer covers
    • Runtime guardrail deployment and canary rollout
    • Metric collection (false-positive rate, guardrail efficacy, latency)
    • Rollback strategy and guardrail versioning
  26. An LLM application processes multimodal input (text + images). An attacker hides a prompt injection in an image (text overlaid or steganographically embedded). Walk through the attack and how you'd defend it.

    What a strong answer covers
    • Visual prompt injection (text in images, steganography)
    • Image preprocessing, OCR validation, and content verification
    • Separation of image data from instructions
  27. Your system uses a knowledge base that's updated frequently by external sources. You discover that one source was compromised and injected false information. Design a process to detect, isolate, and remediate poisoned documents without manual review of the entire corpus.

    What a strong answer covers
    • RAG poisoning detection and remediation at scale
    • Document source validation and version control
    • Automated rollback, fact-checking, and anomaly detection in retrieval results
  28. You're evaluating a new LLM model for deployment. It's cheaper and faster but shows marginally higher refusal rates on benign queries. How would you decide whether the trade-off is acceptable, and what guardrails would you add to compensate?

    What a strong answer covers
    • Model selection trade-offs (cost, latency, safety, capability)
    • Guardrail calibration and false-positive measurement
    • A/B testing methodology to measure real-world impact
  29. Your agentic system uses a scratchpad (internal reasoning visible only to the agent) to plan multi-step tasks. An attacker learns the scratchpad format and crafts a prompt that corrupts it to exfiltrate secrets. How would you secure the scratchpad?

    What a strong answer covers
    • Agent scratchpad/plan injection and reasoning hijacking
    • Scratchpad format validation, encryption, and integrity checks
    • Instruction vs. data separation in agent working memory
  30. You're reviewing a prompt that includes examples of desired behavior (few-shot prompting). An attacker discovers they can add a malicious example that overwrites the intended behavior. Design a prompt structure that's robust to example injection.

    What a strong answer covers
    • Many-shot jailbreaking and example-based instruction confusion
    • Prompt structure (preamble, examples, instruction, input boundaries)
    • Robustness testing of few-shot prompts against adversarial examples

A 14-day preparation plan

  1. Days 1 to 3Complete OWASP Top 10 for LLM Applications course (5628) to map the full LLM threat landscape. Simultaneously work through OWASP reading (4361) on modern pentesting. Practice hands-on with foundational prompt injection labs: prompt-injection-1, ai-role-confusion-1, ai-system-leak-1. Focus on understanding how instructi
  2. Days 4 to 7Take Prompt Injection From Zero course (5533) for attack-and-defend depth. Work through advanced jailbreak labs: ai-encoding-jailbreak-1, ai-jailbreak-roleplay-1, ai-many-shot-jailbreak-1. Read the AI Agent Hijacking lab (5157) and Tool-Output Injection lab (5158). Design a prompt-hardening exercise using ai-review-pro
  3. Days 8 to 11Take Securing AI Agents and MCP course (5537) to master agent threats. Work through agent-specific labs: ai-plan-injection-1, ai-agent-hijack-1, ai-token-smuggling-1. Read the Confused Deputy (5160) and SSRF (5161) lab documents. Practice RAG security via ai-review-rag-ingestion-1 and ai-embedding-poisoning-1. Build me
  4. Days 12 to 14Synthesize learning by reviewing system-design questions: design a multi-tenant RAG system, harden a production agent, and trade off cost/latency/safety. Work through output validation labs: ai-review-output-sinks-1, ai-output-schema-bypass-1. Read the AI Recon and AI Assessment readings (4372, 4418). Create a personal

These questions are SecurityElites practice material for this kind of role. They are not taken from any employer, and a real interview may differ.