A02: Security Misconfiguration
Security misconfiguration occurs when systems, applications, or cloud services are set up incorrectly. This includes unnecessary features, default credentials, overly informative error messages, and missing security headers.
Key Vulnerabilities
Missing security hardening across application stack or cloud permissions
Unnecessary features enabled (ports, services, accounts, privileges)
Default accounts and passwords left unchanged
Error messages revealing stack traces to users
Security features disabled or not configured in upgraded systems
Missing or insecure security headers
Prevention Strategies
Implement repeatable hardening processes with automation
Use minimal platforms — remove unused features and frameworks
Regularly review and update configurations as part of patch management
Use segmented application architecture with proper isolation
Send security headers (CSP, X-Frame-Options, HSTS)
Automate configuration verification across all environments
Real-World Example
In 2017, a massive data breach at a credit bureau exposed 147 million records because an Apache Struts vulnerability went unpatched due to poor configuration management.
Code Comparison
// VULNERABLE: Detailed error messages exposed to users
app.use((err, req, res, next) => {
res.status(500).json({
error: err.message,
stack: err.stack, // Exposes internal paths
dbQuery: err.sql, // Exposes database schema
serverVersion: process.version
});
});// SECURE: Generic error response + server-side logging
app.use((err, req, res, next) => {
console.error('[ERROR]', err); // Log details server-side
res.status(500).json({
error: 'An unexpected error occurred.',
requestId: generateRequestId() // For support reference
});
});