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.
During a pull-request review you notice a query that concatenates user input into SQL. Describe the steps you would take right away to mitigate the potential SQL injection risk, how you would communicate the issue in the PR review, and what longer-term measures you would put in place to prevent similar issues across the codebase.
Explain how SQL injection attacks work, covering error-based, union-based, boolean/conditional-blind, and time-based blind techniques with a short example payload for each. Give a real-world exploit example and its business impact, then propose a prioritized set of mitigations at the code, framework, database, and architecture levels (parameterized queries/ORM best practices, least-privileged DB accounts, network rules, WAF, logging and detection).
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.
A web page echoes a query parameter without encoding:
<!-- 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.
You are reviewing a Python Flask endpoint that builds SQL queries by string concatenation, for example:
cursor.execute('SELECT * FROM users WHERE username = "%s"' % username)
Explain the vulnerability, map it to the appropriate CWE, and provide a secure Python fix using parameterized queries or an ORM. Then list any remaining risks you would still check for (for example, over-privileged DB accounts or an ORM call that silently falls back to raw SQL).
Unlock Full Question Bank
Get access to all 14 Secure Coding and Application Security interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.