Security Interview Questions (with real STAR answers)

The security interview questions that come up most, from junior to senior - OWASP vulnerabilities, authentication, cryptography, cloud IAM, and incident response. Short model answers for the technical questions, and STAR answers for the "tell me about a time" questions, built from real production work you can do yourself.

Get started - freeLive cloud workspace in your browser · nothing to install

Security interviews mix technical questions, incident scenarios, and behavioral questions. This page covers the questions that come up most, from junior to senior: behavioral questions with STAR answers built from real production work you can do yourself, then technical and scenario questions with short model answers.

Security behavioral interview questions (STAR answers)

Tell me about a time you found and fixed a vulnerability.

Situation: A search endpoint built its SQL by string concatenation, which left it open to SQL injection.
Task: I had to close the hole without breaking search for normal users.
Action: I reproduced the injection with a payload like ' OR 1=1 --, then rewrote the query with parameterized statements so user input could never change the SQL.
Result: The injection was gone, and I checked nearby endpoints for the same pattern.

Go earn this story: Close a SQL Injection in a Search Endpoint →

Tell me about a time you hardened authentication.

Situation: User passwords were stored in plaintext, so a single database leak would expose every account.
Task: I needed to change how passwords were stored and move existing users over safely.
Action: I switched to bcrypt with a per-password salt and a suitable cost factor, and handled existing records so logins kept working during the transition.
Result: Passwords could no longer be read from the database, which closed a serious exposure.

Go earn this story: Hash Passwords Instead of Storing Plaintext →

Tell me about a time you dealt with a leaked secret.

Situation: Credentials were hardcoded in the source code and had been committed to the repository.
Task: I had to remove the exposure and stop it from happening again.
Action: I rotated the exposed values first, moved the secrets into a managed secret store, and changed the app to read them from the store at runtime.
Result: The live secret was no longer in the code, and new secrets followed the same pattern instead of being hardcoded.

Go earn this story: Remove Hardcoded Credentials From Source Code →

Tell me about a time you found an access control problem.

Situation: An invoice endpoint took an invoice id from the URL and returned it to any logged-in user, so changing the id showed other customers' invoices (an IDOR).
Task: I had to make sure each user could see only their own data.
Action: I added an ownership check on the server - the query now filters by both the invoice id and the current user's id - and returned 404 for invoices the user does not own.
Result: Users could no longer read other customers' invoices, and the same check became part of our code review list for every endpoint that takes an id.

Go earn this story: Fix an IDOR Exposing Other Users' Invoices →

Tell me about a time you responded to a security incident.

Situation: The secret used to sign our JWTs was leaked, so anyone holding it could create valid tokens.
Task: I had to stop forged tokens quickly without logging out every user at once.
Action: I generated a new signing key and supported both keys for a short window using a key id (kid) in the token header: new tokens were signed with the new key, old tokens were still accepted until they expired, and then the old key was removed.
Result: Forged tokens stopped working after the window, and users were not forced to log in again.

Go earn this story: Rotate a Leaked JWT Secret Without Logout →

Tell me about a time you pushed for least privilege.

Situation: Several AWS IAM policies used wildcards such as Action: '*' and Resource: '*', so a compromised service could do almost anything in the account.
Task: I had to reduce the permissions without breaking the services that used them.
Action: I checked which actions each service really called, replaced the wildcards with specific actions on specific resource ARNs, and tested each service after the change.
Result: Each service had only the access it needed, so a compromised credential could do far less damage.

Go earn this story: Tighten Over-Permissive AWS IAM Policies →

Security technical and scenario interview questions

What is the OWASP Top 10?

A list from OWASP of the most critical web application security risks. It includes broken access control, injection, cryptographic failures, security misconfiguration, vulnerable and outdated components, authentication failures, and server-side request forgery (SSRF). Be ready to explain a few and how to prevent them.

How do you prevent SQL injection?

Use parameterized queries or prepared statements so user input is always treated as data, never as SQL. ORMs do this by default. Add input validation and run the database user with the least privileges it needs. Never build SQL with string concatenation.

What is cross-site scripting (XSS), and how do you prevent it?

XSS is when an attacker gets their JavaScript to run in another user's browser. It can be stored (saved in the database), reflected (from the URL), or DOM-based. Prevent it by encoding output for the context it appears in, using frameworks that escape by default, sanitizing any HTML you must allow, and adding a Content Security Policy.

What is CSRF, and how do you prevent it?

Cross-site request forgery tricks a logged-in user's browser into sending a request to your site, because the browser attaches cookies automatically. Prevent it with SameSite cookies (Lax or Strict), anti-CSRF tokens on state-changing requests, and by never changing data on GET requests.

What is the difference between hashing, encryption, and encoding?

Encoding (for example Base64) changes the format and anyone can reverse it - it is not security. Encryption (for example AES) is reversible with a key and protects confidentiality. Hashing (for example SHA-256) is one-way and is used for integrity checks; for passwords, use a slow password hashing function.

How should passwords be stored?

Never in plaintext or with fast hashes like MD5 or SHA-1. Use a slow, salted password hashing algorithm - Argon2id, bcrypt, or scrypt - with a cost factor high enough to slow down brute force. The salt is unique per password and is stored with the hash.

What is the difference between symmetric and asymmetric encryption?

Symmetric encryption (AES) uses one shared key to encrypt and decrypt, and it is fast. Asymmetric encryption (RSA, elliptic curve) uses a public key and a private key, and is used for key exchange and digital signatures. TLS uses asymmetric cryptography to agree on a symmetric key, then encrypts the data with it.

What happens in a TLS handshake?

The client and server agree on the TLS version and cipher suite, the server sends its certificate, and the client checks that it is valid and issued by a trusted certificate authority for that hostname. They then do a key exchange (usually ECDHE) to create shared session keys, and all further data is encrypted with them.

What is the difference between authentication and authorization?

Authentication checks who you are (password, token, MFA). Authorization checks what you are allowed to do. Many serious bugs are authorization bugs, such as IDOR, where the user is logged in but can reach data that belongs to someone else.

What is SSRF, and how do you prevent it?

Server-side request forgery is when an attacker makes your server send requests to a URL they choose, often internal services or the cloud metadata endpoint (169.254.169.254). Prevent it with an allowlist of hosts, by resolving the hostname and blocking private and link-local IP ranges, by not following redirects blindly, and by using IMDSv2 on AWS.

What are common JWT security mistakes?

Accepting the 'none' algorithm or any algorithm the token claims, using a weak or shared signing secret, not checking expiry, putting sensitive data in the payload (it is only encoded, not encrypted), and storing tokens in localStorage where XSS can read them. Pin the algorithm and validate exp, iss, and aud.

What is the CIA triad?

Confidentiality (only authorized people can read data), Integrity (data is not changed without authorization), and Availability (systems and data are there when needed). Most security controls protect one or more of these three.

Scenario: a developer pushed an AWS access key to a public GitHub repository. What do you do?

Treat the key as compromised. Deactivate and rotate it right away, then check CloudTrail for activity from that key and look for new users, roles, or resources. Remove the key from git history with git filter-repo and force-push, but assume it was already copied. Then add secret scanning such as gitleaks in pre-commit hooks and CI.

Scenario: a scanner reports a critical CVE in a dependency. What do you do?

Confirm that the vulnerable version is really in use and whether the vulnerable code path is reachable. Upgrade to a patched version (or apply a workaround if none exists), run the tests, and deploy. Use tools such as Trivy, pip-audit, or npm audit in CI so new vulnerable versions are caught before release.

What questions are asked in a security interview?

Expect behavioral questions (tell me about a time you...), technical questions on OWASP vulnerabilities, authentication, cryptography, and cloud permissions, and incident scenarios such as a leaked key. Some companies also ask you to review code for vulnerabilities. The questions on this page cover all of these.

How do you answer behavioral interview questions?

Use STAR: Situation, Task, Action, Result. Keep it concrete - a specific incident, what you owned, what you did, and the result. The answers above are all structured this way.

More for Security engineers

Security projectsSecurity roadmapResume projectsCareer guide

Do real production work, free. Live cloud workspaces in your browser - every project you complete lands on your portfolio.

Get started - free
Get started - free