Web Security Senior cheat sheet: interview answers
Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.
1. What does the STRIDE model help you do?
Correct answer: Find threats by category, like spoofing and tampering
Going through each category for every component and data flow makes it less likely that a whole class of threats is missed.
2. When is threat modeling most useful?
Correct answer: During design, and again when the architecture changes
Design flaws like trusting a client-side role are cheap to fix on a whiteboard and expensive in production.
3. What is the core idea of zero trust architecture?
Correct answer: No trust from network location: every request is verified
Being inside the VPN or cluster doesn't make a call trusted. Services check identity and permissions on each request.
4. What is OWASP ASVS used for?
Correct answer: A detailed list of verifiable security requirements by level
The Top 10 raises awareness; ASVS is a checklist you can build requirements and test plans from.
5. Why are secure defaults important in a shared internal library or framework?
Correct answer: Most developers use the default, so a safe one protects everyone
Auto-escaping templates and
HttpOnlysession cookies by default prevent entire bug classes. Unsafe options should need explicit, visible opt-in.6. A team adds a new data flow: the browser uploads files that a background worker processes. Which question is most important for the threat model?
Correct answer: What can a malicious file do to the worker, and what can it reach?
Parsers for images, PDFs and archives are a common attack surface. Isolate the worker and give it minimal permissions.
7. What does "blast radius" mean in security design?
Correct answer: How much an attacker reaches after one compromise
Separate accounts, scoped tokens, network segmentation and per-service databases keep one breach from becoming a full compromise.
8. How do you roll out Trusted Types in a large existing app?
Correct answer: Start in Report-Only mode, fix reported sinks, then enforce
Report-only shows every place that passes strings to sinks. A small number of named policies (
trusted-typesdirective) keeps the review surface small.9. What is a script gadget?
Correct answer: Legitimate code that turns harmless injected markup into execution
Gadgets in frameworks and libraries can bypass sanitizers and some CSPs, because the code doing the work is trusted.
10. What is mutation XSS (mXSS)?
Correct answer: Sanitized HTML changes when re-parsed and becomes executable
Differences between the sanitizer's parse and the browser's (for example around
<noscript>, SVG or MathML) can be exploited. Sanitize with the browser's own parser and keep the library up to date.11. What does the HTML Sanitizer API (
setHTML) offer compared with a JavaScript sanitizer library?Correct answer: Sanitization built in, using the parser that renders the HTML
Using the browser's parser avoids parser differences behind mXSS. Until it's available in all target browsers, libraries like DOMPurify are still needed.
12. What is dangling markup injection?
Correct answer: An unclosed tag captures later page content into a URL, leaking it
It works even when CSP blocks scripts. Contextual encoding prevents it; restrictive
img-srcandform-actionreduce the impact.13. A policy uses a nonce, but the HTML page is cached by a CDN and served to many users. What's wrong?
Correct answer: Everyone gets the same nonce, so an attacker can learn it
Nonces must be unique per response. For cached pages use hash-based CSP or don't cache the HTML.
14. Why can a CSP allowing
https://cdn.jsdelivr.netbe bypassed?Correct answer: Anyone can publish a package there and load their own script
Public CDNs and domains with JSONP endpoints make host allowlists unsafe. Pin with SRI or move to nonces with
'strict-dynamic'.15. What does
require-trusted-types-for 'script'actually enforce?Correct answer: Sinks like
innerHTMLthrow when given a plain stringA default policy can be defined as a migration aid, but it should sanitize or reject, not pass everything through.
16. In a design system, a
<RichText html={...} />component wrapsdangerouslySetInnerHTML. What's the most robust approach?Correct answer: Sanitize inside the component so callers can't pass raw strings
Putting the safety check at the single sink makes the safe path the default. Types and lint rules can block direct
dangerouslySetInnerHTMLelsewhere.17. Why can XSS through
postMessagehappen even on a site with strict CSP?Correct answer: The trusted handler passes the data to a sink, so nonces don't help
CSP blocks new scripts, not your own code doing something dangerous. Trusted Types catch string-to-sink flows like this.
18. What is a good way to handle CSP violation reports at scale?
Correct answer: Collect them at an endpoint, deduplicate and filter the noise
Reports from browser extensions and injected adware are common. Grouping helps spot real regressions or attack attempts.
19. Which is the main remaining risk once a strict nonce CSP and Trusted Types are in place?
Correct answer: Logic bugs, exfiltration without script and server-side attacks
These controls are strong against script injection, but they don't fix authorization bugs, CSRF, open redirects or HTML-only data leaks.
20. Which two headers make a page cross-origin isolated?
Correct answer:
Cross-Origin-Opener-PolicyandCross-Origin-Embedder-PolicyIsolation gives the page its own process and enables features like
SharedArrayBufferand precise timers, which need protection from Spectre.21. Why were
SharedArrayBufferand high-resolution timers restricted after Spectre?Correct answer: Precise timing lets a page read other origins' memory in-process
Cross-origin isolation guarantees no other origin's data is in the process, so those APIs are safe again.
22. What does
Cross-Origin-Opener-Policy: same-originprotect against?Correct answer: Cross-origin windows keeping a reference to your page
With COOP the browsing context group is split, so
window.openerbecomesnullacross origins.23. What are XS-Leaks?
Correct answer: Side channels that reveal a user's state on another site
Signals include timing, frame counts, error events and window lengths. Defenses are SameSite cookies, COOP, CORP and Fetch Metadata checks.
24. What does a resource isolation policy based on Fetch Metadata do?
if (req.headers['sec-fetch-site'] === 'cross-site' && !(req.headers['sec-fetch-mode'] === 'navigate' && req.method === 'GET')) { return res.status(403).end(); }Correct answer: Rejects cross-site requests except simple top-level navigations
Endpoints meant to be embedded or called cross-site (public APIs, images for other sites) need explicit exceptions.
25. What is site isolation in browsers?
Correct answer: Pages from different sites run in separate OS processes
It's a key Spectre mitigation in Chromium. It also means CORB/ORB can keep sensitive cross-site responses out of the renderer.
26. What does
Cross-Origin-Embedder-Policy: credentiallesschange compared withrequire-corp?Correct answer: No-CORS subresources load without cookies, needing no CORP
It makes cross-origin isolation easier to adopt with third-party images and scripts that don't send CORP.
27. What attributes should an iframe that shows untrusted user HTML have?
Correct answer:
sandboxwithoutallow-same-origin, ideally on another originallow-scriptstogether withallow-same-originon the same origin lets the framed code remove its own sandbox.28. Why do security teams serve user-uploaded content from a separate domain like
usercontent.example?Correct answer: It's a different site, so it can't read your cookies or storage
A separate registrable domain (not a subdomain) avoids same-site cookie sharing too. Large platforms use this sandbox domain approach.
29. What is the backend-for-frontend (BFF) pattern for SPA authentication?
Correct answer: A server part keeps tokens; the browser gets an
HttpOnlycookieTokens never reach JavaScript, so XSS can't steal them. The BFF proxies API calls and adds the access token on the server side.
30. Tokens kept only in memory in a SPA vs
HttpOnlycookies: what's the key trade-off?Correct answer: Memory avoids CSRF but not XSS; cookies hide tokens but need CSRF defense
Neither option survives XSS fully: the attacker can act in the page either way. The real difference is whether a token can be taken and used elsewhere.
31. What is refresh token reuse detection?
Correct answer: Reusing a rotated token revokes the whole token family
Either the legitimate client or an attacker used a stale token. Revoking everything forces a new login and cuts off the attacker.
32. What do sender-constrained tokens (for example DPoP) protect against?
Correct answer: A stolen token is useless without the client's private key
With DPoP, each request carries a proof signed by a key the client holds. A bearer token, in contrast, works for anyone who has it.
33. What is the JWT algorithm confusion attack (RS256 to HS256)?
Correct answer: An HS256 token signed with the public RSA key passes verification
If the library picks the algorithm from the token header, the public key becomes a shared secret. Pin the expected algorithm per key.
34. How are JWT signing keys rotated without logging everyone out?
Correct answer: Publish keys in a JWKS with
kidand accept the old key for a whileVerifiers look up the key by
kidfrom a trusted JWKS URL. Never fetch keys from a URL given inside the token (jku) without strict checks.35. Why are passkeys (WebAuthn) resistant to phishing?
Correct answer: The credential is bound to the origin, so fake domains can't use it
Even a perfect copy of the login page on another domain gets nothing usable. One-time codes, in contrast, can be relayed in real time.
36. Why is SMS considered a weaker second factor?
Correct answer: SIM swapping, interception and real-time phishing relay
SMS is better than no MFA, but authenticator apps and especially WebAuthn security keys or passkeys are stronger.
37. Which signals justify step-up authentication in the middle of a session?
Correct answer: Sensitive actions, or a new device or location
Asking again only when the risk is high keeps friction low while protecting the operations attackers care about.
38. How should "log out everywhere" be implemented with JWT access tokens?
Correct answer: Revoke refresh tokens and bump a per-user token version
Stateless tokens can't be recalled; the design either checks some state or relies on short access token lifetimes.
39. Why should login and password reset responses take about the same time for existing and unknown accounts?
Correct answer: Timing differences reveal which accounts exist
Hashing a password only for real users makes those requests slower. Run equivalent work or respond asynchronously.
40. How should a service compare a provided API key or HMAC signature with the expected value?
Correct answer: With a constant-time
crypto.timingSafeEqualEarly-exit comparison leaks how many leading characters match through timing, which can allow byte-by-byte guessing.
41. Which source of randomness should be used for session IDs and reset tokens in a browser or Node.js?
Correct answer: A CSPRNG, like
crypto.getRandomValues()Math.random()isn't designed to be unpredictable. Security tokens need a cryptographically secure generator.42. According to the OAuth 2.0 Security BCP (RFC 9700), who should use PKCE?
Correct answer: All clients, including confidential server-side ones
PKCE also protects confidential clients against code injection, so it's now recommended for every authorization code flow.
43. What is an OAuth mix-up attack?
Correct answer: The client is tricked into sending a code to an attacker's provider
Defenses include checking the
issparameter in the authorization response and using distinct redirect URIs per provider.44. How can an authorization code or token leak through the
Refererheader?Correct answer: The callback URL holds the code when third-party resources load
Redeem the code immediately, replace the URL with
history.replaceState, and set a strictReferrer-Policyon callback pages.45. What does the OIDC
nonceparameter protect against?Correct answer: Replay of an ID token, as the client checks its
nonceclaimThe
noncebinds the ID token to this particular authentication request and browser session.46. Why should API access tokens have a specific audience (
aud)?Correct answer: So a token for one API can't be replayed against another
Each resource server should reject tokens whose audience isn't itself. Otherwise a low-trust service can reuse tokens on a high-trust one.
47. Why does the OAuth BCP discourage the resource owner password credentials grant?
Correct answer: The client sees the user's password, which also blocks MFA
Users get trained to type passwords into third-party apps, and modern authentication steps can't be added.
48. An OAuth provider allows
redirect_uri=https://app.com/callback/../open-redirect?to=evil. What combination creates a token leak?Correct answer: Loose URI matching plus an open redirect leaks the code
Each bug alone may look minor. Exact matching on the provider and no open redirects on the client break the chain.
49. What is dependency confusion?
Correct answer: A public package with an internal name gets installed instead
Use scoped packages tied to a private registry, configure the registry per scope, and pin versions in the lockfile.
50. Why are npm
postinstallscripts a supply chain risk?Correct answer: They run arbitrary code as soon as a package is installed
Many real attacks steal tokens through install scripts.
--ignore-scriptswith an allowlist for packages that truly need them reduces the risk.51. What does npm package provenance give you?
Correct answer: A signed link from a package to its source and CI build
Provenance shows the package wasn't published from someone's laptop with a stolen token. It doesn't prove the code is good.
52. What is SLSA?
Correct answer: A framework of levels for build and artifact integrity
SLSA targets attacks like compromised build servers or swapped artifacts between build and release.
53. A script from a CDN is included with
<script src="https://cdn.example/lib@3.2.1.js">. What does addingintegrity="sha384-..."protect against?Correct answer: Running the file if its content changes on the CDN
Subresource Integrity works for versioned, immutable URLs. It requires CORS (
crossorigin) for cross-origin scripts.54. What's the main risk of loading many third-party scripts through a tag manager?
Correct answer: Vendor scripts get full page access, with no code review
Magecart-style card skimming often comes through compromised third-party scripts. Limit vendors, isolate them in iframes, or apply CSP.
55. How should automated dependency updates (Dependabot, Renovate) be handled safely?
Correct answer: Review PRs, batch minor updates and add a short cool-down
Never updating leaves known CVEs; updating instantly picks up freshly compromised versions. A short delay catches most malicious releases.
56. What is typosquatting in package registries?
Correct answer: Malicious packages named like popular ones, such as
reacttA single typo in
npm installcan run attacker code. Review new dependencies and their names before adding them.57. Which CI practice best limits the damage of a compromised dependency during builds?
Correct answer: Short-lived, narrowly scoped credentials and no secrets in untrusted jobs
Builds that install packages from the internet should assume some code is hostile. Separate publish and deploy steps with their own permissions.
58. Your server fetches a URL that users provide for link previews. What's the biggest risk?
Correct answer: SSRF: it can reach internal services or cloud metadata
Resolve the host, block private and link-local ranges after DNS resolution and on redirects, or route fetches through an isolated egress proxy.
59. Why is unsafe deserialization dangerous?
Correct answer: Parsing can create objects or run code, leading to RCE
Prefer data-only formats like JSON with schema validation. Avoid native object serialization of untrusted input.
60. What is ReDoS?
/^(a+)+$/.test(input)Correct answer: A regex with catastrophic backtracking blocks the event loop
In Node.js one slow regex freezes the whole process. Avoid nested quantifiers, limit input length, or use a linear-time regex engine.
61. Which rate limiting design suits a public login API best?
Correct answer: Limits per account and per IP, enforced at a shared layer
Per-IP alone fails against botnets, per-account alone enables lockout attacks. A shared store like Redis keeps limits consistent across instances.
62. What should never appear in application logs?
Correct answer: Passwords, full tokens, session IDs and payment data
Logs are copied to many systems and kept for a long time. Mask secrets at the logger, and log security events like failed logins.
63. What is the main benefit of a secrets manager over environment variables in a repo?
Correct answer: Central access control, audit logs and easy rotation
Short-lived, automatically rotated credentials limit the value of any leak. Audit logs show who read what.
64. Why should file uploads be validated by content and not just by extension?
Correct answer: Names and
Content-Typeare attacker-controlledStore files outside the web root with generated names, scan them, and never execute or serve them from your main origin.
65. What is BOLA in the OWASP API Security Top 10?
Correct answer: Broken object level authorization: ownership isn't checked
It's the API name for IDOR and has been the top API risk. Authorization checks belong in every handler or a shared policy layer.
66. Why does every Next.js Server Action need its own authorization check?
Correct answer: They're public HTTP endpoints that anyone can call directly
Checking the user on the page that renders the form isn't enough. Verify the session and permissions inside the action, and validate arguments.
67. What was the core issue in the 2025 Next.js middleware vulnerability (CVE-2025-29927)?
Correct answer: An internal header could skip middleware, bypassing its auth
The lesson: middleware is a convenient first gate, but authorization must also be checked close to the data, in route handlers, actions and data access code.
68. A React Server Component fetches a user record and passes the whole object to a Client Component. What's the risk?
Correct answer: All props are serialized, so private fields reach the browser
Use a data access layer that returns DTOs with only the needed fields. React's taint APIs can mark values that must never be passed to the client.
69. Why can server-side rendering reintroduce XSS that the client framework would prevent?
Correct answer: Server code building HTML strings bypasses framework escaping
Hand-written HTML in templates, metadata, or serialized state needs the same care. Use the framework's APIs instead of string concatenation.
70. An app sends user input to an LLM and shows the answer as HTML. Which risk does the OWASP LLM Top 10 list first?
Correct answer: Prompt injection: input makes the model ignore instructions
Treat model output as untrusted user input: encode or sanitize it, and don't give the model tools or data beyond what the user may access.
71. Where should authorization logic live in a full-stack framework app to be the most reliable?
Correct answer: In a data access layer that every read and write goes through
Centralizing checks next to the data means new pages, actions and APIs inherit them. UI and middleware checks are extra layers.
72. What does a CVSS score describe?
Correct answer: A vulnerability's technical severity on a 0 to 10 scale
Severity isn't the same as risk to you: reachability, exposed data and existing controls decide fix priority.
73. What is
/.well-known/security.txtfor?Correct answer: Telling researchers how to report vulnerabilities to you
A clear reporting channel (and ideally a disclosure policy or bug bounty) means you hear about issues before they're exploited.
74. What's the right order of actions when a production secret leaks?
Correct answer: Rotate it, check logs for misuse, fix the cause, then document
Containment comes first. Logs are evidence and must be kept; a blameless review afterwards prevents a repeat.
75. How do automated scanning (SAST/DAST), pentests and bug bounties complement each other?
Correct answer: Scanners run constantly, pentests go deep, bounties add outside eyes
Automated tools miss logic flaws like broken authorization; humans miss what they don't have time to cover. Layering them gives better coverage.