Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

9.3.1. Secure Coding Principles and OWASP Top 10

💡 First Principle: Secure coding principles are defensive defaults — assumptions that every input is hostile, every error path matters, and every access must be verified. When these principles are applied consistently, entire vulnerability classes are eliminated structurally rather than discovered and patched individually. The cost difference is orders of magnitude: preventing SQL injection by using parameterized queries everywhere is cheaper than finding and fixing SQL injection bugs one at a time across thousands of code paths.

OWASP Top 10 (2021) — the vulnerability classes that matter most:
RankCategoryRoot CausePrevention
A01Broken Access ControlMissing or inconsistent authorization checksDeny by default; enforce at server side; verify on every request
A02Cryptographic FailuresWeak algorithms, poor key management, data exposureUse current algorithms (AES-256, SHA-256+); manage keys properly; encrypt data at rest and in transit
A03InjectionUntrusted input interpreted as codeParameterized queries (SQL); output encoding (XSS); input validation (allowlist)
A04Insecure DesignMissing threat model; no security architectureThreat modeling in design phase; secure design patterns; abuse case analysis
A05Security MisconfigurationDefault credentials; unnecessary features enabled; verbose errorsHardened baselines; automated configuration scanning; minimal installation
A06Vulnerable ComponentsUsing libraries with known CVEsSCA scanning; SBOM maintenance; dependency update process
A07Authentication FailuresWeak passwords; missing MFA; session mismanagementMFA; credential stuffing protection; secure session handling
A08Data Integrity FailuresUntrusted deserialization; unsigned updatesInput validation on serialized data; signed and verified software updates
A09Logging FailuresInsufficient logging; logs not monitoredLog security-relevant events; protect log integrity; integrate with SIEM
A10SSRFServer makes requests to attacker-controlled URLsValidate and sanitize all URLs; allowlist permitted destinations; segment network
Core secure coding principles:
  • Input validation — Validate all input on the server side. Allowlist validation (define what IS allowed) is stronger than denylist validation (define what IS NOT allowed) because denylist approaches cannot anticipate every possible malicious input. Validate data type, length, range, and format.
  • Output encoding — Encode output based on the context where it will be rendered (HTML encoding for web pages, URL encoding for query parameters, JavaScript encoding for script contexts). Output encoding prevents XSS by ensuring user-supplied data is treated as data, not executable code.
  • Parameterized queries — The definitive defense against SQL injection. Parameterized queries (prepared statements) separate SQL code from data — the database engine treats user input as a literal value, never as executable SQL. Input filtering alone is insufficient because filter bypass techniques are well-documented.
  • Fail secure — When an error occurs, the system should deny access rather than grant it. A firewall that fails open allows all traffic during a malfunction; a firewall that fails closed blocks all traffic. For security controls, fail closed is the correct default.
  • Secure defaults — Applications should ship with the most secure configuration possible. Features that reduce security (debug mode, verbose error messages, default admin accounts) should be disabled by default and require explicit activation.
  • Least privilege in code — Application components should run with the minimum permissions required. A web application should not run as root/admin. Database connections should use accounts with only the permissions needed (SELECT for read operations, not full DBA access).
Memory safety vulnerabilities:

Buffer overflows remain relevant for the CISSP despite being a lower-level vulnerability class:

VulnerabilityMechanismPrevention
Buffer overflowInput exceeds allocated memory; overwrites adjacent data/codeMemory-safe languages (Rust, Go, Java); bounds checking; ASLR; DEP/NX; stack canaries
Integer overflowArithmetic exceeds data type capacity; wraps to unexpected valueSafe integer libraries; range validation before arithmetic operations
Format stringUser input used directly in format functions (printf)Never use user input as format strings; use fixed format strings with arguments

⚠️ Exam Trap: SQL injection is prevented by parameterized queries — not by input filtering alone. Input filtering (stripping single quotes, escaping special characters) can be bypassed with encoding techniques, alternative syntax, or second-order injection. The exam tests whether you know the structural defense (parameterized queries) versus the brittle defense (input filtering).

Reflection Question: A code review reveals that a web application constructs SQL queries by concatenating user input directly into the query string. The developer argues this is safe because the application strips single quotes from all input before concatenation. Explain why this defense is insufficient, provide a specific bypass technique, and describe the correct architectural fix that eliminates SQL injection structurally.

Alvin Varughese
Written byAlvin Varughese
Founder15 professional certifications