HTHyperTransformer AI

Study cards › Security

SecurityInterview questions and answers

← Topics1 / 100
1 / 100 viewed
Question

What is JWT?

Answer

JSON Web Token — a base64-encoded JSON payload signed (HMAC or RSA/ECDSA) so the server can verify the token's authenticity without a database lookup. Used to authenticate API requests statelessly. Anyone can READ a JWT's contents (base64 isn't encryption); only signing key holders can produce valid ones.

Question

Structure of a JWT?

Answer

Three dot-separated parts: header.payload.signature. Header declares the signing algorithm; payload contains claims (user id, expiry, roles); signature is computed over header+payload using the secret. Headers and payload are base64-encoded JSON — readable by anyone.

Question

Signed vs encrypted JWT?

Answer

Signed (JWS): readable by anyone, but tamper-evident — anyone can verify the signature with the public key. Encrypted (JWE): payload is also kept confidential. Most apps use signed JWTs; only use JWE when the token's contents themselves must be hidden from intermediaries.

Question

Where should you store a JWT on the client?

Answer

An HTTP-only, Secure cookie is the safest — JavaScript can't read it, so XSS can't steal it. Avoid localStorage if XSS is a concern. Never store JWTs anywhere a third-party script could read them. Pair with SameSite=Lax/Strict to mitigate CSRF.

Question

Why use short-lived access tokens?

Answer

If an access token leaks, a short expiry (5-15 min) limits how long attackers can use it. Pair with a refresh token (longer-lived, stored more securely) that gets new access tokens silently. The pattern gives you both UX (no constant logins) and security (small blast radius).

Question

How do you revoke JWTs?

Answer

Because JWTs are stateless, revocation needs an external store. Options: a Redis deny-list of token IDs (jti) or 'tokens issued before timestamp X' per user, checked on every request. Or keep access tokens very short-lived and revoke the refresh token instead.

Question

What is OAuth2?

Answer

An authorization framework where a user grants a third-party application limited access to their data on a resource server, mediated by an authorization server. Your app never sees the user's password. The standard powering 'Sign in with Google/Facebook/GitHub' and most API delegations.

Question

OAuth2 grant types?

Answer

Authorization Code (with PKCE for SPAs/mobile — the modern default), Client Credentials (machine-to-machine, no user), Refresh Token (exchange for new access tokens). Implicit Grant and Password Grant are deprecated. Always use Authorization Code + PKCE unless you have a specific reason not to.

Question

What is PKCE?

Answer

Proof Key for Code Exchange — extends the OAuth2 Authorization Code flow with a code_verifier/code_challenge pair so public clients (SPAs, mobile apps) that can't safely store a client secret can use the flow securely. Today PKCE is recommended for ALL clients, not just public ones.

Question

OAuth2 vs OIDC?

Answer

OAuth2 handles AUTHORIZATION (access tokens to call APIs on a user's behalf). OIDC (OpenID Connect) adds AUTHENTICATION on top: an ID token (a JWT) and a userinfo endpoint identifying who the user is. 'Sign in with Google' is technically OIDC; pure OAuth2 doesn't tell you who the user is.

Question

What is RBAC?

Answer

Role-Based Access Control — assign users to roles (admin, editor, viewer), grant permissions to roles. Much simpler than per-user permissions and scales to large teams. The starting point for most app authorization. Audit by listing role memberships rather than tracking individual grants.

Question

RBAC vs ABAC?

Answer

RBAC: 'role → permission' rules (admin can delete). ABAC (Attribute-Based): policies considering many attributes — user.department == doc.department, time-of-day, resource tags. ABAC is more flexible and expressive but more complex to author and audit. Most teams start with RBAC and add ABAC for tricky cases.

Question

Symmetric vs asymmetric encryption?

Answer

Symmetric: same secret key encrypts and decrypts (AES) — fast but you must share the key safely. Asymmetric: public/private keypair (RSA, ECDSA) — slower but you can publish the public key. Real systems combine both: use asymmetric to exchange a symmetric key, then symmetric for bulk data (this is what TLS does).

Question

What is hashing?

Answer

A one-way function that produces a fixed-size digest from any input. Used for passwords (bcrypt/argon2), integrity checks (SHA-256 of files), and as a building block of signatures and HMAC. Critical property: even a tiny input change produces a completely different hash.

Question

Why not SHA-256 for passwords?

Answer

SHA-256 is fast — attackers can hash billions per second on a GPU, so brute-forcing common passwords is trivial. Password hashes need to be SLOW and tunable: bcrypt, scrypt, or argon2. Argon2id is the modern recommendation. Slow on purpose so attackers can't try many guesses per second.

Question

What is salting?

Answer

Adding a unique random value to each password before hashing. Two users with the same password get different hashes, defeating rainbow tables (precomputed hash lookups). Password hashing libraries (bcrypt, argon2) handle salting automatically — never roll your own.

Question

What is HTTPS?

Answer

HTTP over TLS — encrypts traffic between client and server, authenticates the server (via certificate), and prevents tampering or eavesdropping. Mandatory for any modern app. Free TLS certs from Let's Encrypt mean there's no excuse not to use it everywhere.

Question

What is a TLS handshake?

Answer

Client and server agree on cipher suites, exchange keys (typically ECDHE for forward secrecy), verify the server's certificate, and derive session keys. TLS 1.3 is faster (fewer round trips) and removes weak ciphers. Browsers warn or fail on old TLS — keep your servers up to date.

Question

What is HSTS?

Answer

HTTP Strict-Transport-Security — a response header that tells browsers to ONLY use HTTPS for this domain for the next N seconds, even if the user types http://. Prevents protocol-downgrade attacks where an attacker strips TLS on initial requests.

Question

What is the OWASP Top 10?

Answer

The Open Web Application Security Project's ranked list of the most critical web application security risks, updated periodically. Recent themes: broken access control, cryptographic failures, injection, insecure design, security misconfiguration, vulnerable dependencies, SSRF. The default reading list for every web developer.

Question

What is SQL injection?

Answer

An attack where user input is interpolated into a SQL query, letting an attacker run arbitrary SQL. Devastating: data theft, deletion, privilege escalation. Prevention is simple: use parameterized queries or ORMs that bind values rather than string-concatenating them. Never trust user input in raw SQL.

Question

What is XSS (Cross-Site Scripting)?

Answer

An attacker injects JavaScript that runs in another user's browser. The malicious JS can steal cookies, log keystrokes, or take actions as the user. Prevent with output encoding (don't render raw HTML from users), input sanitization (DOMPurify), and a strict Content Security Policy (CSP).

Question

Stored vs reflected vs DOM XSS?

Answer

Stored: payload is saved on the server (e.g. comment field) and executed for every viewer. Reflected: payload comes from a URL parameter and is echoed back. DOM-based: vulnerable client-side JavaScript (innerHTML, eval, document.write) executes the payload without the server seeing it. All three are dangerous.

Question

What is CSRF?

Answer

Cross-Site Request Forgery — tricking a logged-in user's browser into making a state-changing request (transfer money, change password). Defenses: anti-CSRF tokens, SameSite=Lax/Strict cookies (the modern default), and avoiding GETs for state changes. SameSite cookies have almost eliminated CSRF for new apps.

Question

What is the SameSite cookie attribute?

Answer

Controls when cookies are sent cross-site: Strict (never), Lax (only top-level navigations — the modern default), None (always, requires Secure flag). Lax/Strict effectively kills most CSRF for cookie-based sessions. Set this on every cookie you create.

Question

What is CSP?

Answer

Content Security Policy — an HTTP header listing approved sources for scripts, styles, images, etc. The browser refuses to load anything else. A strict CSP (no inline scripts, no eval) makes XSS dramatically harder even if your sanitization fails. One of the highest-leverage security headers.

Question

What is SSRF?

Answer

Server-Side Request Forgery — tricking the server into making outbound HTTP requests to internal-only resources (cloud metadata endpoints, internal APIs, localhost). Devastating in cloud environments. Defend by allowlisting outbound URLs strictly, never letting users control hostnames, and blocking link-local IPs (169.254.x.x).

Question

What is IDOR?

Answer

Insecure Direct Object Reference — the URL /orders/123 lets attackers guess /orders/124 and access someone else's order. The bug is the server NOT checking ownership/authorization. Always verify the current user owns or has permission to access each resource, every request — not just hidden URLs in the UI.

Question

What is broken access control?

Answer

Failing to enforce authorization checks server-side. UI hiding a button isn't security — the server must check on every request. #1 OWASP risk for years. Centralize checks (middleware, policy engines like OPA) so they can't be forgotten on individual endpoints.

Question

What is defense in depth?

Answer

Layering multiple overlapping security controls — WAF + auth + input validation + DB permissions + monitoring. Assume each layer might fail; redundancy means attackers must defeat all of them. Cheap to implement and dramatically reduces successful breaches.

Question

Principle of least privilege?

Answer

Every user, service, and role gets only the permissions actually needed — no more. Limits the blast radius when credentials leak or systems are compromised. Apply it to IAM roles, DB users, network rules, file permissions — everywhere access decisions are made.

Question

OWASP API Security Top 10?

Answer

API-specific risks: broken object-level auth (BOLA), broken authentication, excessive data exposure, lack of resources/rate limiting, broken function-level auth, mass assignment, security misconfiguration, injection, improper assets management, insufficient logging. APIs need their own threat model — browser-era assumptions don't apply.

Question

What is mass assignment?

Answer

Binding a request body directly to a database model lets attackers set fields they shouldn't — POSTing {is_admin: true} to /users/me. Defend by explicitly allowlisting the fields you accept (DTOs, schema validation) instead of accepting whatever the body contains.

Question

What is excessive data exposure?

Answer

Returning more data than the client needs (entire user object including password hash) — even if the UI doesn't display it, the data is still in the response. Always project (Pick/Select) what you actually need at the API layer; never rely on the UI to filter sensitive fields.

Question

Rate limiting as a security tool?

Answer

Caps requests per user/IP per window — blunts brute-force login attempts, credential stuffing, scraping, and DoS attacks. Different from performance rate limiting in intent but similar in implementation. Apply at the API gateway and on critical endpoints (login, password reset) per identity.

Question

What is credential stuffing?

Answer

Attackers automate trying leaked credentials from other breaches against your login form — most people reuse passwords. Defenses: MFA, rate limiting per username AND IP, CAPTCHA after failures, password-breach checks (Have I Been Pwned API).

Question

What is MFA?

Answer

Multi-Factor Authentication — something you KNOW (password), something you HAVE (TOTP app, hardware key, SMS code), and sometimes something you ARE (biometric). Even if the password leaks, attackers also need the second factor. Single highest-leverage account security upgrade.

Question

TOTP vs WebAuthn?

Answer

TOTP: 6-digit codes from an app (Authy, Google Authenticator) — still phishable, the user can type their code into a fake site. WebAuthn (passkeys, hardware keys): cryptographic, origin-bound, phishing-resistant. WebAuthn is the gold standard; TOTP is a strong second-best.

Question

What is a passkey?

Answer

A WebAuthn credential stored on the user's device or cloud keychain (iCloud Keychain, 1Password). Replaces passwords with public-key crypto. Unphishable, can sync across devices, often unlocked by biometrics. The successor to passwords being rolled out by Apple, Google, Microsoft, and FIDO.

Question

What is mTLS?

Answer

Mutual TLS — both client AND server present and verify certificates. Used for high-security clients (banking devices) and as the default for service-to-service auth in service meshes. Stronger than bearer tokens because the client's identity is cryptographically tied to the connection.

Question

API key vs token?

Answer

API key: usually long-lived, static, identifies an app or user — convenient but less secure if leaked (no built-in expiration). Token: short-lived, often scoped to specific permissions, refreshable — more secure but more setup. Prefer tokens for user contexts; API keys are acceptable for server-to-server with rotation.

Question

Why hash AND salt server-side?

Answer

If your DB ever leaks (and many do), attackers must brute-force each password. With unique salts plus slow hashing (bcrypt/argon2), even big rainbow tables and GPU farms can't crack most passwords in reasonable time. Standard practice for 20+ years — no excuse not to.

Question

What is HMAC?

Answer

Hash-based Message Authentication Code — combines a secret key with a hash function to produce a signature. Verifies that a message is authentic AND unchanged. Used to sign webhooks, cookies, and short tokens. Faster than RSA signing; both sender and verifier need the same secret.

Question

What is a replay attack?

Answer

Reusing a captured legitimate request to do something twice — e.g. replaying a money-transfer request. Defend with nonces (single-use tokens), timestamps (reject old requests), and short-lived auth tokens. Idempotency keys also limit the damage of replays for non-idempotent operations.

Question

Encryption at rest vs in transit?

Answer

In transit: TLS — protects against eavesdropping on the wire. At rest: storage-level encryption (KMS-backed) for databases, backups, S3 buckets, EBS volumes — protects against stolen physical disks or backup leaks. Both are baseline requirements for any serious app and most compliance regimes.

Question

What is a secret manager?

Answer

A service for storing, rotating, and granting access to sensitive credentials — AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager. Replaces env files and config repos. Apps fetch secrets at startup via an authenticated API call; secrets are never on disk.

Question

What is key rotation?

Answer

Periodically replacing cryptographic keys to limit exposure if one leaks. KMS and Secrets Manager can rotate automatically. Plan for graceful rotation — old keys remain valid for a window so in-flight tokens aren't invalidated. Static long-lived keys are a security smell.

Question

What is CORS?

Answer

Cross-Origin Resource Sharing — browsers block JavaScript from reading responses across origins UNLESS the server opts in with Access-Control-Allow-Origin and related headers. It's a browser policy; server-to-server requests are unaffected. Configure CORS carefully — wildcards are dangerous.

Question

What is the Same-Origin Policy?

Answer

A browser rule preventing JavaScript on one origin (scheme + host + port) from reading responses from another. The foundation of web security — without it, a malicious site could read your email through your browser. CORS is the controlled relaxation of this policy.

Question

What is clickjacking?

Answer

Tricking users into clicking something they didn't intend by overlaying your site inside a transparent iframe on a malicious page. Defend with X-Frame-Options (DENY or SAMEORIGIN) or CSP's frame-ancestors directive. Most modern frameworks set these by default — verify yours does.

Question

What is a timing attack?

Answer

Inferring secrets from response time differences — e.g. a string-compare that returns early when characters don't match leaks how many leading characters were correct. Defend with constant-time comparisons (crypto.timingSafeEqual in Node) for tokens, passwords, and HMACs.

Question

What was the JWT 'none' algorithm vulnerability?

Answer

Some JWT libraries used to accept the 'none' algorithm, letting attackers forge tokens by setting alg:none in the header. Always specify which algorithms you accept when verifying, and never trust the alg field from the token itself. Modern libraries default to strict verification.

Question

Why use parameterized queries?

Answer

Because user input gets treated as DATA, not SQL — eliminating injection by construction. Drivers bind values into placeholders ($1, $2 or ? depending on dialect) and the DB knows they're not code. Faster to write, safer, and often faster to execute (better plan caching). Use them everywhere.

Question

Input validation vs output encoding?

Answer

Input validation: reject malformed data at the boundary — schema checks, type checks, length limits. Output encoding: safely render data for whatever context (HTML, URL, JS string, SQL) it ends up in. You need BOTH. Validation rejects garbage; encoding handles legitimate data that contains special characters.

Question

Why HTTPS everywhere?

Answer

Without it: ISPs and Wi-Fi attackers can read user traffic, inject ads/scripts, steal cookies, and modify content. HTTPS is now table stakes — search engines penalize HTTP, browsers warn users, and Let's Encrypt makes it free. There's literally no reason to run plain HTTP today.

Question

What is a TLS certificate?

Answer

A digital document binding a domain to a public key, signed by a Certificate Authority (CA) the browser trusts. Browsers verify the chain from a trusted root CA down to the leaf cert for your domain. Lets Encrypt issues free, automated certs that any modern web stack can use.

Question

What does Let's Encrypt do?

Answer

A free, automated Certificate Authority issuing 90-day TLS certs via the ACME protocol. Most modern web stacks integrate it natively (Caddy, Nginx with certbot, Traefik). Killed the 'we don't have HTTPS because certs are expensive/manual' excuse.

Question

What is a security header?

Answer

HTTP response headers that harden a web app: HSTS (force HTTPS), CSP (limit script sources), X-Content-Type-Options (no MIME sniffing), X-Frame-Options (no iframe embedding), Referrer-Policy (limit referer leakage), Permissions-Policy (restrict APIs). Set them all for any production site.

Question

What is dependency scanning?

Answer

Checking your project's packages against CVE databases to find known vulnerabilities. Tools: GitHub Dependabot, Snyk, npm audit, OWASP Dependency-Check. Run in CI; fail builds on high/critical vulns. Modern apps have hundreds of transitive deps — manual auditing is impossible.

Question

SAST vs DAST?

Answer

SAST: Static Application Security Testing — analyzes source code for vulnerable patterns (taint, unsafe APIs). DAST: Dynamic — probes a running app from outside (Burp, OWASP ZAP). They find different bugs; mature programs use both, plus dependency scanning and IAST.

Question

What is a supply chain attack?

Answer

Compromising a dependency or build system to attack downstream consumers — malicious npm packages, compromised CI tools, typosquatting. Defenses: lockfiles, integrity checksums, vetting authors, vendoring critical deps, signed artifacts, and SBOMs to know what you actually ship.

Question

What is sandboxing?

Answer

Running untrusted code in a restricted environment with limited filesystem, network, and syscall access. Examples: browser tabs, Docker containers, gVisor, V8 isolates, WASM runtimes. Critical for any system that executes user-provided code (online IDEs, AI tool calls, plugin systems).

Question

What is the principle of secure defaults?

Answer

Out of the box, the system should be secure — auth enabled, public access disabled, restrictive perms, ports closed. Users opt INTO less-safe behavior knowingly, not the other way around. This is why default credentials, world-readable buckets, and open admin panels keep being top breach causes.

Question

What is a security audit?

Answer

A systematic review of code, infrastructure, and processes by security experts — internal team or external firm. Output: findings ranked by severity with remediation guidance. Different from a pen test (which is adversarial); audits are usually broader and process-focused. Required for many compliance regimes.

Question

What is penetration testing?

Answer

An authorized simulated attack on your system to find exploitable weaknesses. Pen testers try to break in like real attackers, then report what worked. Complements automated scanning by finding logic flaws, chained exploits, and creative attacks scanners miss. Annual pen tests are standard for serious products.

Question

What is a bug bounty?

Answer

A public program (or invite-only) paying ethical hackers for responsibly disclosed vulnerabilities. Tools: HackerOne, Bugcrowd. Scales your security testing far beyond what an internal team alone can do. Set scope and reward tiers carefully — popular programs receive hundreds of reports a month.

Question

What's the role of logging for security?

Answer

Capture auth events, admin actions, permission changes, failed logins, sensitive reads — immutable, centralized, and alertable. Foundation of incident response and forensics. Don't log secrets or PII without scrubbing. Without good security logs, you can't tell whether you were breached.

Question

What is an incident response plan?

Answer

Documented steps for detection, containment, eradication, recovery, and post-mortem of security incidents. Define roles (incident commander, comms, technical lead), communication channels, and customer notification rules. Run drills — the time to learn the playbook is NOT during a real breach.

Question

What is zero trust?

Answer

A security model: never trust based on network location. Authenticate and authorize EVERY request, even inside the perimeter. Implies mutual TLS between services, identity-aware proxies, and per-resource policies. Replaces the old 'crunchy outside, gooey inside' enterprise network model.

Question

How do services authenticate to each other?

Answer

Options: mutual TLS (each service has a cert), signed JWTs (short-lived, scoped), service mesh identities (workload identity backed by k8s service accounts), or AWS IAM SigV4 (calls signed with IAM credentials). Service-to-service auth is fundamental to zero trust.

Question

What is an HTTP-only cookie?

Answer

A cookie inaccessible to JavaScript (document.cookie can't read it). Mitigates XSS-based session theft — even if an attacker injects script, they can't grab the session cookie. Always set HttpOnly on session and auth cookies.

Question

What's the 'Secure' cookie flag?

Answer

Tells the browser to send the cookie only over HTTPS. Without it, any HTTP request leaks the cookie. Always set Secure on session and auth cookies — combined with HSTS, this should be automatic.

Question

What is a sanitization library for HTML?

Answer

Tools like DOMPurify that strip dangerous HTML/JS while preserving safe formatting. Use when rendering user-supplied HTML (rich text comments, markdown HTML output). Never roll your own sanitization — XSS bypass tricks are endless.

Question

What is log/escape sequence injection?

Answer

Sneaking control characters (newlines, ANSI escape codes) into log lines to forge entries or hijack terminal output. Defend by sanitizing log inputs (strip non-printable chars) — especially when logs are displayed in terminals, IDEs, or web log viewers.

Question

What is an open redirect?

Answer

An endpoint that redirects to a user-controlled URL — abused by phishers to send victims to attacker sites from a URL that looks like yours. Allowlist valid destinations; never trust a 'next' query param without validation.

Question

What is a Web Application Firewall (WAF)?

Answer

Inspects HTTP traffic for known attack patterns (SQLi, XSS, malicious bots, scanners) and blocks them at the edge — AWS WAF, Cloudflare, ModSecurity. A layer of defense, NOT a replacement for secure code. Tune rules carefully to avoid blocking legitimate traffic.

Question

DoS vs DDoS?

Answer

DoS (Denial of Service): single source overload. DDoS (Distributed): many compromised sources (a botnet). Defend with CDN absorption, rate limiting, autoscaling, anycast networks, and DDoS scrubbing services (Cloudflare, AWS Shield). For most apps, putting a real CDN in front does 80% of the work.

Question

What is BOLA?

Answer

Broken Object Level Authorization — APIs returning data without checking the caller actually owns or can access the requested object. Currently #1 OWASP API risk. Test by changing IDs in URLs to other users' values; if you get their data, you're vulnerable. Fix: authorize every resource access.

Question

What is the JWT 'aud' claim?

Answer

Audience — which service the token is intended for. Always validate it matches your service identifier so tokens issued for OTHER services in the same auth system aren't accepted by yours. Common gap when many services share an identity provider.

Question

What are 'iss' and 'exp' in JWTs?

Answer

iss: issuer (which auth server minted the token). exp: expiration (unix timestamp). Validate both on every request — accept only your trusted issuer, and reject expired tokens. Many JWT libraries do these checks by default but verify your config.

Question

How do you handle password reset securely?

Answer

Email a single-use, time-limited token (15-30 min) to a reset URL. Never include the password or hint. Throttle requests per email. Don't reveal whether the email exists ('if this email is registered, we sent a link'). Invalidate other sessions on successful reset.

Question

Rate-limiting login: by IP or by user?

Answer

Per-user: prevents brute-forcing one account, but attackers can spread across many accounts. Per-IP: prevents one IP from many attempts but spreads via botnets. Use BOTH, plus CAPTCHA/MFA prompts after a few failures and breached-password checks on signup.

Question

What's the OAuth state parameter?

Answer

An opaque value the client sends with the auth request and verifies on callback — prevents CSRF on the OAuth flow itself. The auth server returns it untouched; the client compares to its stored value before accepting the callback. Always set state (and use PKCE).

Question

OWASP API1 (BOLA) — what is it?

Answer

Broken Object Level Authorization — most APIs don't check that the requested object belongs to the requesting user. The default API1 issue per OWASP. Treat object IDs in requests as untrusted and verify ownership/permission against the authenticated user every time.

Question

What is just-in-time (JIT) access?

Answer

Granting elevated privileges only for a short time after explicit approval — instead of standing admin permissions. Engineers request 'I need DB write access for 1 hour to fix this incident,' get approved, and access auto-revokes. Drastically reduces blast radius of credential compromise.

Question

What is an HSM?

Answer

Hardware Security Module — a dedicated, tamper-resistant device that stores cryptographic keys and performs operations (signing, encryption) without ever exposing the key material. Used for high-value signing (TLS roots, code signing) and required by some compliance regimes (PCI, FIPS).

Question

What is forward secrecy?

Answer

Even if the server's long-term key is compromised in the future, past TLS sessions remain secure because each used an ephemeral session key (via ECDHE). TLS 1.3 mandates forward secrecy. Means an attacker who records traffic now can't decrypt it later by stealing the server key.

Question

What is server-side request validation?

Answer

Schema-validating every request — required fields, types, lengths, allowed values, ranges — at the boundary before doing anything else. Never trust the client to have validated. Libraries: Zod, AJV, Joi, Pydantic, Spring's @Valid. Catches malformed data and many injection attempts.

Question

Why validate content type on uploads?

Answer

Attackers can lie about MIME types or extensions to upload executable content disguised as images. Sniff magic bytes (real file signatures), enforce allowed types, scan with AV before serving, and serve from a separate domain with Content-Disposition: attachment for downloads.

Question

What is path traversal?

Answer

Inputs like '../../etc/passwd' that escape the intended directory to access arbitrary files. Defend by resolving the requested path against an allowlisted root and confirming the resolved path is still under it. Never concatenate user input directly into filesystem paths.

Question

What is XXE (XML External Entity)?

Answer

An XML parser configured to fetch external entities can be abused to read local files or reach internal services (SSRF). Almost no app needs external entity processing — disable it in your XML parser. Hits show up in SOAP and SAML stacks especially.

Question

What's the rule for SameSite=None?

Answer

If you need cross-site cookies (third-party iframes, certain SSO flows), set SameSite=None — and you MUST also set Secure (HTTPS only). Browsers reject SameSite=None cookies without Secure. The combo signals 'I know this is cross-site and consent to the risks.'

Question

What's the risk of skipping JWT 'aud' validation?

Answer

A token issued for Service A (with its claims) could be accepted by Service B if both trust the same issuer and B doesn't check the audience. Always verify the aud claim matches your service so cross-service token reuse is impossible.

Question

What is brute-force protection?

Answer

Detect repeated authentication failures and slow them down or block: per-account lock-out (with a clear unlock path), per-IP rate limits, CAPTCHA after N failures, MFA prompts on suspicious logins. Combine multiple signals — single mechanisms are easy to bypass via distribution.

Question

What is CAPTCHA's role?

Answer

Distinguishes humans from bots for high-risk actions (signup, login, password reset, posting). Modern variants (reCAPTCHA v3, hCaptcha, Cloudflare Turnstile) are invisible most of the time and only challenge suspicious users. Use them sparingly; over-CAPTCHA-ing real users hurts conversion.

Question

What is the OWASP Cheat Sheet?

Answer

OWASP's concise guidance per topic (authentication, XSS prevention, SQL injection, file upload, JWT, sessions, etc.). Bookmark cheatsheetseries.owasp.org — it's the single best free reference for 'how should I implement this securely' questions.

Question

What is privilege escalation?

Answer

An attacker gaining higher privileges than they started with — vertical (regular user → admin) or horizontal (one user → another). Mitigate with least privilege, separation of duties, secure config (no default passwords), patched OS, and careful review of authorization checks on admin endpoints.

Question

What is an SBOM?

Answer

Software Bill of Materials — an inventory of every component, dependency, and version in your build. Critical for responding to vulnerabilities (Log4Shell, xz-utils): you need to know within minutes whether you're affected. Generate from build tools (CycloneDX, SPDX); store with your artifacts.

Question

What is server-side template injection?

Answer

User input rendered as a TEMPLATE (Jinja, EJS, Twig) — the engine can execute arbitrary expressions, potentially leading to RCE. Never feed user input directly to a template engine. Use the template language's safe-render mode, or render user data into static slots, not as templates.

Question

What's the role of audit logs?

Answer

Tamper-evident record of who did what, when, and from where — every admin action, permission change, sensitive read. Essential for compliance (SOC2, HIPAA, PCI), forensics after an incident, and detecting insider misuse. Store separately from app logs, with restricted access and immutable retention.

Practise Security in the app
Track your progress, flag tricky cards and write your own answers.

Open in the app

More topics: React & Frontend JavaScript & TypeScript Backend Engineering Databases System Design AI & Agentic AI DevOps & Cloud Testing DSA Coding Problems (Python)