Skip to main content

During a review you find the LLM provider's API key inside your company's mobile app, and a database password written in the system prompt. What do you do?

AI security · Intermediate 2

Short answer

Treat both as leaked. Revoke and rotate the key and the password now, and check usage and billing logs for abuse. Then fix the design: the app calls our backend, which holds the key in a secret manager and adds authentication, rate limits and spend caps. Nothing secret goes in a prompt, because prompts can be extracted.

Deeper answer

Anything shipped to a user's device can be read by that user: a key in an app is public, whatever obfuscation is used. Attackers look for such keys to run their own workloads on someone else's bill. A system prompt is not a safe place either. Users can often make the model repeat it, and the OWASP Top 10 for LLM applications lists system prompt leakage as a risk. A database password there could give direct access to data.

Order matters. First contain: rotate, then review logs for unknown IP addresses, unusual volume or unusual database queries, and treat it as an incident if there are signs of use. Then redesign: a backend proxy holds the key; each user is authenticated; limits apply per user; the model reaches data only through a narrow service with its own least-privilege credentials. Then prevent: secret scanning in CI and on the built app, separate keys per environment, and budget alerts. Interviewers listen for rotate first, then the architecture fix.

What a strong answer covers

Answer it out loud in the mock interview about 2 min

Follow-ups to expect

Common mistakes

Learn it

Security and privacy

Practice AI security questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.