On this page
- Quick Reference (60 Seconds)
- What the Control Asks For
- Why Secure Coding Matters
- Scope and Applicability
- Key Definitions and Terminology
- Relationship to Other Controls
- Implementation Roadmap (Week-by-Week)
- Detailed Implementation Guidance
- Tools, Technologies, and Solutions
- Policy and Procedure Templates
- Risk Assessment and Treatment
- Audit and Compliance Checklist
- Metrics and KPIs
- Common Pitfalls and How to Avoid Them
- Illustrative Scenarios
- Multi-Framework Mapping
- Regulatory and Industry Context
- Roles and Responsibilities (RACI)
- Documentation and Evidence Requirements
- Continuous Improvement
- FAQ
- References and Further Reading
Quick Reference (60 Seconds)
Control: A.8.28, Secure Coding
Purpose: Ensure software is written securely, preventing common vulnerabilities from being introduced into applications through insecure coding practices.
ISO 27002 attributes: Control type: Preventive · Properties: Confidentiality, Integrity, Availability · Concepts: Protect · Capabilities: Application security, System and network security · Domains: Protection
Who it applies to: All organizations that develop software in-house, customize third-party software, or manage outsourced development.
Minimum viable actions:
- Adopt a secure coding standard (e.g., OWASP, CERT, MISRA)
- Train all developers on secure coding practices
- Implement automated SAST in CI/CD pipeline
- Conduct manual code review for security-critical code
- Maintain a secure coding policy with language-specific guidelines
Key deliverables: Secure Coding Policy, Secure Coding Standard (per language), SAST Configuration, Code Review Checklist, Developer Training Records.
Audit questions you should be able to answer:
- What secure coding standard does your organization follow?
- How are developers trained on secure coding?
- What automated tools check code for security vulnerabilities?
- How do you handle code review for security?
What the Control Asks For
Do you need this control?
A.8.28 is not mandatory in itself: under clause 6.1.3 you include it if your risk assessment calls for it, and record the decision in your Statement of Applicability. Include it if you write code, including scripts, infrastructure as code and low-code workflows. If you develop nothing, you can exclude it with that reason.
Annex A 8.28 asks organizations to apply secure coding principles to software development.
What ISO 27002:2022 Adds
ISO/IEC 27002:2022 (8.28), paraphrased:
General. Set organisation-wide governance for secure coding and a minimum secure baseline, extended to third-party and open-source components. Watch real-world threats and current vulnerability advice and use them to keep improving your coding principles.
Planning and before coding. Apply the principles to new code and reused code, in-house and for products you supply to others. Prepare:
- expectations and approved principles for in-house and outsourced code;
- knowledge of common and historical coding defects that lead to vulnerabilities;
- development tools, such as IDEs, configured to help enforce secure code;
- guidance from tool and platform providers, and up-to-date tools (for example compilers);
- developers qualified to write secure code;
- secure design and architecture, including threat modelling;
- secure coding standards, mandated where relevant;
- controlled development environments.
During coding. Use language-specific secure practices; secure techniques such as pair programming, refactoring, peer review, security iterations and test-driven development; structured programming; documented code with defects removed; and prohibit insecure techniques such as hard-coded passwords, unapproved code samples and unauthenticated web services. Test during and after development (8.29); SAST helps. Before go-live, evaluate the attack surface and least privilege, and check that the most common programming errors have been mitigated.
Review and maintenance. Package and deploy updates securely; handle reported vulnerabilities (8.8); log errors and suspected attacks and review the logs to improve the code; protect source code from unauthorised access and tampering (version control, 8.4).
External tools and libraries. Keep an inventory of libraries and versions and update them; choose well-vetted components, especially for authentication and cryptography; check licence, security and history; use maintainable software from reputable sources; and make sure development resources stay available long enough.
Modifying a vendor package. Consider the risk to built-in controls, vendor consent, getting the change as a standard vendor update, who maintains it afterwards, and compatibility.
What the Standard Does NOT Require
- The standard does not mandate specific programming languages or frameworks
- It does not require 100% vulnerability-free code (impossible), but rather systematic prevention and detection
- It does not specify particular tools, but requires that code security analysis be performed
- It does not require manual review of every line of code, but rather risk-based review
Why Secure Coding Matters
The Vulnerability Epidemic
The OWASP Top 10 and the CWE Top 25 show how many serious vulnerabilities start in code. The current OWASP Top 10:2025 (final release January 2026) is:
- A01 Broken Access Control (now including server-side request forgery)
- A02 Security Misconfiguration
- A03 Software Supply Chain Failures
- A04 Cryptographic Failures
- A05 Injection (including cross-site scripting)
- A06 Insecure Design
- A07 Authentication Failures
- A08 Software or Data Integrity Failures
- A09 Security Logging and Alerting Failures
- A10 Mishandling of Exceptional Conditions
Many tools and contracts still reference the 2021 edition (A01 Broken Access Control, A02 Cryptographic Failures, A03 Injection, A04 Insecure Design, A05 Security Misconfiguration, A06 Vulnerable and Outdated Components, A07 Identification and Authentication Failures, A08 Software and Data Integrity Failures, A09 Security Logging and Monitoring Failures, A10 SSRF). Say which edition your standard uses. Most of these are prevented or caught by secure coding, review and testing. Some (insecure design, misconfiguration) also need A.8.27 and A.8.9.
The Indian Context
Indian organizations face unique secure coding challenges:
- Startup ecosystem: many startups build applications with limited security expertise
- Outsourcing hub: Indian developers write code for global clients; secure coding is a competitive advantage
- Digital India: Government applications processing citizen data (Aadhaar, UPI) require bulletproof code
- Fintech growth: payment applications in card scope must meet PCI DSS v4.0.1 Requirement 6; the RBI Master Direction on Digital Payment Security Controls (2021) sets application security requirements (it applies to banks, small finance banks, payments banks and credit-card-issuing NBFCs; fintechs working with them usually inherit it through contracts)
- AI/ML adoption: Indian enterprises building AI/ML applications need secure coding for model serving, data pipelines, and inference
- Skill gap: Computer science curricula in India often lack sufficient secure coding training
- DPDP Act 2023: code must implement notice, consent and erasure (s.5, s.6, s.8(7)) and the reasonable security safeguards in s.8(5)
- AI coding assistants: now common in Indian engineering teams; see the AI-assisted coding rules below
Scope and Applicability
In Scope
This control applies to:
- All in-house developed code: Web applications, mobile apps, APIs, microservices, batch jobs, scripts
- Customized third-party code: Modifications to COTS, plugin development, theme customization
- Infrastructure code: Terraform, CloudFormation, Ansible, Kubernetes manifests
- Database code: Stored procedures, triggers, functions, queries
- Client-side code: JavaScript, TypeScript, mobile client code, desktop applications
- AI/ML code: Model training scripts, inference code, data preprocessing, pipeline code
- Embedded/IoT code: Firmware, device drivers, edge computing code
- Outsourced code: Code written by vendors, contractors, or offshore teams
Out of Scope (with caveats)
- Unmodified third-party code: COTS software, SaaS (but configuration is in scope)
- Generated code: Code generated by frameworks or tools (but the generation process and templates are in scope)
- Configuration-only changes: Settings, permissions, feature flags (covered by A.8.9)
- Documentation-only changes: No code impact
Caveat: If you customize third-party code, the customizations are in scope. If you generate code from templates, the templates and generation logic are in scope.
Applicability by Organization Type
| Organization Type | Applicability | Typical Coding Focus |
|---|---|---|
| Software product companies | Critical | SaaS code, API code, mobile apps, client code |
| Financial services | Critical | Banking applications, payment processing, trading systems |
| Healthcare | Critical | PHI handling code, clinical systems, telemedicine apps |
| E-commerce | Critical | Payment code, customer data handling, inventory systems |
| Government | Critical | Citizen portals, Aadhaar integration, UPI code |
| Manufacturing | High | OT/IT integration code, IoT firmware, supply chain apps |
| Startups | High | Cloud-native code, rapid development, API-first |
| NGOs | Moderate | Donor management, grant processing, web applications |
Key Definitions and Terminology
| Term | Definition |
|---|---|
| Secure Coding | The practice of writing software code in a way that guards against the introduction of security vulnerabilities |
| Static Application Security Testing (SAST) | Analysis of source code or compiled code to find security vulnerabilities without executing the code |
| Dynamic Application Security Testing (DAST) | Testing of running applications to find security vulnerabilities by simulating attacks |
| Software Composition Analysis (SCA) | Analysis of third-party and open-source components for known vulnerabilities |
| Code Review | The systematic examination of source code by humans to find bugs, security flaws, and violations of coding standards |
| Security Code Review | A specialized code review focused on identifying security vulnerabilities |
| Input Validation | The process of ensuring that user input conforms to expected format, type, and range before processing |
| Output Encoding | The process of converting data into a safe format before displaying it to prevent injection attacks |
| Parameterized Query | A database query where user input is passed as parameters rather than concatenated into the query string |
| Secure Session Management | Practices for creating, managing, and destroying user sessions securely |
| CWE (Common Weakness Enumeration) | A community-developed list of common software and hardware weakness types |
| OWASP Top 10 | The ten most critical web application security risks |
| Defensive Coding | Writing code that continues to function correctly even in unexpected circumstances |
| Fail-Safe Defaults | Defaulting to the most secure option when configuration is ambiguous or missing |
| Code Linting | Automated checking of source code for programmatic and stylistic errors |
| CI/CD Pipeline | Continuous Integration/Continuous Deployment pipeline that automates building, testing, and deploying code |
Relationship to Other Controls
Directly Related Controls
| Control | Relationship |
|---|---|
| A.5.21, ICT supply chain | Third-party and open-source components |
| A.5.32, Intellectual property rights | Licences of libraries and code samples |
| A.6.3, Awareness, education and training | Secure-coding training for developers |
| A.8.4, Access to source code | Protect code from unauthorised access and tampering |
| A.8.8, Management of technical vulnerabilities | Handling reported vulnerabilities in your code |
| A.8.9, Configuration management | Secure defaults and configuration in code |
| A.8.15 / A.8.16, Logging; monitoring | Logging errors and suspected attacks |
| A.8.24, Use of cryptography | Correct use of cryptographic libraries |
| A.8.25, Secure development life cycle | Secure coding is a core SDLC phase |
| A.8.26, Application security requirements | Code implements the requirements |
| A.8.27, Secure system architecture | Code implements the design |
| A.8.29, Security testing | SAST, DAST and review verify the code |
| A.8.30, Outsourced development | Same rules for supplier code |
| A.8.32, Change management | Secure packaging and deployment of updates |
Framework Mapping
| Framework | Relevant Control / Reference |
|---|---|
| NIST CSF 2.0 | PR.PS-06 (secure software development), ID.RA-01 (vulnerabilities identified) |
| NIST SP 800-218 (SSDF) | PW.5 (create source code by following secure coding practices), PW.4 (reuse well-secured software), PW.7 (review code) |
| NIST SP 800-53 Rev 5 | SA-15 (development process, standards and tools), SA-11 (developer testing), SI-10 (input validation), SI-11 (error handling) |
| PCI DSS v4.0.1 | 6.2.1–6.2.4 (bespoke software developed securely, code review, attack prevention), 6.3.2 (component inventory) |
| COBIT 2019 | BAI03.03 (develop solution components) |
| CIS Controls v8 | 16.1, 16.4 (third-party components), 16.9 (developer training), 16.12 (code-level security checks) |
| OWASP | ASVS, SAMM (Implementation: Secure Build), Cheat Sheet Series |
| GDPR | Art 25 (data protection by design), Art 32 (security of processing) |
| DPDP Act 2023 | Section 8(4), 8(5) |
Implementation Roadmap (Week-by-Week)
Figure · Tiers
Maturity levels for secure coding

Phase 1: Foundation (Weeks 1–3)
Week 1: Policy and Standard Selection
- Draft the Secure Coding Policy
- Select secure coding standards (OWASP, CERT, MISRA, language-specific)
- Define scope (languages, frameworks, platforms in scope)
- Identify security champions
Week 2: Tool Selection and Setup
- Select SAST tools for primary languages
- Select SCA tools for dependency management
- Select code review tools (if not already using)
- Set up tools in CI/CD pipeline
Week 3: Baseline Assessment
- Run SAST on existing codebase to establish vulnerability baseline
- Run SCA to identify vulnerable dependencies
- Identify "hot spots", files/modules with highest vulnerability density
- Document baseline metrics
Deliverables: Secure Coding Policy, Tool selection, Baseline report, Vulnerability inventory
Phase 2: Pilot (Weeks 4–6)
Week 4-5: Developer Training
- Conduct secure coding training for all developers
- Focus on top 10 vulnerability types for your technology stack
- Hands-on secure coding workshop (code review exercise, CTF-style challenges)
- Train security champions on advanced topics
Week 6: Pilot with One Team
- Apply secure coding practices to one development team
- Enforce SAST in CI/CD for the pilot team
- Conduct peer code review for security
- Measure vulnerability reduction
Deliverables: Training completion records, Pilot team results, Training feedback, Improved practices
Phase 3: Rollout (Weeks 7–10)
Week 7-8: Organization-Wide Rollout
- Deploy secure coding practices to all development teams
- Enforce SAST/SCA in all CI/CD pipelines
- Establish security code review process
- Create secure coding reference materials (wiki, cheat sheets)
Week 9-10: Process Integration
- Integrate secure coding into SDLC gates
- Define vulnerability severity thresholds (block build on critical/high)
- Establish vulnerability remediation SLA
- Create developer security dashboard
Deliverables: Organization-wide deployment, Integrated gates, SLA definitions, Dashboard
Phase 4: Optimization (Weeks 11–14)
Week 11-12: Metrics and Monitoring
- Collect and analyze KPIs (see Section 13)
- Conduct first internal audit of secure coding process
- Identify improvement opportunities
- Update training with lessons learned
Week 13-14: Continuous Improvement
- Update secure coding standards with new vulnerability types
- Integrate DAST for runtime validation
- Automate more security checks (secrets detection, license compliance)
- Gamify secure coding (leaderboards, rewards)
Deliverables: KPI dashboard, Internal audit report, Updated standards, Gamification program
Maturity Model
| Level | Description | Typical Timeline |
|---|---|---|
| 1, Ad-hoc | No secure coding standard, no tools, no training, security found in testing | Pre-implementation |
| 2, Managed | Basic standard exists, SAST for some projects, initial training | Weeks 1–3 |
| 3, Defined | Standardized across all teams, SAST/SCA in all pipelines, regular training, code review process | Weeks 4–8 |
| 4, Quantitatively Managed | Metrics tracked, automated enforcement, vulnerability SLAs, advanced training | Weeks 9–12 |
| 5, Optimizing | AI-assisted code review, predictive vulnerability prevention, zero-vulnerability culture, continuous improvement | Ongoing |
Detailed Implementation Guidance
Secure Coding Standards by Vulnerability Type
Injection Prevention (SQL, NoSQL, OS Command, LDAP)
The Problem: User input is concatenated into queries or commands, allowing attackers to execute arbitrary code.
Secure Coding Rules:
- Rule 1: Never concatenate user input into SQL queries. Use parameterized queries or prepared statements.
- Rule 2: Use ORM frameworks that automatically parameterize queries (but be aware of ORM injection).
- Rule 3: Validate input before using it in any command context.
- Rule 4: Use stored procedures with parameterized inputs (but don't build dynamic SQL inside procedures).
- Rule 5: Escape/encode output when parameterized queries are not possible (legacy code only).
Language Examples:
## Python (SQL Injection Prevention)
## BAD: Concatenation
query = f"SELECT * FROM users WHERE username = '{username}'"
## GOOD: Parameterized query
cursor.execute("SELECT * FROM users WHERE username = %s", (username))
## Java (SQL Injection Prevention)
// BAD: Concatenation
String query = "SELECT * FROM users WHERE username = '" + username + "'";
// GOOD: PreparedStatement
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM users WHERE username = ?");
stmt.setString(1, username);
NoSQL Injection Prevention:
// Node.js (MongoDB) — BAD
const user = await db.collection('users').findOne({ username: req.body.username });
// Node.js (MongoDB) — GOOD
Broken Authentication Prevention
The Problem: Authentication mechanisms are implemented incorrectly, allowing attackers to compromise credentials or session tokens.
Secure Coding Rules:
- Rule 1: Use standard, well-tested authentication libraries (don't roll your own crypto or auth).
- Rule 2: Implement multi-factor authentication (MFA) for all sensitive accounts.
- Rule 3: Use strong password policies (minimum 12 characters, complexity requirements, breach detection).
- Rule 4: Implement secure session management (secure cookies, HttpOnly, SameSite, short timeouts, rotation).
- Rule 5: Protect against brute force (rate limiting, account lockout, CAPTCHA after failures).
- Rule 6: Implement secure password recovery (non-guessable tokens, time-limited, single-use).
- Rule 7: Use password hashing with slow algorithms (bcrypt, Argon2, PBKDF2), never MD5 or SHA-1.
Password Hashing Example:
## Python (bcrypt)
import bcrypt
## Hashing
hashed = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(rounds=12))
## Verification
if bcrypt.checkpw(password.encode('utf-8'), hashed):
# Authentication successful
// Java (Spring Security)
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(12); // strength factor 12
}
Sensitive Data Exposure Prevention
The Problem: Sensitive data (PII, PHI, financial data, credentials) is exposed in plaintext, weakly encrypted, or logged.
Secure Coding Rules:
- Rule 1: Classify data by sensitivity and apply appropriate protection.
- Rule 2: Encrypt sensitive data at rest using AES-256 or equivalent.
- Rule 3: Encrypt all data in transit using TLS 1.3 (disable TLS 1.0, 1.1, and weak cipher suites).
- Rule 4: Never store plaintext passwords, credit card numbers, or encryption keys in code.
- Rule 5: Use environment variables or secure vaults (HashiCorp Vault, AWS KMS, Azure Key Vault) for secrets.
- Rule 6: Mask or truncate sensitive data in logs (e.g., show only last 4 digits of credit card).
- Rule 7: Implement data retention and deletion policies in code.
- Rule 8: Use tokenization for payment card data (PCI DSS requirement).
Secret Management Example:
## Python — BAD: Hardcoded secret
API_KEY = "sk-1234567890abcdef"
## Python — GOOD: Environment variable
import os
API_KEY = os.environ.get('API_KEY')
## Python — BETTER: AWS Secrets Manager
import boto3
client = boto3.client('secretsmanager')
secret = client.get_secret_value(SecretId='api-key')
API_KEY = secret['SecretString']
Cross-Site Scripting (XSS) Prevention
The Problem: User input is rendered in HTML without proper encoding, allowing attackers to inject malicious scripts.
Secure Coding Rules:
- Rule 1: Validate and sanitize all user input on the server side.
- Rule 2: Encode output based on context (HTML, JavaScript, CSS, URL, XML).
- Rule 3: Use modern frameworks that auto-encode by default (React, Vue, Angular with proper usage).
- Rule 4: Implement Content Security Policy (CSP) to mitigate XSS impact.
- Rule 5: Never use
innerHTML,document.write, oreval()with user input. - Rule 6: Use
textContentorinnerTextinstead ofinnerHTMLwhen inserting text.
Output Encoding Example:
// JavaScript (React) — GOOD (auto-escapes by default)
function UserProfile({ user }) {
return <div>{user.name}</div>; // Auto-escaped
}
// JavaScript (React) — DANGEROUS (dangerouslySetInnerHTML)
function UserProfile({ user }) {
return <div dangerouslySetInnerHTML={{ __html: user.bio }} />; // Only if bio is trusted
}
// Java (JSP) — GOOD
// Java (JSP) — BAD
<%= user.getName() %> <%-- Does NOT escape --%>
Insecure Deserialization Prevention
The Problem: Untrusted data is deserialized without validation, allowing attackers to execute arbitrary code.
Secure Coding Rules:
- Rule 1: Never deserialize untrusted data.
- Rule 2: If deserialization is necessary, use safe formats (JSON with schema validation) instead of native serialization.
- Rule 3: Implement integrity checks (HMAC or digital signatures) on serialized data.
- Rule 4: Isolate deserialization in a low-privilege environment.
- Rule 5: Log deserialization exceptions and monitor for attacks.
- Rule 6: Use allowlists for deserialized classes (reject all except known safe classes).
Safe Serialization Example:
## Python — BAD (pickle with untrusted data)
data = pickle.loads(untrusted_data) # Can execute arbitrary code
## Python — GOOD (JSON with schema validation)
import jsonschema
schema = {
"type": "object",
"properties": {
"name": {"type": "string", "maxLength": 100},
"age": {"type": "integer", "minimum": 0, "maximum": 150}
}
}
data = json.loads(untrusted_data)
jsonschema.validate(data, schema)
Broken Access Control Prevention
The Problem: Users can access resources or perform actions outside their authorized permissions.
Secure Coding Rules:
- Rule 1: Deny by default, reject all requests except explicitly allowed ones.
- Rule 2: Implement access control on the server side (never trust client-side checks).
- Rule 3: Use a single, well-tested access control mechanism (don't mix multiple approaches).
- Rule 4: Implement least privilege, users get minimum permissions needed.
- Rule 5: Validate access control on every request (don't rely on cached permissions).
- Rule 6: Use indirect object references (e.g., mappings) rather than exposing internal IDs.
- Rule 7: Log all access control failures and alert on anomalies.
- Rule 8: Implement rate limiting for sensitive operations.
Access Control Example:
## Python (Flask) — BAD
@app.route('/api/users/<id>')
def get_user(id):
user = User.query.get(id)
return jsonify(user.to_dict()) # No authorization check!
## Python (Flask) — GOOD
@app.route('/api/users/<id>')
@login_required
def get_user(id):
user = User.query.get(id)
if not user:
abort(404)
if not current_user.can_access(user): # Server-side authorization
abort(403)
return jsonify(user.to_dict())
Security Misconfiguration Prevention
The Problem: Default configurations, incomplete setups, or verbose error messages expose security weaknesses.
Secure Coding Rules:
- Rule 1: Change all default passwords and credentials.
- Rule 2: Disable unnecessary features, services, and ports.
- Rule 3: Remove default accounts, sample applications, and unnecessary documentation.
- Rule 4: Implement secure headers (HSTS, X-Frame-Options, X-Content-Type-Options, CSP).
- Rule 5: Disable verbose error messages in production (no stack traces, no internal paths).
- Rule 6: Keep all frameworks, libraries, and platforms updated.
- Rule 7: Use automated configuration scanning (CIS benchmarks, security baselines).
- Rule 8: Separate environments (dev, test, prod) with different configurations.
Secure Headers Example:
## Python (Flask)
from flask import Flask
app = Flask(__name__)
@app.after_request
def set_security_headers(response):
response.headers['Strict-Transport-Security'] = 'max-age=31536000; includeSubDomains'
response.headers['X-Frame-Options'] = 'DENY'
response.headers['X-Content-Type-Options'] = 'nosniff'
response.headers['Content-Security-Policy'] = "default-src 'self'"
response.headers['X-Permitted-Cross-Domain-Policies'] = 'none'
return response
Using Components with Known Vulnerabilities Prevention
The Problem: Applications use outdated libraries and frameworks with known CVEs.
Secure Coding Rules:
- Rule 1: Maintain an inventory of all dependencies (Software Bill of Materials, SBoM).
- Rule 2: Use SCA tools to scan for known vulnerabilities in dependencies.
- Rule 3: Subscribe to security advisories for all frameworks and libraries used.
- Rule 4: Establish a vulnerability management process for dependencies (CVE monitoring, patch cycle).
- Rule 5: Use dependency pinning (lock files) to ensure reproducible builds.
- Rule 6: Regularly update dependencies (automated with tools like Dependabot, Renovate).
- Rule 7: Evaluate new dependencies for security posture before adoption.
- Rule 8: Remove unused dependencies (they still create attack surface).
Insufficient Logging and Monitoring Prevention
The Problem: Security events are not logged, or logs are not monitored, allowing attackers to operate undetected.
Secure Coding Rules:
- Rule 1: Log all security-relevant events (authentication, authorization, data access, changes, errors).
- Rule 2: Include sufficient context in logs (timestamp, user, IP, action, result, object).
- Rule 3: Protect logs from tampering (immutable storage, append-only).
- Rule 4: Never log sensitive data (passwords, tokens, credit card numbers, PII).
- Rule 5: Use structured logging (JSON) for easier parsing and analysis.
- Rule 6: Implement log integrity verification (hashing, digital signatures).
- Rule 7: Set up real-time alerting for critical security events.
- Rule 8: Centralize logs in a SIEM or log management platform.
Secure Logging Example:
## Python — GOOD: Structured logging without sensitive data
import logging
import json
logger = logging.getLogger('security')
## Log authentication event (no password!)
logger.info(json.dumps({
"event": "authentication_attempt",
"timestamp": "2026-01-15T10:30:00Z",
"user_id": user.id,
"ip_address": request.remote_addr,
"result": "success" if authenticated else "failure",
"mfa_used": True
}))
## BAD: Logging sensitive data
logger.info(f"User {username} logged in with password {password}") # NEVER DO THIS
Server-Side Request Forgery (SSRF) Prevention
The Problem: The server makes requests to attacker-controlled URLs, potentially accessing internal services or exfiltrating data.
Secure Coding Rules:
- Rule 1: Validate and sanitize all URLs before making server-side requests.
- Rule 2: Use allowlists for allowed URL schemes, hosts, and ports.
- Rule 3: Disable URL schemas that enable unwanted protocols (file://, ftp://, gopher://).
- Rule 4: Implement network segmentation to prevent SSRF from accessing internal services.
- Rule 5: Use DNS resolution validation to prevent DNS rebinding attacks.
- Rule 6: Log all server-side requests for monitoring and forensics.
- Rule 7: Implement response timeouts and size limits to prevent DoS.
Cryptographic Failures Prevention
The Problem: Weak cryptography, improper implementation, or hardcoded keys expose sensitive data.
Secure Coding Rules:
- Rule 1: Use well-tested cryptographic libraries (never roll your own crypto).
- Rule 2: Use strong, industry-standard algorithms (AES-256-GCM, RSA-4096, ECDSA P-256, ChaCha20-Poly1305).
- Rule 3: Use authenticated encryption (GCM, CCM, ChaCha20-Poly1305) rather than unauthenticated modes (CBC, ECB).
- Rule 4: Generate random values using cryptographically secure random number generators (CSPRNG).
- Rule 5: Never hardcode cryptographic keys, IVs, or salts in code.
- Rule 6: Implement key rotation and management via a key management service.
- Rule 7: Use proper key derivation functions (PBKDF2, Argon2, scrypt) for password-based keys.
- Rule 8: Validate certificates properly (hostname verification, certificate pinning for mobile).
- Rule 9: Disable weak protocols (SSL, TLS 1.0, TLS 1.1) and weak cipher suites.
- Rule 10: Protect against timing attacks (use constant-time comparison functions).
Secure Cryptography Example:
## Python (cryptography library)
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
import base64
import os
## Generate key from password using PBKDF2
salt = os.urandom(16)
kdf = PBKDF2HMAC(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
iterations=100000)
key = base64.urlsafe_b64encode(kdf.derive(password))
## Encrypt
f = Fernet(key)
token = f.encrypt(b"sensitive data")
## Decrypt
data = f.decrypt(token)
Language-Specific Secure Coding Guidelines
Python Secure Coding
- Use
parameterized querieswithsqlite3,psycopg2,MySQLdb - Use
cryptographylibrary for crypto, notpycrypto(unmaintained) - Use
secretsmodule for random tokens, notrandommodule - Use
html.escape()for HTML encoding,urllib.parse.quote()for URL encoding - Use
defusedxmlfor XML parsing (prevents XXE) - Use
ast.literal_eval()instead ofeval()for safe evaluation - Use
subprocess.run()with argument lists, notos.system()orsubprocess.call()with strings - Use
mypyfor type checking,banditfor security linting
Java Secure Coding
- Use
PreparedStatementfor all database queries - Use
OWASP Java Encoderfor output encoding - Use
Spring SecurityorApache Shirofor authentication/authorization - Use
JacksonwithenableDefaultTyping()disabled (prevents deserialization attacks) - Use
java.security.SecureRandomfor randomness - Use
java.nio.filefor file operations (prevents path traversal) - Use
@PreAuthorizeand@PostAuthorizefor access control - Use
ESAPIfor validation and encoding
JavaScript/Node.js Secure Coding
- Use
helmetmiddleware for security headers - Use
express-rate-limitfor rate limiting - Use
validatorlibrary for input validation - Use
bcryptorargon2for password hashing - Use
jsonwebtokenwith secure configuration for JWT - Use
sequelizeorknexwith parameterized queries - Use
dompurifyfor sanitizing HTML on the client side - Use
npm auditandsnykfor dependency scanning - Use
eslint-plugin-securityfor security linting
C/C++ Secure Coding
- Use
CERT C Secure Coding StandardorMISRA C - Use
strncpy,strncatinstead ofstrcpy,strcat(or better, usesnprintf) - Use
malloc/freecarefully (prevent use-after-free, double-free) - Use
static analysistools (Coverity, Clang Static Analyzer, PVS-Studio) - Use
AddressSanitizerandMemorySanitizerfor runtime detection - Use
integer overflowchecks (check before arithmetic) - Use
format stringprotection (always specify format string inprintf) - Use
bounded loopsto prevent infinite loops and DoS - Use
const correctnessto prevent accidental modification
Go Secure Coding
- Use
database/sqlwith parameterized queries - Use
crypto/randfor randomness, notmath/rand - Use
html/templatefor auto-escaping HTML templates - Use
gosecfor security linting - Use
deporgo modwith vulnerability scanning - Use
contextpackage for request cancellation and timeouts - Use
validatorpackage for input validation - Use
securecookiefor secure session management
Java/Kotlin (Android) Secure Coding
- Use
RoomorSQLiteDatabasewith parameterized queries - Use
EncryptedSharedPreferencesfor sensitive data storage - Use
Certificate pinningfor API communication - Use
Root detectionandTamper detection - Use
ProGuard/R8for code obfuscation (not security, but raises the bar) - Use
BiometricPromptfor biometric authentication - Use
SafetyNet APIorPlay Integrity APIfor device integrity - Use
NetworkSecurityConfigfor certificate pinning and cleartext traffic disabling
Swift (iOS) Secure Coding
- Use
Keychainfor sensitive data storage (not UserDefaults) - Use
URLSessionwith certificate pinning - Use
Codablewith safe decoding (prevents deserialization issues) - Use
NSPredicatecarefully (prevents injection) - Use
App Transport Security (ATS)to enforce HTTPS - Use
Jailbreak detectionlibraries - Use
SwiftLintwith security rules - Use
CryptoKitfor cryptography (iOS 13+)
AI-Assisted Coding Rules
AI coding assistants are now part of most teams' work. Treat their output as an unapproved code sample in 27002's terms:
- Do not paste secrets, customer data or confidential code into assistants that are not approved for that data.
- Use only assistants approved by the organisation, with data-retention and training settings agreed.
- Review AI-generated code like any untrusted contribution: same review, same SAST, SCA and secret scanning.
- Check licence and provenance where the assistant reproduces existing code.
- Do not let an assistant add dependencies without the usual component approval.
Code Samples From the Internet
Snippets from forums, gists and blogs are "unapproved code samples" until reviewed. Before use: understand what the code does, check its licence, check it against your standard (input validation, error handling, crypto), and record where it came from in the commit message.
IDE and Pre-Commit Guardrails
27002 asks you to configure development tools to help enforce secure code:
- pre-commit hooks for secret scanning and linting;
- IDE plugins for SAST and dependency warnings;
- dependency pinning (lock files) and an approved-registry setting;
- shared editor configuration checked into the repository.
Secure Coding in CI/CD Pipeline
Modern secure coding integrates directly into the CI/CD pipeline:
Developer Commit → Pre-Commit Hooks → CI Build → SAST → SCA →
Unit Tests → Build Artifact → DAST → Deploy → Runtime Monitoring
Stage 1: Pre-Commit Hooks
git-secretsordetect-secrets, prevent secrets from being committedlint-stagedwith security linting, catch issues before commithuskyfor Git hooks automation
Stage 2: CI Build, SAST
- Run SAST on every commit/PR
- Block builds on critical/high findings (configurable threshold)
- Generate SARIF output for GitHub/GitLab security dashboards
- Comment findings directly on PR for developer awareness
Stage 3: CI Build, SCA
- Scan dependencies for known vulnerabilities
- Block builds on CVEs above severity threshold
- Generate SBoM for compliance
- Suggest updates via Dependabot/Renovate
Stage 4: CI Build, Security Unit Tests
- Test authentication flows
- Test authorization boundaries
- Test input validation
- Test output encoding
- Test session management
- Test error handling
Stage 5: DAST
- Run DAST on staging environment
- Test running application for runtime vulnerabilities
- Validate that SAST findings are actually exploitable (or not)
- Test business logic vulnerabilities (SAST cannot find these)
Stage 6: Runtime Monitoring
- RASP (Runtime Application Self-Protection) for production
- Monitor for OWASP Top 10 attack patterns
- Block attacks in real-time
- Generate security events for SIEM
Security Code Review Process
Not all code can be reviewed by security experts, but security-critical code must be:
What to Review:
- Authentication and authorization code
- Input validation and sanitization functions
- Cryptographic implementations
- Session management code
- File upload and download handlers
- API endpoints (especially public-facing)
- Data access layers (database queries)
- Integration points (third-party APIs, webhooks)
- Error handling and logging
- Configuration handling
Code Review Checklist:
| Category | Check | Pass/Fail |
|---|---|---|
| Input Validation | All user input is validated before use | ☐ |
| Output Encoding | All output is contextually encoded | ☐ |
| Authentication | Authentication is enforced on all sensitive endpoints | ☐ |
| Authorization | Authorization checks are server-side and on every request | ☐ |
| Cryptography | Strong algorithms are used, keys are managed securely | ☐ |
| Session Management | Sessions are secure, timeout, rotation, invalidation | ☐ |
| Error Handling | Errors don't expose sensitive information | ☐ |
| Logging | Security events are logged without sensitive data | ☐ |
| Secrets | No hardcoded secrets, secrets are in vault/environment | ☐ |
| Dependencies | No known vulnerable dependencies | ☐ |
| File Operations | File paths are validated, upload restrictions enforced | ☐ |
| API Security | Rate limiting, authentication, input validation on APIs | ☐ |
| Configuration | Secure defaults, no debug mode in production | ☐ |
| Concurrency | Race conditions, deadlock prevention, thread safety | ☐ |
| Memory Safety | No buffer overflows, use-after-free, integer overflows | ☐ |
Code Review Process:
- Developer submits code for review (PR)
- Automated SAST runs and reports findings
- Peer reviewer checks code quality and functionality
- Security champion reviews security-critical code paths
- Security findings are addressed or risk-accepted
- Security approval is required for critical/high-risk changes
- Code is merged only after all approvals
Vulnerability Remediation Process
| Severity | SLA | Escalation |
|---|---|---|
| Critical | 24 hours | CISO notification, emergency patch process |
| High | 7 days | Security team tracking, daily status updates |
| Medium | 30 days | Development team tracking, weekly status |
| Low | 90 days | Backlog tracking, quarterly review |
| Informational | Next release | Backlog tracking |
Remediation Workflow:
- Vulnerability identified (SAST, DAST, manual review, external report)
- Vulnerability triaged and severity assigned (CVSS or custom scoring)
- Ticket created in tracking system (Jira, Azure DevOps, GitHub Issues)
- Developer assigned and fixes within SLA
- Fix verified by security team (re-test, code review)
- Deployed through normal change management
- Vulnerability closed in tracking system
- Metrics updated
Tools, Technologies, and Solutions
SAST Tools
| Tool | Languages | Best For |
|---|---|---|
| SonarQube | 25+ languages | Code quality + security, CI/CD integration |
| Checkmarx | 25+ languages | Enterprise, deep analysis, compliance |
| Fortify | 25+ languages | Enterprise, complete reporting |
| CodeQL | 10+ languages | GitHub-native, deep analysis, open source |
| Bandit | Python | Python-specific, fast, open source |
| Brakeman | Ruby | Ruby on Rails specific |
| ESLint Security Plugin | JavaScript | JavaScript/Node.js specific |
| gosec | Go | Go-specific, fast, open source |
| SpotBugs (FindSecBugs) | Java | Java-specific, extensive rule set |
| PMD Security | Java, Apex, JavaScript | Multi-language, fast |
| PVS-Studio | C/C++, C#, Java | Deep static analysis, MISRA support |
| Coverity | C/C++, Java, C# | Enterprise, high precision |
| Clang Static Analyzer | C/C++, Objective-C | Free, open source, IDE integration |
| Infer | C/C++, Java, Objective-C | Facebook's analyzer, fast, open source |
| Horusec | 15+ languages | Multi-language, open source, CI/CD |
| SonarCloud | 25+ languages | Cloud-based, SaaS, GitHub/GitLab integration |
| Reshift | Java, JavaScript | Cloud-native, lightweight, developer-friendly |
SCA (Software Composition Analysis) Tools
| Tool | Best For | Pricing model |
|---|---|---|
| OWASP Dependency-Check | Free, open source, multi-language | Free |
| Sonatype Nexus Lifecycle | Enterprise, policy enforcement | Enterprise pricing |
| WhiteSource (Mend) | Enterprise, complete | Enterprise pricing |
| GitHub Dependabot | GitHub-native, automatic PRs | Free |
| Renovate | Open source, multi-platform, configurable | Free |
| FOSSA | Compliance-focused, license + security | Free / Commercial |
| Black Duck | Enterprise, deep open source analysis | Enterprise pricing |
| Debricked | AI-powered, fast | Commercial |
| Jfrog Xray | Artifact repository integration | Commercial |
Secrets Detection Tools
| Tool | Best For |
|---|---|
| GitHub Secret Scanning | GitHub-native |
| GitLab Secret Detection | GitLab-native |
| TruffleHog | Open source, deep scanning, many providers |
| Git-secrets | AWS-focused, Git hooks |
| Detect-secrets | Yelp's tool, CI/CD friendly |
| Gitleaks | Fast, lightweight, open source |
| GitGuardian | Enterprise, complete |
| SpectralOps | Enterprise, AI-powered |
DAST Tools
| Tool | Best For | Pricing model |
|---|---|---|
| OWASP ZAP | Free, web applications, CI/CD | Free |
| Netsparker (Invicti) | Accurate, automated, CI/CD | Commercial |
| AppSpider | Enterprise, complete | Enterprise pricing |
| Probely | API security, developer-friendly | Commercial |
| CrackMapExec | Network + application | Free |
| W3AF | Open source, web application | Free |
| Nuclei | Fast, template-based, CI/CD | Free / Commercial |
RASP Tools
| Tool | Best For | Pricing model |
|---|---|---|
| Signal Sciences | WAF + RASP, cloud-native | Commercial |
| Imperva RASP | Enterprise, complete | Enterprise pricing |
| Contrast Security | IAST + RASP, developer-friendly | Commercial |
| Hdiv | IAST + RASP, Java | Commercial |
| ThreatMapper | Open source, cloud-native | Free (open source) |
| Sqreen | Developer-friendly, SaaS | Commercial |
| AppSensor | Open source, application-layer detection | Free |
Secure Coding Training Platforms
| Platform | Best For |
|---|---|
| HackerEarth | Indian platform, coding challenges |
| Codebashing | Developer-friendly, bite-sized lessons |
| OWASP WebGoat | Free, hands-on, web application security |
| OWASP Juice Shop | Free, modern, gamified |
| Damn Vulnerable Web App (DVWA) | Free, beginner-friendly |
| Mutillidae | Free, complete, OWASP Top 10 |
| Singahi Secure Coding Workshop | Indian context, customized, hands-on |
Policy and Procedure Templates
Secure Coding Policy (Template)
Template
Secure Coding Policy
Document ID: POL-SEC-CODE-001 Version: 1.0 Effective Date: [DATE] Owner: CISO / Security Lead Approved By: [Name], [Title] Review Cycle: Annual
1. Purpose
This policy establishes the requirement for secure coding practices across all software development at [Organization].
2. Scope
This policy applies to:
- All in-house developed software (web, mobile, API, desktop, embedded)
- Customized third-party software
- Infrastructure as Code (IaC)
- Database code (stored procedures, triggers, functions)
- AI/ML code (training, inference, pipelines)
- Code written by vendors, contractors, and outsourced teams
3. Policy Statements
3.1 Secure Coding Standards
- All developers must follow the [Organization] Secure Coding Standard, which is based on [OWASP / CERT / MISRA / custom] guidelines.
- The standard is language-specific and covers [Python, Java, JavaScript, Go, C/C++, etc.].
- The standard is updated annually and when new vulnerability types emerge.
3.2 Developer Training
- All developers must complete secure coding training before writing production code.
- Training is refreshed annually.
- New developers must complete training within 30 days of joining.
- Security champions receive advanced training.
3.3 Automated Code Security Analysis
- All code must pass SAST scanning before deployment.
- Critical and high severity vulnerabilities must be fixed before deployment.
- SAST is integrated into the CI/CD pipeline and runs on every commit.
- SCA is used to scan all dependencies for known vulnerabilities.
- Secrets detection prevents hardcoded secrets in repositories.
3.4 Manual Security Code Review
- Security-critical code paths must undergo manual security code review.
- Security champions conduct or participate in security code reviews.
- Code review checklist is used for all security reviews.
- Security findings must be resolved before code merge.
3.5 Vulnerability Management
- Vulnerabilities found in code must be tracked and remediated within defined SLAs:
- Critical: 24 hours
- High: 7 days
- Medium: 30 days
- Low: 90 days
- Vulnerabilities are tracked in the vulnerability management system.
- Risk acceptance requires CISO approval for critical/high vulnerabilities.
3.6 Secure Coding in CI/CD
- The CI/CD pipeline must include SAST, SCA, secrets detection, and security unit tests.
- Builds are blocked if critical/high vulnerabilities are found (configurable threshold).
- Security findings are reported to developers via PR comments and dashboards.
- DAST is run on staging environments before production deployment.
3.7 Outsourced Development
- Vendors and contractors must comply with this secure coding policy.
- Vendor code must pass the same SAST/SCA checks as in-house code.
- Security code review is required for all vendor-delivered code.
- Vendor contracts must include secure coding requirements and liability clauses.
3.7a Code Samples and AI Assistants
- Code from the internet and AI assistants is treated as unapproved until reviewed, licence-checked and scanned like any other code.
- Secrets, customer data and confidential code must not be entered into unapproved AI tools.
- Hard-coded passwords and unauthenticated web services are prohibited.
3.8 Emerging Technologies
- AI/ML code must follow the AI/ML Secure Coding Guidelines.
- IoT/embedded code must follow the Embedded Security Coding Guidelines.
- Blockchain code must follow the Blockchain Secure Coding Guidelines.
- Cloud-native code must follow the Cloud-Native Secure Coding Guidelines.
4. Roles and Responsibilities
- CISO: Owns the policy, ensures compliance, reports to board
- Security Lead: Maintains standards, reviews tools, trains champions
- Development Manager: Ensures team compliance, allocates time for security
- Security Champion: Conducts code reviews, trains team, advocates security
- Developer: Follows secure coding standard, fixes vulnerabilities, asks for help
- QA Lead: Validates security fixes, tests security requirements
- DevOps Lead: Maintains CI/CD security pipeline, configures tools
5. Exceptions
Exceptions require written CISO approval with risk acceptance and compensating controls.
6. Enforcement
Non-compliance may result in blocked deployments, audit findings, or disciplinary action.
7. Related Documents
- Application Security Requirements Policy (POL-APP-SEC-001)
- Secure Development Life Cycle Policy (POL-SDLC-001)
- Information Security Policy (POL-INFO-001)
- Application Security Testing Policy (POL-APP-TEST-001)
- AI/ML Secure Coding Guidelines (GL-AI-SEC-001)
8. Revision History
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0 | [DATE] | [Name] | Initial version |
Security Code Review Procedure (Template)
Template
Security Code Review Procedure
Document ID: PROC-SEC-REV-001 Version: 1.0 Effective Date: [DATE] Owner: Security Lead
1. Purpose
To define the procedure for conducting security code reviews.
2. Scope
All security-critical code paths in new and modified code.
3. When to Conduct Security Code Review
- New authentication/authorization code
- New input validation/sanitization code
- New cryptographic implementations
- New session management code
- New file upload/download handlers
- New API endpoints (especially public-facing)
- New database query code
- New integration points (third-party APIs, webhooks)
- New error handling and logging code
- New configuration handling code
- Changes to any of the above
4. Review Steps
Step 1: Automated Scanning (Pre-Review)
- Run SAST on the code
- Run SCA on dependencies
- Run secrets detection
- Review automated findings before manual review
Step 2: Manual Review Preparation
- Understand the code context and business logic
- Review the threat model for the application
- Identify security-critical code paths
- Prepare the code review checklist
Step 3: Manual Review Execution
- Review code line-by-line for security-critical paths
- Check each item on the code review checklist
- Identify business logic vulnerabilities (SAST cannot find these)
- Document findings with severity and remediation guidance
Step 4: Review Discussion
- Discuss findings with the developer
- Provide clear remediation guidance with code examples
- Prioritize findings based on severity and exploitability
- Agree on remediation timeline
Step 5: Remediation Verification
- Developer fixes the findings
- Re-run automated scanning to verify fixes
- Re-review critical/high findings manually
- Update tracking system
Step 6: Approval
- Security champion approves the code for security
- Code is merged only after security approval (for critical/high-risk changes)
5. Roles
- Reviewer: Security champion or security team member
- Developer: Code author, responsible for remediation
- Approver: Security lead (for critical/high-risk changes)
- Tracker: Vulnerability management system
6. Records
- Code review checklist (completed)
- Security findings report
- Remediation verification records
- Approval record
Risk Assessment and Treatment
Risk Assessment for Secure Coding
| Risk ID | Risk Description | Likelihood | Impact | Risk Level | Mitigation |
|---|---|---|---|---|---|
| R-001 | Developers not trained on secure coding, introducing vulnerabilities | High | High | Critical | Mandatory training, secure coding standard, SAST enforcement |
| R-002 | SAST tools not integrated, vulnerabilities missed | Medium | High | High | CI/CD integration, mandatory SAST, build blocking |
| R-003 | Security code review skipped for critical code | Medium | High | High | Mandatory review checklist, security champion program, merge gates |
| R-004 | Vulnerable dependencies not updated | High | Medium | High | SCA scanning, automated updates, dependency management |
| R-005 | Hardcoded secrets in code | Medium | High | High | Secrets detection, pre-commit hooks, vault usage, developer training |
| R-006 | Outsourced code not subject to secure coding | Medium | High | High | Vendor policy, contract terms, SAST/SCA for vendor code, review requirements |
| R-007 | Legacy code not reviewed for security | High | Medium | High | Legacy code review program, compensating controls, modernization plan |
| R-008 | Business pressure overrides security fixes | Medium | High | High | Risk acceptance process, CISO approval for critical/high deferrals, metrics visibility |
| R-009 | Secure coding standard not updated | Medium | Medium | Medium | Annual review, CVE integration, threat intelligence feed |
| R-010 | Developers circumvent security tools | Medium | Medium | Medium | Policy enforcement, audit logs, management commitment, culture change |
Risk Treatment Options
| Risk | Treatment | Residual Risk |
|---|---|---|
| R-001 | Training + standard + mentoring | Low |
| R-002 | CI/CD integration + automated enforcement | Low |
| R-003 | Mandatory process + checklist + champion program | Low |
| R-004 | SCA + automated updates + dependency pinning | Low |
| R-005 | Pre-commit hooks + vault + training + detection | Low |
| R-006 | Vendor management + contract + scanning | Low |
| R-007 | Legacy program + compensating controls + modernization | Medium |
| R-008 | Risk acceptance + governance + metrics | Low |
| R-009 | Annual review + automated monitoring | Low |
| R-010 | Culture + policy + enforcement + rewards | Low |
Audit and Compliance Checklist
Pre-Audit Self-Assessment
| # | Question | Evidence | Status |
|---|---|---|---|
| 1 | Is there a documented Secure Coding Policy? | Policy document | ☐ |
| 2 | Is there a documented Secure Coding Standard? | Standard document | ☐ |
| 3 | Are developers trained on secure coding? | Training records | ☐ |
| 4 | Is SAST integrated into CI/CD? | CI/CD pipeline config | ☐ |
| 5 | Is SCA integrated into CI/CD? | CI/CD pipeline config | ☐ |
| 6 | Are critical/high vulnerabilities blocked from deployment? | Pipeline records | ☐ |
| 7 | Is there a security code review process? | Procedure document | ☐ |
| 8 | Are security code reviews conducted for critical code? | Review records | ☐ |
| 9 | Is there a vulnerability remediation SLA? | SLA document | ☐ |
| 10 | Are vulnerabilities tracked to closure? | Vulnerability tracking system | ☐ |
| 11 | Are secrets detected in code before commit? | Pre-commit hook config | ☐ |
| 12 | Are there security champions in development teams? | Champion list | ☐ |
| 13 | Is there a secure coding reference/wiki? | Wiki/documentation | ☐ |
| 14 | Is secure coding covered in onboarding? | Onboarding records | ☐ |
| 15 | Is outsourced code subject to secure coding requirements? | Vendor contracts | ☐ |
| 16 | Is there a process for handling new CVEs in dependencies? | Process document | ☐ |
| 17 | Are secure coding metrics tracked? | Metrics dashboard | ☐ |
| 18 | Is there a language-specific secure coding standard? | Language standards | ☐ |
| 19 | Is secure coding integrated into the SDLC? | SDLC documentation | ☐ |
| 20 | Are security unit tests written for critical functionality? | Test records | ☐ |
| 21 | Is DAST run on applications before deployment? | DAST records | ☐ |
| 22 | Is there a process for risk-accepting vulnerabilities? | Risk acceptance records | ☐ |
| 23 | Are developers incentivized for secure coding? | Incentive records | ☐ |
| 24 | Is there a process for reporting security bugs? | Bug bounty / reporting process | ☐ |
| 25 | Are secure coding practices audited? | Audit records | ☐ |
| 26 | Is there a secure coding maturity assessment? | Assessment records | ☐ |
| 27 | Are AI/ML code covered by secure coding guidelines? | AI/ML guidelines | ☐ |
| 28 | Is there a process for handling false positives from SAST? | False positive process | ☐ |
| 29 | Are secure coding standards reviewed annually? | Review records | ☐ |
| 30 | Are build logs retained for audit? | Build log retention | ☐ |
Auditor Interview Questions
Be prepared to answer:
- "What secure coding standard does your organization follow?"
- "How are developers trained on secure coding?"
- "Show me the SAST configuration for [application]."
- "How do you handle security code review?"
- "What is your vulnerability remediation SLA?"
- "How do you prevent hardcoded secrets in code?"
- "How do you handle vulnerable dependencies?"
- "How do you enforce secure coding on outsourced development?"
- "Show me evidence that security-critical code is reviewed."
- "How do you measure secure coding effectiveness?"
Common Audit Findings and How to Avoid Them
| Finding | Cause | Prevention |
|---|---|---|
| "No secure coding standard" | Process gap | Create and approve standard; base on OWASP/CERT |
| "SAST not integrated into CI/CD" | Tool gap | Integrate SAST; block builds on critical findings |
| "Developers not trained on secure coding" | Training gap | Mandatory training; annual refresh; onboarding |
| "Security code review not conducted" | Process gap | Mandatory checklist; champion program; merge gates |
| "Vulnerabilities not tracked to closure" | Tracking gap | Vulnerability management system; SLA enforcement |
| "Hardcoded secrets in repository" | Prevention gap | Pre-commit hooks; secrets detection; vault training |
| "Outdated dependencies with known CVEs" | Dependency gap | SCA scanning; automated updates; dependency management |
| "No secure coding for outsourced code" | Vendor gap | Vendor contract terms; SAST/SCA for vendor code |
| "Legacy code not reviewed" | Legacy gap | Legacy review program; compensating controls |
| "No DAST for runtime validation" | Testing gap | DAST on staging; runtime monitoring |
Metrics and KPIs
Figure · Measures
The measures that show A.8.28 is working
- SAST Coverage100%Monthly
- SCA Coverage100%Monthly
- Secrets Detection Coverage100%Monthly
- Security Code Review Rate> 90%Monthly
- Training Completion Rate100%Quarterly
Process Metrics
| Metric | Formula | Target | Frequency |
|---|---|---|---|
| SAST Coverage | (# of apps with SAST / # of apps) × 100 | 100% | Monthly |
| SCA Coverage | (# of apps with SCA / # of apps) × 100 | 100% | Monthly |
| Secrets Detection Coverage | (# of repos with secrets detection / # of repos) × 100 | 100% | Monthly |
| Security Code Review Rate | (# of critical code paths reviewed / # of critical code paths) × 100 | > 90% | Monthly |
| Training Completion Rate | (# of trained developers / # of developers) × 100 | 100% | Quarterly |
| Vulnerability Remediation SLA Compliance | (# of vulns fixed within SLA / # of vulns) × 100 | > 90% | Monthly |
| Build Block Rate | (# of builds blocked for security / # of builds) × 100 | < 5% | Monthly |
| Champion Coverage | (# of teams with champion / # of teams) × 100 | 100% | Quarterly |
| Policy Update Rate | (# of policy updates / year) | > 2 | Annually |
| False Positive Rate | (# of false positives / # of SAST findings) × 100 | < 20% | Quarterly |
Outcome Metrics
| Metric | Formula | Target | Frequency |
|---|---|---|---|
| Vulnerability Density | Critical/high vulnerabilities per 1000 LOC | < 0.5 | Per release |
| Mean Time to Remediate (MTTR) | Average days from discovery to fix | < 7 days (critical) | Monthly |
| Production Security Defects | Security defects found in production per release | < 2 | Per release |
| Dependency Vulnerability Rate | (# of vulnerable dependencies / # of total dependencies) × 100 | < 5% | Monthly |
| Secrets in Code Rate | (# of secrets found in code / # of code scans) × 100 | 0 | Monthly |
| Security Test Pass Rate | (# of security tests passed / # of security tests) × 100 | > 95% | Per release |
| Compliance Audit Findings | Secure coding-related audit findings | 0 | Per audit |
| Developer Security Score | Average security score per developer | > 80/100 | Quarterly |
| Time to Security Audit Readiness | Time to prepare for security audit | < 2 weeks | Per audit |
| Cost of Security Rework | Cost of fixing security issues post-release | Decreasing | Quarterly |
Dashboard Sample
┌─────────────────────────────────────────────────────────────────────┐
│ SECURE CODING DASHBOARD │
│ [Organization] — [Month Year] │
├─────────────────────────────────────────────────────────────────────┤
│ SAST COVERAGE: 100% ██████████████████████ Target: 100%│
│ SCA COVERAGE: 100% ██████████████████████ Target: 100% │
│ REVIEW RATE: 94% ███████████████████░░░ Target: 90% │
│ TRAINING: 98% ████████████████████░░ Target: 100% │
│ VULN DENSITY: 0.4 ██░░░░░░░░░░░░░░░░░░░ Target: <0.5 │
│ MTTR (CRITICAL): 2.1 days ███░░░░░░░░░░░░░░░░░░ Target: <7 │
│ PROD DEFECTS: 1 ░░░░░░░░░░░░░░░░░░░░░ Target: <2 │
│ DEP VULN RATE: 3% █░░░░░░░░░░░░░░░░░░░░ Target: <5% │
│ SECRETS IN CODE: 0 ░░░░░░░░░░░░░░░░░░░░░ Target: 0 │
│ SEC TEST PASS: 97% ███████████████████░░░ Target: 95% │
└─────────────────────────────────────────────────────────────────────┘
Common Pitfalls and How to Avoid Them
Pitfall 1: "SAST Is Too Noisy"
Symptom: Developers ignore SAST findings because of too many false positives.
Reality: Modern SAST tools (Semgrep, CodeQL) have significantly reduced false positives. Configuration tuning and custom rule development can further reduce noise.
Solution:
- Tune SAST rules to your technology stack
- Suppress false positives with documented justification
- Use high-confidence rules only for build blocking
- Gradually expand rule set as developers become more security-aware
Pitfall 2: "We Don't Have Time for Secure Coding"
Symptom: Security is deprioritized to meet deadlines.
Reality: Fixing vulnerabilities in production takes 10-100x longer than fixing them during development. Secure coding saves time overall.
Solution:
- Show time-to-fix data: development vs. production
- Integrate security into daily workflow (not separate activity)
- Use automation to reduce manual effort
- Start with critical/high vulnerabilities only
Pitfall 3: "We Use a Framework, So We're Secure"
Symptom: Developers assume frameworks handle all security.
Reality: Frameworks provide security features, but developers must use them correctly. Frameworks don't prevent business logic flaws, misconfiguration, or custom code vulnerabilities.
Solution:
- Train developers on framework security features (and how to misuse them)
- Review custom code even when using secure frameworks
- Test for business logic vulnerabilities (DAST, manual testing)
- Don't disable framework security features for convenience
Pitfall 4: "Security Is the Security Team's Job"
Symptom: Developers write code and "throw it over the wall" to security.
Reality: Security is everyone's responsibility. Developers who write insecure code create work for themselves and the security team.
Solution:
- Security champion program
- Developer training and empowerment
- Make security part of developer KPIs
- Reward secure coding, don't just punish mistakes
Pitfall 5: "We Reviewed It Once, We're Done"
Symptom: Code is reviewed once and never revisited.
Reality: New vulnerabilities are discovered constantly. Code must be re-scanned when new CVEs affect dependencies, when new SAST rules are added, and when the threat landscape changes.
Solution:
- Continuous scanning in CI/CD
- Regular dependency updates and re-scanning
- Annual code security audit
- Monitor for new CVEs affecting your stack
Pitfall 6: "Outsourced Code Is Not Our Problem"
Symptom: Vendor code is accepted without security review.
Reality: Vendor code running in your environment is your risk. Many breaches originate from vulnerable third-party components.
Solution:
- Include secure coding requirements in vendor contracts
- Run SAST/SCA on vendor code
- Conduct security acceptance testing
- Include security SLAs in vendor agreements
Pitfall 7: "We Only Need to Fix Critical Vulnerabilities"
Symptom: Only critical vulnerabilities are fixed; highs and mediums are ignored.
Reality: Attack chains often combine medium vulnerabilities to achieve critical impact. A medium vulnerability + a medium vulnerability = critical breach.
Solution:
- Fix all vulnerabilities within SLA, not just critical
- Understand attack chain risk (how vulnerabilities combine)
- Use risk-based prioritization, not severity-only
Pitfall 8: "Security Tools Replace Secure Coding Knowledge"
Symptom: Developers rely entirely on SAST/DAST and don't learn secure coding.
Reality: Tools catch known patterns but miss business logic flaws, novel vulnerabilities, and architectural issues. Developer knowledge is irreplaceable.
Solution:
- Invest in training, not just tools
- Use CTFs and hands-on labs (OWASP Juice Shop, WebGoat)
- Encourage developers to understand WHY vulnerabilities exist, not just fix them
- Security champions mentor developers on secure coding patterns
Illustrative Scenarios
Hypothetical scenarios: composite examples for guidance, not real organisations or verified outcomes.
Scenario 1: Fast-Growing SaaS Team With No Coding Standard
Situation. An HR-tech SaaS company grows from 10 to 40 developers in a year. A penetration test finds SQL injection, cross-site scripting and broken access control. There is no coding standard, no SAST and no security review.
What applying 8.28 looks like.
- A short secure coding standard for the stack (Django and React), based on the OWASP Cheat Sheets, with a minimum baseline.
- SAST, SCA and secret scanning in CI, plus pre-commit secret scanning and IDE plugins.
- A secure-coding workshop with hands-on labs; one security champion per team.
- Security review by a champion for authentication, authorisation and data-access code.
- A library inventory (SBOM) and a rule that AI-generated and copied code gets the same review.
Lesson. Standards, automation and trained reviewers together change outcomes; tools alone do not.
Scenario 2: Legacy Trading Platform
Situation. A securities firm's trading platform includes old Java code with known deserialization and injection risks. SAST is run by hand once a quarter, and dependency vulnerabilities are not tracked.
What applying 8.28 looks like.
- SAST and SCA in every build, with gates on new critical findings.
- A Java secure coding standard drawn from the SEI CERT Oracle Coding Standard for Java and OWASP guidance.
- Mandatory security review for trading-critical code; security unit tests for authentication and authorisation paths.
- A risk-ranked plan to fix legacy findings, with accepted risks recorded.
- Evidence kept for SEBI CSCRF reviews and ISO audits.
Lesson. For legacy code, stop new defects first, then pay down the old ones by risk.
Multi-Framework Mapping
Figure · Matrix
Comparison: Level 1 to Level 3
OWASP ASVS Mapping
| ASVS Level | Use for | Relevance to A.8.28 |
|---|---|---|
| Level 1 | All applications | Baseline coding checks (validation, encoding, authentication basics) |
| Level 2 | Most business applications | Default verification level for secure coding |
| Level 3 | Critical applications | Deepest verification |
ASVS chapters on validation and encoding, cryptography, error handling and logging, data protection, files and APIs give testable coding requirements. ASVS 5.0 (May 2025) reorganised the chapters; reference the version you use.
PCI DSS v4.0.1 Mapping
| PCI DSS Requirement | Secure Coding Focus |
|---|---|
| 6.2.1 | Bespoke and custom software developed securely |
| 6.2.2 | Developers trained at least once every 12 months |
| 6.2.3 | Code reviewed before release to find and fix vulnerabilities |
| 6.2.4 | Techniques that prevent common attacks (injection, XSS, access-control flaws, and others) |
| 6.3.2 | Inventory of bespoke and third-party components |
DPDP Act 2023: Coding Implications
| DPDP Act Section | Secure Coding Implication |
|---|---|
| Section 8(4) | Appropriate technical and organisational measures, code must implement data minimization, encryption, access control |
| Section 8(5) | Reasonable security safeguards, code must implement technical safeguards for data protection |
| Section 8(6) | Personal data breach intimation, code must detect and log breaches |
NIST SP 800-53 Rev 5 Mapping
| NIST Control | Description | A.8.28 Mapping |
|---|---|---|
| SA-15 | Development process, standards, tools | Secure coding standards and tools |
| SI-10 | Information input validation | Input validation in code |
| SI-11 | Error handling | Secure error handling in code |
| SC-28 | Protection of information at rest | Encryption in code |
| AC-6 | Least privilege | Authorization in code |
| AU-6 | Audit review | Logging in code |
COBIT 2019 Mapping
| COBIT Practice | Description | A.8.28 Mapping |
|---|---|---|
| BAI03.03 | Develop solution components | Secure coding during development |
| BAI03.06 | Perform quality assurance | Code review and testing |
| BAI06.01 | Evaluate, prioritise and authorise change requests | Secure deployment of updates |
CIS Controls v8 Mapping
| CIS Safeguard | Implementation Group | A.8.28 Mapping |
|---|---|---|
| 16.1 Secure application development process | IG2 | Coding standard within the process |
| 16.4 Inventory of third-party software components | IG2 | Library inventory |
| 16.9 Train developers in application security | IG2 | Developer training |
| 16.12 Code-level security checks | IG3 | SAST and code analysis |
Regulatory and Industry Context
India
| Regulation | Secure Coding Relevance | Key Mandates |
|---|---|---|
| DPDP Act 2023 | Critical | Section 8(4) (Appropriate technical and organisational measures); code must implement technical safeguards |
| IT Act 2000 | High | Section 43A: Reasonable security practices; secure coding is a reasonable practice |
| RBI Guidelines | Critical for banks | Cybersecurity framework requires secure coding for banking applications |
| SEBI Regulations | Critical for markets | Cyber resilience framework requires secure coding for trading systems |
| IRDAI Guidelines | Critical for insurance | Information security requires secure coding for customer data handling |
| CERT-In | High | Security best practices include secure coding |
International
| Regulation | Relevance | Key Mandates |
|---|---|---|
| PCI DSS v4.0.1 | Critical for card data | Req 6.3, 6.5: Secure coding for payment applications |
| GDPR | High | Art 25: Data protection by design; Art 32: Security of processing |
| HIPAA | Critical for health | Security Rule: Technical safeguards require secure coding |
| SOX | High | IT general controls require secure coding for financial systems |
| NIST CSF 2.0 | High | PR.PS-06: Secure software development practices |
| CCPA/CPRA | High | Security requirements for personal information handling |
| LGPD | High | Security measures in code |
| PDPA | High | Protection obligations require secure coding |
Roles and Responsibilities (RACI)
RACI Matrix for Secure Coding
| Activity | CISO | Security Lead | Dev Manager | Security Champion | Developer | QA Lead | DevOps Lead |
|---|---|---|---|---|---|---|---|
| Define secure coding policy | A | R | C | C | I | I | I |
| Maintain secure coding standard | I | R/A | C | C | C | I | I |
| Select SAST/SCA tools | A | R | C | C | I | I | C |
| Configure CI/CD security | I | C | I | C | I | I | R/A |
| Conduct developer training | I | R/A | C | C | I | I | I |
| Write secure code | I | C | I | C | R/A | I | I |
| Security code review | I | A | I | R | C | C | I |
| Fix vulnerabilities | I | C | C | C | R/A | I | I |
| Verify fixes | I | A | I | C | C | R | I |
| Track vulnerabilities | I | R/A | C | C | I | C | I |
| Manage dependencies | I | C | I | C | C | I | R/A |
| Audit secure coding | R/A | C | I | I | I | C | I |
| Metrics and reporting | R/A | C | I | I | I | I | C |
| Vendor secure coding | A | R | C | C | I | I | I |
| Emerging tech guidelines | A | R | C | C | C | I | I |
Legend: R = Responsible, A = Accountable, C = Consulted, I = Informed
Role Descriptions
| Role | Key Responsibilities | Required Skills |
|---|---|---|
| CISO | Policy ownership, governance, board reporting, exception approval | Security leadership, risk management, business acumen |
| Security Lead | Maintains standards, configures tools, trains champions, reviews code | Application security, secure coding, SAST/DAST, training |
| Development Manager | Ensures team compliance, allocates time for security, supports training | Development management, security awareness, team leadership |
| Security Champion | Conducts code reviews, trains team, advocates security, triages findings | Development + security, communication, influence, mentoring |
| Developer | Writes secure code, fixes vulnerabilities, asks for help, participates in training | Software development, secure coding practices, testing |
| QA Lead | Validates security fixes, tests security requirements, supports DAST | Testing methodologies, security testing, automation |
| DevOps Lead | Maintains CI/CD security pipeline, configures SAST/SCA, manages secrets | DevOps, CI/CD, security tools, infrastructure |
Documentation and Evidence Requirements
Recommended Documentation
ISO 27001 does not mandate specific documents for this control. If you select it, keep the documented information you need to show it is planned and working (clause 7.5), and set retention in your own retention schedule. Typical records:
| Document | Purpose | Suggested retention | Owner |
|---|---|---|---|
| Secure Coding Policy | Governance framework | Per retention schedule | CISO |
| Secure Coding Standard | Developer rules and guidelines | Current version + your retention period | Security Lead |
| Language-Specific Guidelines | Detailed rules per language | Current version + your retention period | Security Lead |
| SAST Configuration | Tool setup and rules | Current version + your retention period | DevOps Lead |
| SCA Configuration | Dependency scanning setup | Current version + your retention period | DevOps Lead |
| Code Review Checklist | Security review checklist | Current version + your retention period | Security Lead |
| Training Materials | Developer training content | Per retention schedule | Security Lead |
| Training Records | Staff competency evidence | Per retention schedule | HR / Security |
| Vulnerability Tracking Records | Vulnerability lifecycle | Per retention schedule | Security Lead |
| Remediation Records | Fix verification evidence | Per retention schedule | Developer |
| Build Logs | CI/CD pipeline evidence | 1 year | DevOps Lead |
| Audit Records | Audit findings and remediation | Per retention schedule | CISO |
| Exception Records | Approved deviations | Per retention schedule | CISO |
| Metrics Reports | KPI tracking | Per retention schedule | Security Lead |
| Champion Program Records | Champion assignments and activities | Per retention schedule | Security Lead |
| Vendor Secure Coding Requirements | Contract terms for outsourced code | Per retention schedule | Security Lead |
| Secure Coding Wiki/Documentation | Developer reference | Current version | Security Lead |
| False Positive Records | Suppressed findings with justification | Per retention schedule | Security Lead |
| Annual Standard Review | Standard update evidence | Per retention schedule | Security Lead |
Evidence for Audit
| Audit Question | Evidence Required |
|---|---|
| "Show me the secure coding policy" | Approved Secure Coding Policy |
| "Show me the secure coding standard" | Secure Coding Standard document |
| "How are developers trained?" | Training records, completion certificates |
| "Show me SAST configuration" | CI/CD pipeline config, SAST tool config |
| "Show me vulnerability tracking" | Vulnerability management system, tracking records |
| "How are vulnerabilities remediated?" | Remediation records, SLA compliance reports |
| "Show me security code review records" | Review checklists, meeting records |
| "How do you prevent secrets in code?" | Pre-commit hook config, secrets detection records |
| "How do you handle dependencies?" | SCA records, dependency update records |
| "How do you handle outsourced code?" | Vendor contracts, SAST/SCA records for vendor code |
Continuous Improvement
Improvement Cycle
Plan → Implement → Measure → Review → Improve
Plan: Set targets for vulnerability density, MTTR, training coverage, tool effectiveness.
Implement: Deploy tools, conduct training, enforce code review, track vulnerabilities.
Measure: Track KPIs, conduct surveys, analyze audit results, monitor incidents.
Review: Monthly metrics review, quarterly process review, annual complete review.
Improve: Update standards, tune tools, enhance training, adopt new techniques, gamify.
Improvement Triggers
| Trigger | Action |
|---|---|
| New CVE affecting your stack | Update SCA rules, notify developers, patch dependencies |
| New vulnerability type discovered | Update secure coding standard, add SAST rules, train developers |
| SAST tool update with new rules | Evaluate new rules, add to CI/CD, train on new findings |
| Security incident | Root cause analysis, update standard if coding issue, train on incident |
| Audit finding | Update process, standard, or training to address finding |
| Developer feedback | Refine standard, improve training, tune tools |
| New language/framework adopted | Create language-specific guidelines, configure SAST |
| Industry benchmark | Compare metrics, set improvement targets |
| Tool evolution | Evaluate new tools, migrate if beneficial |
| Regulatory change | Update compliance checklist, add regulatory requirements to standard |
Maturity Advancement Path
| From Level | To Level | Key Actions | Typical Timeline |
|---|---|---|---|
| 1 (Ad-hoc) | 2 (Managed) | Create policy + standard; deploy SAST for pilot; conduct initial training | 1–2 months |
| 2 (Managed) | 3 (Defined) | Deploy to all teams; integrate CI/CD; establish code review; train champions | 3–4 months |
| 3 (Defined) | 4 (Quantified) | Define KPIs; enforce SLAs; gamify; advanced training; DAST integration | 3–4 months |
| 4 (Quantified) | 5 (Optimizing) | AI-assisted review; predictive prevention; zero-vulnerability culture; continuous improvement | 6–12 months |
FAQ
Q1: What is the most important secure coding practice?
A: Input validation is the single most important practice. The majority of vulnerabilities (injection, XSS, XXE, SSRF, path traversal) are caused by trusting user input. Validate every input, every time, on the server side.
Q2: Do we need to review every line of code for security?
A: No. Focus security code review on security-critical code paths: authentication, authorization, input validation, output encoding, cryptography, session management, file handling, and API endpoints. Use automated tools for the rest.
Q3: How do we handle legacy code that has no secure coding?
A: Prioritize by risk. Use SAST to identify the most vulnerable files. Apply compensating controls (WAF, input validation at gateway) where code cannot be changed immediately. Plan a remediation roadmap.
Q4: What if developers don't have time to learn secure coding?
A: Make secure coding part of their daily workflow, not a separate activity. Use IDE plugins (Snyk, Semgrep) that show vulnerabilities as they code. Use short, bite-sized training (10-minute modules) rather than week-long courses. Start with the top 5 vulnerability types for your stack.
Q5: Are there secure coding standards for AI/ML?
A: Yes, but they are evolving. Focus on: input sanitization for model inference, adversarial strength testing, secure model serialization, data pipeline validation, and access control for model artifacts. See the OWASP Top 10 for LLM Applications and the OWASP Machine Learning Security Top 10.
Q6: How do we measure secure coding effectiveness?
A: Track vulnerability density, MTTR, production security defects, dependency vulnerability rate, and training completion. See Section 13 for a full KPI framework.
Q7: What is the best SAST tool?
A: The best tool depends on your languages, budget, and integration needs. For small teams: Semgrep (free, fast, customizable). For enterprise: Checkmarx or SonarQube. For GitHub-native: CodeQL. For open source: SonarQube Community + OWASP Dependency-Check.
Q8: How do we handle false positives from SAST?
A: Document false positives with justification and suppress them in the tool. Tune rules to your technology stack. Use high-confidence rules only for build blocking. Track false positive rate as a KPI.
Q9: Should we use SAST, DAST, or both?
A: Both. SAST finds code-level issues early (shift-left). DAST finds runtime issues that SAST misses (business logic, configuration, environment). SCA is also essential for dependency vulnerabilities. IAST (Contrast, Hdiv) provides the best of both worlds but requires runtime instrumentation.
Q10: How do we enforce secure coding on outsourced development?
A: Include secure coding requirements in contracts, run SAST/SCA on vendor code, require security code review for deliverables, and include security acceptance criteria in acceptance testing.
Q11: What is the difference between SAST and SCA?
A: SAST (Static Application Security Testing) scans your source code for security vulnerabilities. SCA (Software Composition Analysis) scans your third-party dependencies for known vulnerabilities (CVEs). Both are essential and complement each other.
Q12: How often should we train developers on secure coding?
A: Initial training before writing production code. Annual refresher for all developers. Advanced training for security champions. Just-in-time training when new vulnerability types or technologies are introduced.
Q13: Can we use AI/LLMs to help with secure coding?
A: Yes, with caution. AI coding assistants (GitHub Copilot, ChatGPT) can suggest secure code, but they also suggest insecure code. Developers must review AI-generated code for security. Use AI for: generating secure coding examples, explaining vulnerability fixes, creating test cases. Do NOT use AI for: cryptographic implementations, security-critical code without review, or replacing security training.
Q14: What is the Security Champion program?
A: A program where one developer per team is trained as a security advocate. Champions conduct security code reviews, mentor teammates on secure coding, triage security findings, and bridge the gap between the security team and development team.
Q15: How do we handle security bugs reported by users or external researchers?
A: Establish a vulnerability disclosure policy (VDP) and bug bounty program if appropriate. Have a clear process for receiving, triaging, and responding to external reports. Thank reporters, fix issues promptly, and disclose responsibly.
References and Further Reading
Standards and Guidelines
- ISO/IEC 27001:2022: Information Security, Cybersecurity and Privacy Protection, Information Security Management Systems, Requirements. ISO, 2022.
- ISO/IEC 27002:2022: Information Security, Cybersecurity and Privacy Protection, Information Security Controls. ISO, 2022.
- NIST SP 800-53 Rev 5: Security and Privacy Controls for Information Systems and Organizations. NIST, 2020.
- OWASP Top 10:2025 (final January 2026; the 2021 edition is still widely referenced). OWASP.
- OWASP Application Security Verification Standard (ASVS) 5.0 (2025); v4.0.3 (2021) is still widely used.
- OWASP Software Assurance Maturity Model (SAMM) v2.0. OWASP, 2020.
- CWE Top 25: Most Dangerous Software Weaknesses. MITRE, 2023.
- SEI CERT C Coding Standard (2016 edition; maintained online): Carnegie Mellon Software Engineering Institute.
- SEI CERT C++ Coding Standard and SEI CERT Oracle Coding Standard for Java: Carnegie Mellon Software Engineering Institute (maintained online).
- MISRA C:2012: Guidelines for the Use of the C Language in Critical Systems, 2012.
- PCI DSS v4.0.1: Payment Card Industry Data Security Standard. PCI SSC, 2024.
- CIS Controls v8: Center for Internet Security, 2021.
Secure Coding Books and Resources
- "The Art of Software Security Assessment": Mark Dowd et al., Addison-Wesley, 2006.
- "Secure Coding in C and C++": Robert Seacord, Addison-Wesley, 2013.
- "24 Deadly Sins of Software Security": Michael Howard et al., McGraw-Hill, 2009.
- "Software Security: Building Security In": Gary McGraw, Addison-Wesley, 2006.
- "Threat Modeling: Designing for Security": Adam Shostack, Wiley, 2014.
- "Hacking: The Art of Exploitation": Jon Erickson, No Starch Press, 2008.
- OWASP Cheat Sheet Series: https://cheatsheetseries.owasp.org/
- OWASP Testing Guide: https://owasp.org/www-project-web-security-testing-guide/
Training Platforms and Labs
- OWASP WebGoat: https://owasp.org/www-project-webgoat/
- OWASP Juice Shop: https://owasp.org/www-project-juice-shop/
- Damn Vulnerable Web App (DVWA): https://github.com/digininja/DVWA
- Mutillidae: https://github.com/webpwnized/mutillidae
- Secure Code Warrior: https://www.securecodewarrior.com/
- HackEDU: https://www.hackedu.com/
- HackerEarth: https://www.hackerearth.com/
- Codebashing: https://www.codebashing.com/
- Cybrary: https://www.cybrary.it/
Indian Regulatory Resources
- Digital Personal Data Protection Act 2023: Government of India, 2023.
- RBI Master Direction on Information Technology Governance, Risk, Controls and Assurance Practices: Reserve Bank of India, 7 November 2023 (in force from 1 April 2024); and RBI Cyber Security Framework in Banks: circular of 2 June 2016.
- SEBI Cybersecurity and Cyber Resilience Framework (CSCRF) for SEBI Regulated Entities, circular of 20 August 2024.
- IRDAI Guidelines on Information and Cybersecurity: Insurance Regulatory and Development Authority of India, 2023.
- IT Act 2000 (as amended): Ministry of Electronics and Information Technology, India.
Industry Research
- IBM Cost of a Data Breach Report 2024: IBM Security and Ponemon Institute, 2024.
- Verizon Data Breach Investigations Report 2024: Verizon, 2024.
- BSIMM: Building Security In Maturity Model (use the latest edition).
- NIST SP 800-218: Secure Software Development Framework (SSDF) v1.1. NIST, 2022.