On this page
- Quick Reference (60 Seconds)
- What the Standard Actually Requires
- 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.
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 Standard Actually Requires
Figure · Process
What A.8.28 asks you to do

Annex A 8.28 asks organizations to apply secure coding principles to software development.
This control is about the actual practice of writing code in a way that prevents vulnerabilities. The standard expects organizations to:
- Adopt and enforce secure coding standards, Language-specific rules that prevent common vulnerabilities
- Train developers on secure coding, Regular training on vulnerability prevention and secure coding techniques
- Implement automated code security analysis, Static Application Security Testing (SAST) integrated into the development pipeline
- Conduct manual security code review, Human review for security-critical code paths
- Handle security defects in code, Process for identifying, tracking, and remediating code-level vulnerabilities
- Maintain secure coding documentation, Standards, guidelines, and reference materials for developers
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 (2021) and CWE Top 25 consistently show that the majority of security vulnerabilities are introduced at the code level:
- Injection flaws (SQL, NoSQL, OS command, LDAP), #1 on OWASP Top 10
- Broken authentication, #2 on OWASP Top 10
- Sensitive data exposure, #3 on OWASP Top 10
- XML external entities (XXE), #4 on OWASP Top 10
- Broken access control, #5 on OWASP Top 10
- Security misconfiguration, #6 on OWASP Top 10
- Cross-site scripting (XSS), #7 on OWASP Top 10
- Insecure deserialization, #8 on OWASP Top 10
- Using components with known vulnerabilities, #9 on OWASP Top 10
- Insufficient logging and monitoring, #10 on OWASP Top 10
All of these are fundamentally coding problems that can be prevented or detected through secure coding practices.
The Indian Context
Indian organizations face unique secure coding challenges:
- Startup ecosystem: 10,000+ startups building 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 boom: Payment applications require PCI DSS compliant code with zero tolerance for injection flaws
- 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 data protection by design and default
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.1, Policies for information security | Secure coding policy must align with the overarching information security policy |
| A.5.8, Information security in project management | Secure coding must be embedded in project management and development processes |
| A.5.24, Information security incident management planning and preparation | Secure coding requirements must be defined for ICT services |
| A.5.36, Compliance with policies, rules and standards | Developers must comply with secure coding policies and standards |
| A.5.37, Documented operating procedures | Secure coding procedures must be documented |
| A.6.1, Screening | Developers must be screened before access to source code |
| A.6.2, Terms and conditions of employment | Employment contracts should include secure coding responsibilities |
| A.6.3, Information security awareness, education and training | Developers must be trained on secure coding |
| A.8.1, User endpoint devices | Secure coding for endpoint applications |
| A.8.5, Secure authentication | Code must implement secure authentication |
| A.8.9, Configuration management | Secure coding for configuration handling |
| A.8.16, Monitoring activities | Code must implement secure logging and monitoring |
| A.8.24, Use of cryptography | Code must implement cryptography correctly |
| A.8.25, Secure development life cycle | Secure coding is a core phase of the SDLC |
| A.8.26, Application security requirements | Code must satisfy security requirements |
| A.8.27, Secure system architecture | Code must implement secure architecture |
| A.8.29, Security testing in development and acceptance | Code must be tested for security vulnerabilities |
| A.8.30, Outsourced development | Secure coding requirements must be enforced on outsourced code |
| A.8.31, Separation of development, test and production environments | Code must support environment separation |
| A.8.33, Test data | Code must handle test data securely |
| A.8.34, Protection of information systems during audit testing | Code must protect systems during audit |
Framework Mapping
| Framework | Relevant Control / Reference |
|---|---|
| NIST CSF 2.0 | PR.IP-1 (SDLC), PR.IP-2 (SDLC feedback), PR.IP-3 (change management), PR.IP-4 (vulnerability management) |
| NIST SP 800-53 Rev 5 | SA-15 (Development process, standards, tools), SI-10 (Information input validation), SI-11 (Error handling) |
| PCI DSS 4.0 | Req 6.3 (security to software development), Req 6.5 (address common coding vulnerabilities), Req 6.6 (public-facing web applications) |
| COBIT 2019 | BAI03.03 (Managed solutions development), BAI03.05 (Managed development), BAI10.03 (Managed configuration) |
| CIS Controls v8 | Control 16 (Application software security), Control 7 (Continuous vulnerability management) |
| OWASP SAMM | Implementation (Secure Build, Security Testing), Verification (Security Testing) |
| BSIMM | SFD (Security Features and Design), ST (Security Testing) |
| GDPR | Art 25 (Data protection by design), Art 32 (Security of processing) |
| DPDP Act 2023 | Section 8(4) (Appropriate technical and organisational measures)) |
Implementation Roadmap (Week-by-Week)
Figure · Tiers
Maturity levels for secure coding
- OptimizingAI-assisted code review
- Quantitatively ManagedMetrics tracked, automated enforcement
- DefinedStandardized across all teams
- ManagedBasic standard exists
- Ad-hocNo secure coding standard, no tools
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, orevalwith 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.escapefor HTML encoding,urllib.parse.quotefor URL encoding - Use
defusedxmlfor XML parsing (prevents XXE) - Use
ast.literal_evalinstead ofevalfor safe evaluation - Use
subprocess.runwith argument lists, notos.systemorsubprocess.callwith 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
JacksonwithenableDefaultTypingdisabled (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+)
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 | licensing Range |
|---|---|---|---|
| SonarQube | 25+ languages | Code quality + security, CI/CD integration | Free (Community) / Enterprise |
| Checkmarx | 25+ languages | Enterprise, deep analysis, compliance | Enterprise licensing |
| Fortify | 25+ languages | Enterprise, complete reporting | Enterprise licensing |
| CodeQL | 10+ languages | GitHub-native, deep analysis, open source | Free (public) / Enterprise |
| Bandit | Python | Python-specific, fast, open source | Free |
| Brakeman | Ruby | Ruby on Rails specific | Free |
| ESLint Security Plugin | JavaScript | JavaScript/Node.js specific | Free |
| gosec | Go | Go-specific, fast, open source | Free |
| SpotBugs (FindSecBugs) | Java | Java-specific, extensive rule set | Free |
| PMD Security | Java, Apex, JavaScript | Multi-language, fast | Free |
| PVS-Studio | C/C++, C#, Java | Deep static analysis, MISRA support | Commercial |
| Coverity | C/C++, Java, C# | Enterprise, high precision | Enterprise licensing |
| Clang Static Analyzer | C/C++, Objective-C | Free, open source, IDE integration | Free |
| Infer | C/C++, Java, Objective-C | Facebook's analyzer, fast, open source | Free |
| Horusec | 15+ languages | Multi-language, open source, CI/CD | Free |
| SonarCloud | 25+ languages | Cloud-based, SaaS, GitHub/GitLab integration | Free (open source) / Commercial |
| Reshift | Java, JavaScript | Cloud-native, lightweight, developer-friendly | Freemium |
SCA (Software Composition Analysis) Tools
| Tool | Best For | licensing Range |
|---|---|---|
| OWASP Dependency-Check | Free, open source, multi-language | Free |
| Sonatype Nexus Lifecycle | Enterprise, policy enforcement | Enterprise licensing |
| WhiteSource (Mend) | Enterprise, complete | Enterprise licensing |
| 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 licensing |
| Debricked | AI-powered, fast | Commercial |
| Jfrog Xray | Artifact repository integration | Commercial |
Secrets Detection Tools
| Tool | Best For | licensing |
|---|---|---|
| GitHub Secret Scanning | GitHub-native | Free |
| GitLab Secret Detection | GitLab-native | Free (included) |
| TruffleHog | Open source, deep scanning, many providers | Free |
| Git-secrets | AWS-focused, Git hooks | Free |
| Detect-secrets | Yelp's tool, CI/CD friendly | Free |
| Gitleaks | Fast, lightweight, open source | Free |
| GitGuardian | Enterprise, complete | Commercial |
| SpectralOps | Enterprise, AI-powered | Commercial |
DAST Tools
| Tool | Best For | licensing Range |
|---|---|---|
| OWASP ZAP | Free, web applications, CI/CD | Free |
| Netsparker (Invicti) | Accurate, automated, CI/CD | Commercial |
| AppSpider | Enterprise, complete | Enterprise licensing |
| 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 | licensing |
|---|---|---|
| Signal Sciences | WAF + RASP, cloud-native | Commercial |
| Imperva RASP | Enterprise, complete | Enterprise licensing |
| 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 | licensing Range |
|---|---|---|
| HackerEarth | Indian platform, coding challenges | Free / Commercial |
| Codebashing | Developer-friendly, bite-sized lessons | Commercial |
| OWASP WebGoat | Free, hands-on, web application security | Free |
| OWASP Juice Shop | Free, modern, gamified | Free |
| Damn Vulnerable Web App (DVWA) | Free, beginner-friendly | Free |
| Mutillidae | Free, complete, OWASP Top 10 | Free |
| Singahi Secure Coding Workshop | Indian context, customized, hands-on | Custom licensing |
Indian Tool Vendors and Service Providers
| Vendor | Offering | Website |
|---|---|---|
| Singahi | Secure coding consulting, SAST/DAST implementation, developer training, VAPT | / |
| HackerEarth | Developer assessment, secure coding challenges | https://www.hackerearth.com |
| TechGig | Coding contests, skill assessments | https://www.techgig.com |
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.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 |
| impact of Security Rework | impact 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
Illustrative scenario, a composite example for guidance, not a specific Singahi engagement or a verified outcome.
Illustrative Scenario 1: Indian SaaS Startup, Developer Security Transformation
Organization: A SaaS startup in Bengaluru building HR tech software for Indian enterprises. Context: 40 developers, Python/Django backend, React frontend, 200+ enterprise customers. Rapid growth from 10 to 40 developers in 18 months. Challenge: No secure coding practices. First external penetration test revealed 35 critical vulnerabilities (SQL injection, XSS, broken auth, insecure deserialization). Developers had no security training. SAST tools were not used. Approach:
- Week 1-2: Singahi conducted secure coding assessment. Baseline vulnerability density: 2.8 per 1000 LOC.
- Week 3-4: Implemented Semgrep in CI/CD with custom rules for Django/React. Integrated Snyk for dependency scanning. Set up Git-secrets for pre-commit hooks.
- Week 5-6: Conducted 2-day secure coding workshop for all 40 developers. Hands-on labs with Django-specific vulnerabilities. Trained 5 security champions (one per team).
- Week 7-8: Established security code review process. Security champion reviews all authentication, authorization, and data access code. Created secure coding wiki with Django-specific guidelines.
- Week 9-12: Ran gamification program: "Security Leaderboard" with points for zero-vulnerability sprints, bonus for finding and fixing vulnerabilities. Monthly "Security Demo" where teams showcase secure coding patterns. Results:
- Vulnerability density: 0.3 per 1000 LOC (89% reduction)
- Critical vulnerabilities in production: 0 (last 3 releases)
- Security champion program: 5 champions, 15 developers requesting advanced training
- SAST false positive rate: 12% (tuned rules, well below industry average of 25%)
- Mean time to remediate critical: 1.2 days (down from 14 days)
- Developer satisfaction: 87% say security is now "part of their workflow" (not overhead)
- impact of program: /year (tools + training + consulting)
- impact of first penetration test remediation without secure coding:
- Customer trust: 2 enterprise customers mentioned "secure development practices" as a reason for choosing the platform Key Lesson: Developer training + automation + culture change = sustainable secure coding. Tools alone are not enough.
Illustrative Scenario 2: Indian Financial Services Firm, Secure Coding for Trading Platform
Organization: A financial services firm in Mumbai with a proprietary trading platform. Context: 150 developers, Java/Spring Boot backend, Angular frontend, Oracle database. Processing + crore in annual trades. SEBI compliance mandatory. Challenge: Trading platform had legacy code from 2010 with no secure coding practices. SEBI inspection flagged "inadequate code security controls." Code review was ad-hoc. SAST was run manually once per quarter. Dependency vulnerabilities were not tracked. Approach:
- Phase 1 (Month 1): Singahi conducted enterprise secure coding assessment. Found 120+ critical/high vulnerabilities in legacy code. Vulnerability density: 1.9 per 1000 LOC.
- Phase 2 (Months 2-3): Implemented Checkmarx for enterprise SAST, integrated into Jenkins CI/CD. Implemented Sonatype Nexus Lifecycle for SCA. Set up automated dependency updates via Renovate.
- Phase 3 (Months 4-5): Conducted secure coding training for all 150 developers (3 batches of 50). Focused on Java-specific vulnerabilities: deserialization, injection, XXE, insecure randomness. Trained 12 security champions (one per squad).
- Phase 4 (Months 6-8): Established mandatory security code review for all trading-critical code. Created Java Secure Coding Standard (120 pages) based on CERT and OWASP guidelines. Implemented security unit tests for all authentication and authorization code.
- Phase 5 (Months 9-12): Legacy code remediation program. Prioritized by risk. Remediated 85% of critical/high vulnerabilities in legacy code. Implemented DAST (OWASP ZAP) for trading platform staging environment. Results:
- Vulnerability density: 0.2 per 1000 LOC (89% reduction)
- SEBI inspection: zero findings on code security
- Critical vulnerabilities in production: 0 (last 4 releases)
- Dependency vulnerabilities: 95% patched within 7 days (automated Renovate)
- Security code review: 100% of trading-critical code reviewed before merge
- Mean time to remediate critical: 0.8 days (down from 21 days)
- Security unit tests: 450+ tests covering all authentication, authorization, and input validation paths
- impact of program: /year (tools + training + consulting)
- impact of SEBI penalty + breach risk avoided: +
- Developer security score: Average 87/100 (quarterly assessment) Key Lesson: Enterprise secure coding requires investment in tools, training, and governance, but the compliance and risk reduction benefits are exponential. Legacy code remediation is critical for financial services.
Multi-Framework Mapping
Figure · Matrix
Comparison: Level 1 to Level 3
OWASP ASVS Mapping
| ASVS Level | Relevance to A.8.28 | Key Requirements |
|---|---|---|
| Level 1 (Opportunistic) | Minimum baseline | V5.1 (Input validation), V5.2 (Sanitization), V5.3 (Output encoding) |
| Level 2 (Standard) | Most organizations | V5.4 (Deserialization), V6.1 (Data classification), V6.2 (Cryptography), V7.1 (Error handling) |
| Level 3 (Advanced) | High-security applications | V8.1 (File upload), V9.1 (Communication), V12.1 (File integrity), V13.1 (API) |
PCI DSS 4.0 Mapping
| PCI DSS Requirement | Secure Coding Focus |
|---|---|
| 6.3 | Security to software development processes |
| 6.5 | Address common coding vulnerabilities (injection, XSS, buffer overflow, etc.) |
| 6.6 | Public-facing web applications, secure coding for WAF bypass scenarios |
DPDP Act 2023 Mapping
| 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 | Managed solutions development | Secure coding in development |
| BAI03.05 | Managed development | Secure coding practices |
| BAI06.01 | Managed changes | Secure coding for changes |
| DSS05.03 | Manage security services | Secure coding for security services |
| DSS05.05 | Manage security services | Secure coding monitoring |
CIS Controls v8 Mapping
| CIS Control | Implementation Group | A.8.28 Mapping |
|---|---|---|
| Control 16 | IG2 | Application software security, secure coding |
| Control 7 | IG2 | Continuous vulnerability management |
| Control 8 | IG2 | Audit log management |
| Control 6 | IG1 | Access control management |
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 4.0 | 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.IP: Secure development requires secure coding |
| 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
Mandatory Documentation
| Document | Purpose | Retention | Owner |
|---|---|---|---|
| Secure Coding Policy | Governance framework | 7 years | CISO |
| Secure Coding Standard | Developer rules and guidelines | Current version + 7 years | Security Lead |
| Language-Specific Guidelines | Detailed rules per language | Current version + 7 years | Security Lead |
| SAST Configuration | Tool setup and rules | Current version + 7 years | DevOps Lead |
| SCA Configuration | Dependency scanning setup | Current version + 7 years | DevOps Lead |
| Code Review Checklist | Security review checklist | Current version + 7 years | Security Lead |
| Training Materials | Developer training content | 7 years | Security Lead |
| Training Records | Staff competency evidence | 7 years | HR / Security |
| Vulnerability Tracking Records | Vulnerability lifecycle | 7 years | Security Lead |
| Remediation Records | Fix verification evidence | 7 years | Developer |
| Build Logs | CI/CD pipeline evidence | 1 year | DevOps Lead |
| Audit Records | Audit findings and remediation | 7 years | CISO |
| Exception Records | Approved deviations | 7 years | CISO |
| Metrics Reports | KPI tracking | 7 years | Security Lead |
| Champion Program Records | Champion assignments and activities | 7 years | Security Lead |
| Vendor Secure Coding Requirements | Contract terms for outsourced code | 7 years | Security Lead |
| Secure Coding Wiki/Documentation | Developer reference | Current version | Security Lead |
| False Positive Records | Suppressed findings with justification | 7 years | Security Lead |
| Annual Standard Review | Standard update evidence | 7 years | 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 our AI/ML Security Master Course for detailed guidance.
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:2021, The Ten Most Critical Web Application Security Risks. OWASP, 2021.
- OWASP Application Security Verification Standard (ASVS) v4.0.3. OWASP, 2023.
- OWASP Software Assurance Maturity Model (SAMM) v2.0. OWASP, 2020.
- CWE Top 25, Most Dangerous Software Weaknesses. MITRE, 2023.
- CERT C Secure Coding Standard, Carnegie Mellon Software Engineering Institute, 2023.
- CERT C++ Secure Coding Standard, Carnegie Mellon Software Engineering Institute, 2023.
- MISRA C:2012, Guidelines for the Use of the C Language in Critical Systems, 2012.
- PCI DSS v4.0, Payment Card Industry Data Security Standard. PCI SSC, 2022.
- 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/
- Singahi AI/ML Security Master Course, /
Indian Regulatory Resources
- Digital Personal Data Protection Act 2023, Government of India, 2023.
- RBI Master Direction on Cyber Security Framework, Reserve Bank of India, 2024.
- SEBI Cybersecurity and Cyber Resilience Framework, Securities and Exchange Board of India, 2023.
- 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 impact of a Data Breach Report 2024, IBM Security and Ponemon Institute, 2024.
- Verizon Data Breach Investigations Report 2024, Verizon, 2024.
- Gartner Market Guide for Application Security Testing, Gartner, 2024.
- Forrester TEI of Application Security, Forrester Research, 2023.
- BSIMM12, Building Security In Maturity Model. Synopsys, 2023.