mediumCWE-16A05:2021

Security Misconfiguration

Default configurations, open CORS policies, debug mode in production, or verbose error messages expose your application to attackers.

How It Works

Security misconfiguration is one of the most common vulnerabilities. It includes leaving debug mode enabled in production, using permissive CORS (Access-Control-Allow-Origin: *), exposing stack traces in error responses, keeping default credentials, or leaving unnecessary features enabled. Attackers probe for these misconfigurations automatically using scanning tools.

Vulnerable Code
const app = express();
app.use(cors({ origin: '*' }));
app.use((err, req, res, next) => {
  res.status(500).json({ error: err.stack });
});
Secure Code
const app = express();
app.use(cors({ origin: 'https://myapp.com' }));
app.use((err, req, res, next) => {
  console.error(err);
  res.status(500).json({ error: 'Internal server error' });
});

Real-World Example

In 2017, the Equifax breach that exposed 147 million records was caused partly by an unpatched Apache Struts vulnerability combined with misconfigured network security that allowed lateral movement.

How to Prevent It

  • Restrict CORS to specific trusted origins
  • Never expose stack traces or debug info in production
  • Use environment-specific configurations
  • Regularly audit your security settings

Affected Technologies

Node.jsReactNext.jsPythonGoJavaPHPC#

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities