Skip to content

Interview question · Cloud, Container & AI Infrastructure Security

Threat-model an LLM inference API that receives untrusted input at scale.

Every layer parses something an attacker wrote, every request costs real money, and tenants share hardware. Walk the path and price each risk.

hardEssentialNewPreparation tags: OpenAI, Anthropic, GoogleUpdated Nov 2026

TL;DR: Walk the request path and threat-model each layer. Gateway: stolen or shared keys and cost exhaustion; per-key and per-tenant token, rate and spend limits. Input processing: parsers for text, images, audio and documents, plus tokenizers, all attack surface; patch, sandbox and size-limit. Model server: framework vulnerabilities, unsafe model loading, exposed debug and management endpoints. Shared state: prefix caches, batching and GPU memory across tenants; scope per tenant. Logs: sensitive prompts retained broadly. Outputs and API as oracle: extraction, abuse at scale. Weights: protected on serving nodes. Assign deterministic controls to each and abuse detection across all.

How to approach it

Clarify scope: is this a public multi-tenant API, an internal platform, or a single application's backend? Does it serve customer-uploaded models? Then draw the path, take each component through STRIDE, and prioritise by impact and likelihood. Interviewers expect cost and tenancy to feature prominently.

A strong answer

FIG · THREAT-MODELLING AN INFERENCE API · LAYER BY LAYER
Untrusted input at scale, expensive compute behind it

Gateway

keys, cost limits

Input processing

parsers, tokenizers

Scheduler

batching, isolation

GPU serving

memory, side channels

Outputs and logs

leakage, retention

Main threats

Stolen keys, cost exhaustion

  • Per-key token, rate and spend limits

Parser bugs

  • Patch, sandbox, size-limit

Cross-tenant leakage

  • Batch and cache isolation

Assets. Customer prompts and outputs (confidential), model weights, service availability and spend, tenant isolation, provider reputation and abuse obligations.

Adversaries. Abusive customers, attackers with stolen keys, competitors attempting extraction, tenants probing other tenants, and remote attackers targeting exposed infrastructure.

Threats and controls by layer.

LayerKey threatsControls
Gateway and authStolen keys; key sharing; cost exhaustion; enumerationScoped, rotatable keys; per-key and per-tenant token, request and spend limits; anomaly detection; key leak scanning
Request validationHuge prompts, max-length generations, many parallel streamsHard caps on input and output tokens, timeouts, concurrency per tenant
Input parsersMalformed images, audio, PDFs; decompression bombs; tokenizer edge casesPatched, sandboxed parsers with size and type limits; fuzzing
Model serverFramework CVEs; unsafe model loading; debug endpointsPatch SLAs; minimal images; safetensors-only loading; no debug or management endpoints exposed
Shared stateCross-tenant leakage through prefix caches (timing), batch interference, GPU memory residuePer-tenant cache scoping; dedicated capacity for sensitive tenants; memory clearing
Management planeExposed dashboards, job APIs, metrics with sensitive labelsPrivate networks only, authentication, network policy
Logs and telemetryPrompts with personal data, long retention, broad accessRedaction, short retention, access control, customer opt-outs
Outputs / oracleModel extraction; large-scale abuse generationRate limits, usage-pattern detection, policy enforcement
Weights on nodesTheft from serving hostsNo interactive access, egress limits, encrypted storage with controlled keys

Prioritisation. Cost exhaustion and key abuse are high likelihood and immediate impact; exposed management planes are low effort for attackers and catastrophic; cross-tenant cache leakage is lower likelihood but high impact for confidential workloads; parser bugs depend on input modalities.

Customer-uploaded models. If tenants can bring their own models or adapters, loading becomes untrusted code execution risk: isolate per tenant, safe formats only, no remote code.

Detection and response. Per-tenant usage baselines, alerts on spend spikes and unusual patterns, ability to revoke keys and throttle tenants instantly.

FIG · BYPASSED VS PROTECTED · PUBLIC INFERENCE API
Keys without limits and shared batching versus quotas and tenant isolation

Open API

Leaked key, no quotas

unlimited tokens

Cost explosion, extraction

batching leaks

Bill and data exposure

Outcome, unsafe: Model copied

Tenants mixed

Controlled API

Per-key, per-tenant budgets

abuse detection

Isolated batching and caches

sandboxed parsers

Abuse capped

Outcome, safe: Tenants isolated

Extraction detected

What interviewers probe next

  • "A tenant wants guaranteed isolation from others. What do you offer?" Dedicated capacity with no shared caches or GPUs, separate logging, and contractual retention terms.
  • "How do you detect extraction?" High-volume, systematic, diverse queries from a key, especially with logit or probability outputs; rate limits and restricting such outputs help.
  • "What's your first week of work?" Inventory internet-exposed endpoints, enforce limits at the gateway, confirm management planes are private, and set a patch process for serving frameworks.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A public LLM inference API accepts text, images and documents from many customers at scale.

  1. Start here

    What threats sit at the gateway?

How it's scored

Weak: Focuses on prompt injection in the abstract.

Hire: Walks the layers with concrete controls, including quotas and parser risks.

Strong Hire: Prioritises by likelihood and impact, covers multi-tenancy and shared caches carefully, the management plane, customer-uploaded models, and detection and response.

Common mistakes

  • Ignoring cost as an attack vector.
  • Sharing prefix caches across tenants without considering leakage.
  • Exposing dashboards or job APIs "temporarily".
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.