Q17 of 22 · Scenarios
How would you test the security of a web form?
ScenariosSeniorscenariosecurityxsssql-injectioncsrfidornon-functional
Short answer
Short answer: Clarify the form's data type and rendering context, then systematically cover injection vectors (XSS, SQLi), transport security, authentication and CSRF, data handling, and rate limiting.
Detail
Clarify first
- Is the form authenticated or public-facing?
- What data does it collect, and is user-generated content rendered back to other users?
- What is the tech stack (helps scope injection surface — Rails, Django, Spring, Node)?
- Are there any known compliance requirements (PCI, HIPAA, GDPR) that constrain data handling?
Injection & content security
- XSS — inject
<script>alert(1)</script>and<img src=x onerror=alert(1)>in every text field; verify stored output is HTML-encoded and no script executes - SQL injection — inject
' OR '1'='1and'; DROP TABLE users; --in every field; no DB error surfaced, no data returned - HTML injection — inject
<h1>Owned</h1>to verify the response is not raw HTML - Command injection — inject
; ls -laif any field is used in a server-side shell command
Transport security
- Form submits over HTTPS; any HTTP attempt is redirected to HTTPS
- Sensitive fields (password, card, SSN) not in the URL query string
autocomplete="off"on password and card fields
Authentication & authorisation
- CSRF: token present in the form; removed or tampered token causes the submission to be rejected
- Unauthenticated submission to an authenticated endpoint returns 401/403 (not silently accepted)
- IDOR: form submission referencing another user's resource ID is rejected
Data handling
- PII collected by the form is not logged in plaintext server-side (check application and access logs)
- Sensitive values not echoed in error messages or HTTP response headers
- Server-side validation enforced independently of client-side validation (disable JS and re-submit)
Rate limiting & abuse
- Brute-force protection on login/registration forms (lockout or CAPTCHA after repeated submissions)
- Submission rate limit applied per user or IP
Close: automate injection payloads using OWASP ZAP or Burp Suite in CI-integrated scan mode, plus targeted unit tests for each validator. Keep manual for logic-level abuse scenarios and reviewing server logs for data leakage.
// WHAT INTERVIEWERS LOOK FOR
Distinguishing stored vs reflected XSS, CSRF token validation, IDOR on form submissions, and server-side validation enforcement with JS disabled. Mentioning OWASP ZAP or Burp Suite shows practical tooling knowledge.
// COMMON PITFALL
Focusing only on XSS and SQL injection. Missing CSRF, IDOR, transport security (HTTPS, no data in URL), PII in logs, and the server-side-validation-only check (disable JS then re-submit).