lessons/interview-questions.md

Lesson 18 of 18

Interview questions, from junior to senior

The questions you will be asked, with model answers that show the method, not just the facts.

Remember: Answer every question with the same chain: context, source and sink, the missing control, impact, the fix at the root cause, a test, and a guardrail.

Interviewers grade how you think, not what you can recite. A good answer is short, names the real risk for the business, and ends with how you would prevent the same bug from coming back. Use the chain below for every answer, and say it out loud: context, source and sink, control, impact, fix, test, guardrail.

Junior: the basics, done properly

Q: What is SQL injection, and how do you fix it? A: Untrusted input becomes part of the SQL text, so the attacker can change the query. Fix it with parameterised queries, so the driver sends the value separately. Identifiers such as column names cannot be parameters, so map them through an allowlist. Test it by sending a quote and an always-true condition to a staging copy.

Q: Authentication versus authorisation? A: Authentication proves who the caller is. Authorisation decides whether that caller may act on this specific object. A valid session passes authentication and can still fail authorisation, which is exactly how IDOR happens.

Q: Why is client-side validation not a control? A: Any client can send any request directly to the API, so the browser's checks protect only the user experience. The server must validate type, range and meaning on every request.

Q: What is XSS, and what does React do about it? A: Data written by one party is interpreted as HTML or script by another party's browser. React escapes text by default. It stops being protective with dangerouslySetInnerHTML, href values built from input, and unvalidated URLs.

Q: How do you store passwords? A: With a slow, salted, memory-hard function such as Argon2id, verified with the library's constant-time check. Never with a fast hash such as SHA-256 or MD5, and never reversibly encrypted.

Mid-level: find it, prove it, fix it

Q: Walk me through reviewing an endpoint that moves money. A: Context first: amount, currency, both accounts, who may call it. Then trace the sources (body, id, headers, token claims) to the sinks (the balance update, the ledger, the outbound call). Check the controls in between: authentication, ownership in the query, amount validation, a single atomic statement with a row-count check, idempotency, and an audit entry. Finish with the failure path: what state is left if step two fails?

Q: How do you find IDOR in an API when you have a valid token? A: Build a test matrix: user A, user B, an administrator, and no token. Every object id that user A can read or change must be refused for user B. Check the list endpoints too, because they often skip the owner filter. Automate the matrix in the test suite.

Q: What can go wrong with JWTs? A: Unverified signatures, an algorithm chosen by the token (alg none, or a public key used as an HMAC secret), missing expiry so tokens live forever, roles trusted from the token instead of the database, and tokens stored where any script can read them. Keep access tokens short, rotate refresh tokens, and keep a revocation list.

Q: Why is SSRF dangerous in the cloud, and how do you reduce it? A: The server can reach the metadata service, which hands out temporary credentials to anything that asks from inside. Use IMDSv2, which needs a session token obtained with a PUT request, enforce an allowlist of destinations, block redirects to internal ranges, and give the instance role the least privilege it needs.

Q: A dependency has a critical CVE you cannot upgrade today. What do you do? A: Confirm exposure: is the vulnerable function reachable from our code and from the internet? Add a compensating control, such as a WAF rule, a feature flag, or disabling the path. Set a deadline for the upgrade, and record the risk acceptance with a named owner if the deadline is not met.

Q: Explain a race condition in a payment flow and its fix. A: A check and a write run as separate steps, so parallel requests all pass the check. Fix it with one atomic conditional update, check the affected row count, and do the credit in the same transaction. Prove it with a test that sends twenty parallel requests and checks the final balance.

Senior: programmes, trade-offs and incidents

Q: How do you roll out SAST across two hundred teams without slowing them down? A: Start in observe-only mode to measure noise. Block only high-confidence rules on new code, using diff-aware scanning. Write custom rules for the internal frameworks, because generic rules miss them. Track false-positive rate and fix time, and move a rule to blocking only when it is precise enough to trust.

Q: How do you measure whether the AppSec programme works? A: Mean time to remediate by severity, the false-positive rate of scanners, guardrail adoption (the share of repositories with SAST, dependency scanning and secret scanning on), and recurrence: whether the same class of bug keeps appearing in pentests and bounty reports. Output metrics matter less than whether the classes are disappearing.

Q: A product owner refuses to fix a P1 before launch. What do you do? A: Explain the business risk in their terms, such as money moved or data exposed. Offer the fastest fix, or a compensating control that can ship today. If they still choose to launch, record a risk acceptance signed by the accountable owner, with a deadline and a follow-up. Never just say no.

Q: Design the security of a payments service that calls internal microservices. A: Authenticate every service-to-service call with mTLS or signed short-lived tokens, and propagate the end user's identity so each service can authorise the object. Enforce idempotency keys on every money movement, write an append-only audit log, apply least privilege to each service's database role, and make secrets come from a secret manager.

Q: How would you threat model a QR-code transfer feature? A: Draw the flow from the app to the API gateway, the payments service and the external provider. Apply STRIDE to each arrow: spoofed QR codes, tampered amount or IBAN in transit, no audit trail for disputes, data leaked in logs, floods of QR generation, and standard accounts reaching business limits. Then decide the controls: signed payloads, strong customer authentication that binds the code to the amount and payee, and rate limits.

Q: You discover that customer data has been exposed for three months. What happens in the first 24 hours? A: Contain the exposure first, without destroying evidence. Confirm the scope: which data, how many customers, which period. Involve legal and the data protection officer. Under GDPR, where the breach is likely to risk people's rights, notify the supervisory authority within 72 hours, and tell affected people without undue delay when the risk is high. Then find the root cause, fix it, and turn the lesson into a guardrail.

Close the interview with questions that show judgement: What is the hardest security trade-off the team is making this quarter? How are developers involved in threat modelling? What does a bad week for the AppSec team look like?

Questions to ask yourself

  1. Can you name the source, the sink and the missing control in your answer?
  2. What is the business impact, in money or data?
  3. What is the fix at the root cause, and how do you stop the whole class coming back?