HomeTopicsA02 Security Misconfiguration
Lesson 2 / 10

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

1

Missing security hardening across application stack or cloud permissions

2

Unnecessary features enabled (ports, services, accounts, privileges)

3

Default accounts and passwords left unchanged

4

Error messages revealing stack traces to users

5

Security features disabled or not configured in upgraded systems

6

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 Code
// 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 Code
// 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
  });
});