Authentication and secure AI APIs
Design application security around verified identity, authorization and untrusted inputs.
Verify identity on the server and restrict data access to the authorized user.
Interview questions
Choose a question to reveal its answer.
01MediumCoreHow does a backend verify an authenticated session?
Answer
How does a backend verify an authenticated session?
Validate a token using the identity provider's supported verification mechanism, including applicable signature, issuer, audience and expiry checks.
Reject a request that presents an expired or invalidly signed token.
02MediumCoreHow do you prevent users from accessing other users' records?
Answer
How do you prevent users from accessing other users' records?
Authorize every object access using the verified identity and applicable permissions; never trust a client-supplied owner ID.
Filter saved assessments by the authenticated user's identity.
def can_read(session, record):
return bool(session) and session['user_id'] == record['user_id']
# In production, obtain session from verified authentication.The caller cannot authorize access by supplying a different user ID.
03EasyCoreWhy must privileged API keys stay on the server?
Answer
Why must privileged API keys stay on the server?
A browser bundle is inspectable; exposing privileged keys grants capabilities outside intended application controls.
Use a server-only database credential for validated administrative operations.
04EasyCoreWhy validate model or API inputs server-side?
Answer
Why validate model or API inputs server-side?
Client checks can be bypassed; the server must enforce types, limits and business rules.
Reject an assessment request containing invalid option indexes.
05MediumHigh priorityHow do parameterized queries prevent SQL injection?
Answer
How do parameterized queries prevent SQL injection?
They separate data values from executable SQL syntax so user strings are not interpreted as SQL commands.
Bind an input user identifier rather than interpolating it into a query.
06HardHigh priorityWhat is CSRF and how can an application mitigate it?
Answer
What is CSRF and how can an application mitigate it?
CSRF induces a browser to send an authenticated unwanted request; defenses depend on session design and include origin checks, CSRF tokens and suitable cookie settings.
Reject untrusted-origin state-changing requests where cookie authentication is used.
07MediumHigh priorityWhat is XSS and why is generated content a potential risk?
Answer
What is XSS and why is generated content a potential risk?
XSS executes attacker-controlled script in a user's browser when unsafe content is interpreted as code.
Render model output as escaped text or sanitize allowed markup.
08MediumHow would you protect an expensive model API from abuse?
Answer
How would you protect an expensive model API from abuse?
Enforce per-user quotas, bounded inputs, concurrency limits, timeouts and cost monitoring.
Limit request size and number of inference calls per user.
09MediumWhat information belongs in a security audit log?
Answer
What information belongs in a security audit log?
Record relevant action, actor, time and outcome while minimizing personal data and excluding secrets.
Record unauthorized tool requests without storing raw credentials.
10HardWhy is row-level security useful even with server-side checks?
Answer
Why is row-level security useful even with server-side checks?
Database policies add an independent boundary to appropriate access paths; privileged service roles require explicit server controls.
Restrict ordinary database reads to rows owned by a verified user.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.