Security Misconfiguration (OWASP A02:2025)
On this page
Stack traces in production: the default that leaks
Start a plain Express 5 app, add a route that parses a query parameter, and send it bad input:
app.get('/report', (req, res) => { JSON.parse(req.query.data); res.send('ok'); });curl 'localhost:3300/report?data=%7Bbad'<pre>SyntaxError: Expected property name or '}' in JSON at position 1 ...
at file:///.../owasplab/app.mjs:60:41
at Layer.handleRequest (/.../node_modules/router/lib/layer.js:152:17)
...The response contains the full stack trace: file paths on the server, the line that failed and the router library in use. Every response also carries X-Powered-By: Express. None of this is a bug in the code. It's Express's default behaviour when NODE_ENV isn't set to production.
Restart the same app with NODE_ENV=production and the response becomes:
<pre>Internal Server Error</pre>That's security misconfiguration in miniature: an unsafe default nobody changed.
ASP.NET Core makes the opposite choice. With no environment variable set it runs as Production, and an unhandled exception returns an empty 500 with no details. Tested on .NET 8, the same bad JSON gave a full JsonReaderException stack trace only when ASPNETCORE_ENVIRONMENT=Development was set. So the .NET version of this mistake is a Development setting copied into a production container, launch profile or app service. Two things still need changing from the defaults: Kestrel announces itself with a Server: Kestrel header on every response, and an empty 500 gives clients nothing consistent to handle. Turn the first off and give errors a standard safe shape:
builder.WebHost.ConfigureKestrel(o => o.AddServerHeader = false);
builder.Services.AddProblemDetails();
var app = builder.Build();
app.UseExceptionHandler(); // generic RFC 9457 Problem Details body, details stay in the logsWhy security misconfiguration is now number 2
The category rose from fifth in 2021 to second in 2025, and OWASP's data found some form of it in every application tested. Teams deploy more often, to more cloud accounts and more services, each with its own settings. Configuration grew faster than anyone's habit of checking it.
Common shapes:
| Misconfiguration | Example | Fix |
|---|---|---|
| Verbose errors | Stack traces or SQL errors in responses | Generic error body; full details in server logs only |
| Public storage | A bucket with customer files readable by anyone | Block public access at the account level; scan for exceptions |
| Default credentials | An admin console still on its factory password | Force a change on first start; remove unused accounts |
| Unneeded features | Debug endpoints, sample apps, directory listings left on | Turn off or remove anything not in use |
| Missing headers, loose CORS | No CSP or HSTS; Access-Control-Allow-Origin: * on a private API | Set headers once at a gateway or shared middleware |
Fixing the error handler for good
Don't rely on someone remembering an environment variable. Add your own final error handler so the safe behaviour doesn't depend on NODE_ENV:
app.disable('x-powered-by');
app.use((err, req, res, next) => {
logger.error({ err, path: req.path }, 'unhandled request error'); // full detail, server side
res.status(500).json({ error: 'Internal server error' }); // nothing useful to an attacker
});Configuration as code, checked every time
The lasting fix is to treat settings like code:
- Write them down in Terraform, Helm values or framework config, and review them like code.
- Start restrictive. For S3, block public access on the account and the bucket. A public bucket then needs a deliberate, reviewed exception:
resource "aws_s3_bucket_public_access_block" "data" {
bucket = aws_s3_bucket.data.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}- Apply the same config everywhere, so production doesn't differ from staging because someone fixed it by hand.
- Scan continuously. Policy checks in CI catch insecure templates, and cloud posture tools catch drift in running accounts.
Defaults matter beyond your own team. Years of databases exposed with no password led vendors to change theirs. MongoDB 3.6 started listening only on localhost by default, and Elasticsearch 8 turned on authentication and TLS by default.
Check yourself
The trace reveals file paths, libraries and sometimes versions, which helps an attacker map the app and look up known vulnerabilities. Send a generic message and keep the details in server logs.
The safe behaviour then depends on one variable that can be missed in another environment or deployment path. A final error handler makes the safe response the code's default.
Teams now run many more services, accounts and settings, deployed constantly, while configuration checks stayed occasional or manual. Some misconfiguration showed up in every app tested.
Default credentials left enabled, unnecessary features or ports open, missing security headers, overly permissive CORS, public cloud storage buckets, outdated TLS settings and debug endpoints left on in production. Most are invisible in normal testing because the app still works.
Define it as code, such as infrastructure templates and configuration files in version control, review changes like code, and run automated checks in CI for things like public buckets, missing headers and debug flags. Manual setup per environment drifts.