|
1 | 1 |
|
| 2 | +# Senior/Lead AppSec — Technical Interview Question Bank |
| 3 | + |
| 4 | +**How to use this set:** 36 questions total — **22 theory (≈60%)** and **14 practical (≈40%)**. Each item includes brief **“What good answers include”** guidance. Practical tasks test commands/flags, config review, and quick fixes. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## A) Theory — Strategy, Architecture, Web/API, Mobile, Supply Chain (22) |
| 9 | + |
| 10 | +1. **AppSec vs DevSecOps vs Product Security** |
| 11 | + **What good answers include:** AppSec = secure design/code/testing of software; DevSecOps = securing CI/CD and delivery; Product Security = end-to-end ecosystem (device/cloud/support). How these collaborate. |
| 12 | + |
| 13 | +2. **Using OWASP ASVS effectively** |
| 14 | + **What good answers include:** Map ASVS levels (L1–L3) to app criticality; derive acceptance criteria; link to test cases and evidence. |
| 15 | + |
| 16 | +3. **OWASP Top 10 vs OWASP API Top 10** |
| 17 | + **What good answers include:** Differences (e.g., Broken Access Control vs BOLA/IDOR); why resource-level authz matters in APIs. |
| 18 | + |
| 19 | +4. **NIST SSDF (SP 800-218) in a modern SDLC** |
| 20 | + **What good answers include:** Plan/Protect/Produce/Respond; policies, signed commits, SAST/SCA gates, SBOM, incident readiness. |
| 21 | + |
| 22 | +5. **Threat modeling in agile teams** |
| 23 | + **What good answers include:** DFDs, trust boundaries, STRIDE, abuse cases, backlog integration; update models as architecture changes. |
| 24 | + |
| 25 | +6. **Authentication choices** |
| 26 | + **What good answers include:** OAuth 2.0/OIDC flows (Auth Code + PKCE for SPA/native), session vs token trade-offs, MFA, phishing-resistant methods. |
| 27 | + |
| 28 | +7. **Authorization design** |
| 29 | + **What good answers include:** RBAC/ABAC, object-level checks, tenancy boundaries, policy engines (OPA), deny-by-default. |
| 30 | + |
| 31 | +8. **Session management** |
| 32 | + **What good answers include:** HttpOnly/Secure/SameSite, rotation on privilege change, idle/absolute timeouts, fixation prevention. |
| 33 | + |
| 34 | +9. **Input handling & output encoding** |
| 35 | + **What good answers include:** Allow-lists, canonicalization, context-aware encoding (HTML/attr/JS/URL), server-side validation. |
| 36 | + |
| 37 | +10. **XSS variants & mitigations** |
| 38 | + **What good answers include:** Stored/reflected/DOM; CSP, escaping, template auto-escape, no dangerous sinks, strict MIME types. |
| 39 | + |
| 40 | +11. **Injection (SQL/NoSQL/LDAP/OS)** |
| 41 | + **What good answers include:** Parameterized queries/prepared statements, ORM pitfalls, safe shell exec patterns, least privilege. |
| 42 | + |
| 43 | +12. **SSRF & egress control** |
| 44 | + **What good answers include:** Allow-lists, block link-local/metadata IPs, DNS pinning, URL parsers, mTLS to backends. |
| 45 | + |
| 46 | +13. **CORS and same-site architecture** |
| 47 | + **What good answers include:** Least-privilege origins, preflight understanding, avoid `*` with credentials, cookies vs tokens. |
| 48 | + |
| 49 | +14. **JWT security** |
| 50 | + **What good answers include:** Verify signature/alg (no `none`), `iss`/`aud`/`exp`/`nbf`, key rotation, short TTL, revocation strategy. |
| 51 | + |
| 52 | +15. **API rate limiting & abuse prevention** |
| 53 | + **What good answers include:** Quotas, per-principal keys, token bucket/SLAs, backoff, anomaly detection. |
| 54 | + |
| 55 | +16. **Secrets management** |
| 56 | + **What good answers include:** No secrets in repos; vaults/KMS; short-lived creds; rotation; scoped access; secrets scanning. |
| 57 | + |
| 58 | +17. **Supply chain & SBOM/VEX** |
| 59 | + **What good answers include:** SCA, SBOM (SPDX/CycloneDX), VEX to assess exploitability, provenance/signing (Sigstore), private registries. |
| 60 | + |
| 61 | +18. **SAST vs DAST vs IAST vs RASP** |
| 62 | + **What good answers include:** Strengths/limits, where to place in pipeline, coverage and false positives management. |
| 63 | + |
| 64 | +19. **Mobile AppSec (iOS/Android) basics** |
| 65 | + **What good answers include:** MASVS, secure storage/Keychain/Keystore, certificate pinning, reverse-engineering defenses (with realism). |
| 66 | + |
| 67 | +20. **Logging & privacy** |
| 68 | + **What good answers include:** Structured logs, avoid PII/secrets, correlation IDs, retention and access control. |
| 69 | + |
| 70 | +21. **Risk triage & exception handling** |
| 71 | + **What good answers include:** Beyond CVSS: reachability, KEV, exposure window, compensating controls, time-boxed waivers. |
| 72 | + |
| 73 | +22. **Metrics that matter for AppSec** |
| 74 | + **What good answers include:** p95 time-to-patch, % critical vulns > SLA, secrets findings trend, coverage of signed artifacts, defect escape rate. |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## B) Practical — Hands-On Tasks (14) |
| 79 | + |
| 80 | +> Give a terminal/editor and let the candidate execute or explain. Each item notes **expected commands/snippets** and **what good answers include**. |
| 81 | +
|
| 82 | +1. **Fix a CORS misconfiguration (Express.js)** |
| 83 | + **Snippet:** |
| 84 | + |
| 85 | +```js |
| 86 | +app.use(cors({ origin: "*", credentials: true })); |
| 87 | +``` |
| 88 | + |
| 89 | +**Good answer:** Disallow wildcard with credentials; set explicit origins and headers; example: |
| 90 | + |
| 91 | +```js |
| 92 | +app.use(cors({ |
| 93 | + origin: ["https://app.example.com"], |
| 94 | + credentials: true, |
| 95 | + methods: ["GET","POST","PUT","DELETE"], |
| 96 | + allowedHeaders: ["Authorization","Content-Type"] |
| 97 | +})); |
| 98 | +``` |
| 99 | + |
| 100 | +2. **Turn a vulnerable SQL call into a safe one (Node + pg)** |
| 101 | + **Snippet (bad):** |
| 102 | + |
| 103 | +```js |
| 104 | +const rows = await db.query(`SELECT * FROM users WHERE email='${email}'`); |
| 105 | +``` |
| 106 | + |
| 107 | +**Good answer:** Parameterize and least privilege: |
| 108 | + |
| 109 | +```js |
| 110 | +const rows = await db.query("SELECT * FROM users WHERE email=$1", [email]); |
| 111 | +``` |
| 112 | + |
| 113 | +3. **Semgrep rule to flag `eval` in JS** |
| 114 | + **Expected:** A minimal rule and CLI. |
| 115 | + |
| 116 | +```yaml |
| 117 | +rules: |
| 118 | +- id: js-avoid-eval |
| 119 | + languages: [javascript, typescript] |
| 120 | + message: "Avoid eval; use safe alternatives." |
| 121 | + severity: ERROR |
| 122 | + pattern: eval(...) |
| 123 | +``` |
| 124 | +
|
| 125 | +Run: `semgrep --config semgrep.yml src/` |
| 126 | + |
| 127 | +4. **ZAP baseline scan with fail threshold** |
| 128 | + **Command:** |
| 129 | + |
| 130 | +```bash |
| 131 | +zap-baseline.py -t https://staging.example.com -r zap.html -m 5 -a |
| 132 | +``` |
| 133 | + |
| 134 | +**Good answer:** Explain `-m` max alerts threshold, auth context if needed, and that this is non-intrusive. |
| 135 | + |
| 136 | +5. **JWT verification hardening (Node)** |
| 137 | + **Snippet (bad):** |
| 138 | + |
| 139 | +```js |
| 140 | +jwt.verify(token, pubKey); // defaults, no checks |
| 141 | +``` |
| 142 | + |
| 143 | +**Good answer:** Enforce alg, iss, aud, clock skew limits: |
| 144 | + |
| 145 | +```js |
| 146 | +jwt.verify(token, pubKey, { |
| 147 | + algorithms: ["RS256"], |
| 148 | + issuer: "https://idp.example.com/", |
| 149 | + audience: "api://orders", |
| 150 | + maxAge: "10m", |
| 151 | + clockTolerance: 5 |
| 152 | +}); |
| 153 | +``` |
| 154 | + |
| 155 | +6. **SSRF defense helper (Python)** |
| 156 | + **Task:** Write a function that only allows HTTP(S) to `api.partner.com` and blocks link-local/metadata ranges. |
| 157 | + **Good answer:** Parse URL, resolve DNS, check IP against allow-list and deny private/link-local (169.254.0.0/16, 127.0.0.0/8, ::1, fc00::/7). |
| 158 | + |
| 159 | +7. **Set a strict CSP header** |
| 160 | + **Task:** Provide a starter CSP that blocks inline scripts and limits sources. |
| 161 | + **Good answer:** |
| 162 | + `Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self'; connect-src 'self'; base-uri 'self'; frame-ancestors 'none';` |
| 163 | + Mention nonces/hashes for legit inline needs. |
| 164 | + |
| 165 | +8. **Fix CSRF for cookie-based session (frontend + backend)** |
| 166 | + **Ask:** What flags and tokens are required? |
| 167 | + **Good answer:** `SameSite=Lax/Strict`, `HttpOnly`, `Secure`; anti-CSRF token in header/body, double submit or server-generated token, origin/referrer checks. |
| 168 | + |
| 169 | +9. **Diagnose a broken access control (FastAPI)** |
| 170 | + **Snippet (bad):** |
| 171 | + |
| 172 | +```py |
| 173 | +@app.get("/orders/{id}") |
| 174 | +def get_order(id, user=Depends(auth)): |
| 175 | + return db.get_order(id) # no owner check |
| 176 | +``` |
| 177 | + |
| 178 | +**Good answer:** Verify resource ownership/role: |
| 179 | + |
| 180 | +```py |
| 181 | +order = db.get_order(id) |
| 182 | +if order.owner_id != user.id and not user.is_admin: raise HTTPException(403) |
| 183 | +``` |
| 184 | + |
| 185 | +10. **Review a dangerous file upload** |
| 186 | + **Snippet (bad):** saves name directly, no size/type checks. |
| 187 | + **Good answer:** Check MIME/type via server-side validation, size limits, random server filename, store outside web root, AV scan, strip metadata. |
| 188 | + |
| 189 | +11. **Bandit or pip-audit on a Python service** |
| 190 | + **Commands:** |
| 191 | + `bandit -r app/ -ll` and `pip-audit -r requirements.txt --fix` |
| 192 | + **Good answer:** Explain severity flags, pinning versions, creating a PR with fixes. |
| 193 | + |
| 194 | +12. **Write a minimal NetworkPolicy (default-deny egress)** |
| 195 | + **YAML:** |
| 196 | + |
| 197 | +```yaml |
| 198 | +apiVersion: networking.k8s.io/v1 |
| 199 | +kind: NetworkPolicy |
| 200 | +metadata: {name: default-deny-egress, namespace: web} |
| 201 | +spec: |
| 202 | + podSelector: {} |
| 203 | + policyTypes: [Egress] |
| 204 | + egress: [] |
| 205 | +``` |
| 206 | + |
| 207 | +**Good answer:** Then allow needed destinations explicitly. |
| 208 | + |
| 209 | +13. **OAuth 2.0: choose the right flow for a SPA** |
| 210 | + **Ask:** Which flow and why? |
| 211 | + **Good answer:** Authorization Code with PKCE (no client secret in SPA, mitigates interception); ID token usage rules; store tokens securely. |
| 212 | + |
| 213 | +14. **Git pre-commit secrets scanning** |
| 214 | + **Commands:** |
| 215 | + `pre-commit install` with config for `detect-secrets` or `gitleaks`; run `gitleaks detect -v --redact` |
| 216 | + **Good answer:** Block on findings, add allow-lists/entropy tuning, rotate exposed keys. |
| 217 | + |
| 218 | +--- |
| 219 | + |
| 220 | +## Scoring Guidance (quick rubric) |
| 221 | + |
| 222 | +* **Architecture & strategy (Theory 1–6):** clarity, trade-offs, and mapping to controls (0–20). |
| 223 | +* **Web/API/Auth (Theory 7–15):** depth and correctness (0–20). |
| 224 | +* **Supply chain, mobile, ops (Theory 16–22):** practicality and completeness (0–15). |
| 225 | +* **Hands-on fluency (Practical 1–14):** correct commands/flags/configs, minimal but secure fixes (0–35). |
| 226 | +* **Communication:** concise, business-aware reasoning (0–10). |
| 227 | + |
| 228 | +--- |
0 commit comments