InterviewStack.io LogoInterviewStack.io

Secure Coding and Application Security Questions

Writing and reviewing code that resists attack. Covers the OWASP Top Ten and common web vulnerabilities (XSS, SQL injection, CSRF), input validation, secure coding practices and security code review, static application security testing (SAST), API and HTTP security, database and frontend security, and mobile app security. The application-layer defense discipline for engineers building software.

EasyTechnical
46 practiced

Explain Cross-Site Request Forgery (CSRF): the attack mechanism, and practical mitigations including server-side anti-CSRF tokens, SameSite cookie attributes, the double-submit cookie pattern, and relevant client-side considerations. Map it to CWE-352, and explain when CSRF is (and is not) a concern for pure API designs versus traditional cookie-based web apps.

MediumTechnical
32 practiced

Define a multi-layered input validation strategy for preventing injection and XSS across the client, API gateway, service layer, and database. Discuss canonicalization, allow-listing versus deny-listing, schema validation, and the trade-off between a centralized validation library and per-service checks, for a full-stack application spanning a browser client and multiple backend services.

EasyTechnical
61 practiced

Implement two small Python functions: (1) validate_username(username) that enforces a length of 3-30 characters, only alphanumeric/underscore/hyphen characters, and no leading or trailing whitespace; (2) escape_html(s) that safely encodes a user-supplied string for HTML output. Explain when you would reach for input validation versus output encoding, and why one does not substitute for the other.

MediumSystem Design
43 practiced

Design a microservice authentication and authorization architecture that avoids common Broken Authentication and Broken Access Control problems. Address token types and lifecycle (access token, refresh token), revocation, audience/scopes, RBAC vs ABAC trade-offs, where to enforce checks (API gateway vs services), and logging/audit points.

MediumTechnical
36 practiced

A web page echoes a query parameter without encoding:

php
<!-- vulnerable.php -->
<html>
  <body>
    Search results: <?php echo $_GET['q']; ?>
  </body>
</html>

Demonstrate a reflected-XSS payload an attacker could use against this page to exfiltrate cookies, then provide a secure server-side fix and a recommended Content Security Policy header. Explain why both the code fix and the CSP header are useful together.

Unlock Full Question Bank

Get access to all 14 Secure Coding and Application Security interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.