Security Misconfiguration is a security vulnerability created by settings, not code: a server, framework or database left running with unsafe defaults. It is number five on the 2013 OWASP Top 10, the list of web application risks published by the Open Web Application Security Project (OWASP), and it is the only item on the list that is not a bug in anyone’s code. Nobody wrote it. It is what the server does on its own: the default account left enabled, the debug flag left on, the error page that prints a stack trace, the sample application nobody removed, the admin console reachable from the public internet.
This is the entry teams score themselves highest on and find the most of, because it does not show up in a code review. The code is clean. The settings are wrong. And settings get wrong for one reason above all: the environment was built by hand, by a person following memory or a half-remembered runbook, and the one person who knew the hardening steps was not there the day this box was built.
What the bug is, in plain words
A running application is more than its code. It sits on an application server, behind a web server, on an operating system, next to a database, each shipped with defaults chosen to make the thing start, not to make it safe. A default is a decision the vendor made for an empty demo. When you ship that demo’s settings to production, you ship the vendor’s convenience as your security posture.
Misconfiguration is every gap between “it runs” and “it is locked down.” Five kinds cover most of what I find:
- accounts and passwords left at their defaults
- debug and developer modes left on in production
- errors that return stack traces and internal detail to the user
- directory listing enabled, so the server hands out a file index
- sample applications, admin consoles and management tools left installed and reachable
None of these is subtle. All of them are easy to find, from the outside, by anyone who looks. That is the danger: the attacker does not need a vulnerability in your code, only a scan of your server.
How the attack works, with real cases
A default password on a management console. In 2009, a flaw was published in the Windows installer for Apache Tomcat (CVE-2009-3548): it set a blank password for the administrative user by default. Tomcat’s manager application lets an authenticated administrator deploy a new web application, which means run code. Blank password plus a reachable manager equals a full server takeover with no exploit at all. The attacker visits the manager, logs in with nothing, and deploys a web shell. This is the whole attack: a default credential and a management interface that should never have faced the internet.
A console that forgot to guard one HTTP method. JBoss, a widely used Java application server, shipped a JMX Console, a web page that lets an administrator invoke management operations, including deploying an application. In 2010 a flaw was published (CVE-2010-0738): the console enforced its access control only on the GET and POST methods. Send the same management request with a different method, such as HEAD, and the check was skipped. An attacker who could reach the console used it to deploy a web application archive and take over the server. The root cause was configuration: the console was exposed, and its protection was both incomplete and the only thing standing between the internet and “deploy arbitrary code.”
A detailed error page that gave away the keys. In 2010, a padding oracle flaw was published against ASP.NET (CVE-2010-3332). The framework returned different, detailed error responses depending on how a decryption attempt failed. Those differences told an attacker, one request at a time, whether a guess at the encryption padding was right, which let them decrypt and forge protected values such as view state and, in many deployments, read files like web.config. The fix Microsoft shipped as an immediate workaround was a configuration change: make every error return the same page, so the server stops leaking which failure happened. A verbose error page is not just embarrassing. Here it was the whole vulnerability.
Three cases, three categories, one shape: nobody had to break the application. The application told them how, or let them in with the key under the mat.
Before and after
Misconfiguration is fixed in config, so the fix is a diff. Here are the four I change most often.
Turn off the stack trace
A detailed error page is a gift to an attacker: framework versions, file paths, SQL fragments, sometimes a snippet of the query that failed. Turn it off in production, log the detail server-side, show the user nothing but a plain page.
PHP, before (exposed)
; php.ini on a production server
display_errors = On
display_startup_errors = On
expose_php = On
PHP, after (quiet to the user, logged for you):
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = /var/log/php/error.log
expose_php = Off
display_errors = On prints errors, including paths and query fragments, straight to the page. expose_php = On adds an X-Powered-By header that announces your exact PHP version to every scanner. Both are on in PHP’s shipped development profile. Production is the opposite: show the user a generic page, write the detail to a log only you can read.
Turn off debug mode
Framework debug modes do far more than print errors. They expose settings, environment, sometimes an interactive console that runs code.
Django, before: a new project’s settings.py ships with
DEBUG = True
ALLOWED_HOSTS = []
With DEBUG = True, any unhandled error returns a full traceback page showing local variables, settings and the request, to whoever triggered it. Ship it and you have published your internals.
Django, after
DEBUG = False
ALLOWED_HOSTS = ['app.example.com']
Django refuses to run with DEBUG = False and an empty ALLOWED_HOSTS, which is the framework forcing you to name your real hostnames before it will serve traffic safely. Rails is the same story: a generated app has config.consider_all_requests_local = true in development.rb and false in production.rb, and it bundles the web-console gem in the development group only. The failure mode is running the app in development mode on a production box, which hands everyone the detailed error pages and, with the console, a prompt. Set the environment correctly and do not load developer tools in production.
Turn off directory listing
If a directory has no index file and listing is on, the web server hands out a browsable file index. Attackers read it for backups, source, old scripts and config.
Apache, before. A stock httpd.conf serves the document root with:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Indexes is what generates the listing. The shipped default includes it.
Apache, after
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ServerTokens Prod
ServerSignature Off
TraceEnable Off
Removing Indexes turns off the listing. ServerTokens Prod trims the Server header from the full version string (which the default, Full, prints) down to just Apache, and ServerSignature Off keeps the version off error pages. TraceEnable Off disables the TRACE method, which has no use on a normal site and can help an attacker.
Change or remove the defaults, and remove the samples
Change every default password before a box faces the network. Better, delete what you are not using: the sample applications, the manager and admin consoles you do not need, the test endpoints. The Tomcat and JBoss cases above were consoles that did not need to be reachable. If a console must exist, bind it to localhost or put it behind the firewall, never on the public interface, and never with its shipped password.
Why the common fixes fail
“We have a hardening document.” A document in a folder is not a configuration. If a human has to read it and apply twelve steps by hand on every new server, some server, some day, will miss step seven. Misconfiguration is overwhelmingly a story of hand-built environments where one box differs from the rest because one person did it differently. The document has to become the build.
“The production team hardens it after we hand it over.” Then production is configured by people who did not write the app, and the app is tested by people who do not run it. The gap between them is exactly where this risk lives. Development, test and production should be built from the same hardened recipe, differing only in their secrets.
“We changed the admin password.” Good, and did you remove the sample apps, turn off directory listing, turn off debug mode, strip the version headers, and close the management console to the outside? Misconfiguration is not one setting. It is the sum of all the settings nobody owns.
“A scanner checked it.” A scanner is worth running and will catch the common cases. It will not know that your admin console should not be internet-facing, or that this environment was supposed to match that one. Automated scanning finds drift; it does not define “secure” for your system. You still have to write that down as a build.
The defense that ends it: a repeatable hardened build
The fix for every item above is the same: stop configuring servers by hand. Define the hardened state once, in a file, and build every environment from that file. When the configuration is code, the stack trace is off because the file says so, not because someone remembered. A new server is identical to the last one because the same recipe built both.
Concretely:
-
Write the hardened configuration as code. Whatever your tooling, the point is that the settings live in version control, get reviewed, and get applied the same way every time. The settings above (errors off, debug off, listing off, headers stripped, defaults changed, samples removed) go in that recipe.
-
Build every environment from it. Development, test and production run the same recipe with different secrets. A difference between environments should be impossible to introduce by hand, because nothing is done by hand.
-
Pick a benchmark and measure against it. The Center for Internet Security publishes hardening benchmarks for common servers and operating systems. Use one as your target, so “hardened” has a definition you can check, not a feeling.
-
Scan for drift on a schedule. Even with a recipe, someone will log in and change something live during an incident. Scan periodically and compare to the recipe. Anything that differs is either a mistake to fix or a change to fold back into the recipe.
Layers around it
- Least privilege for the service account. The account the application server runs under decides how far a takeover reaches. It should own its own files and nothing else.
- A separate network for management. Admin consoles, if they must exist, live on an internal interface, never the public one.
- Strip the fingerprints. Remove version headers and banners. They do not stop a determined attacker, but they turn off the easy scan that finds the version with a public exploit.
How to test your own application
-
From outside your network, request a path that does not exist and a path that triggers an error. Read the response. If you see a stack trace, a framework version, a file path or a SQL fragment, debug mode or verbose errors are on.
-
Request a directory with no index file, such as
/images/or/uploads/. If you get a list of files, directory listing is on. -
Read your response headers.
Server,X-Powered-By,X-AspNet-Versionand similar announce your exact versions. Decide what you want to reveal, which is as little as possible. -
Look for what shipped with the platform:
/manager/and/host-manager/on Tomcat,/jmx-console/and/web-console/on JBoss, sample and example apps, admin panels. For each, ask two questions: is it reachable from outside, and does it still have a default or weak password. Either answer being wrong is a finding. -
Try a management request with an unusual HTTP method against a console you expect to be protected. If a HEAD or an odd method gets further than a GET, the access control is incomplete, as in the JBoss case.
-
Compare two environments that should match. Any difference is drift, and drift is where the next misconfiguration hides.
Checklist
- Errors show the user a plain page; detail goes to a server-side log.
- Debug and developer modes are off, and developer tools are not loaded in production.
- Directory listing is off.
- Default passwords are changed; unused samples, consoles and tools are removed.
- Management interfaces are off the public network.
- Version headers and banners are stripped.
- Every environment is built from one hardened recipe in version control.
- A scheduled scan checks for drift against that recipe and a published benchmark.
Security misconfiguration is the easiest risk to fix and the easiest to reintroduce, because every new server is a fresh chance to forget a step. The answer is to stop relying on memory. Write down what secure means for your stack, as a build that runs the same way every time, and the server stops giving itself away.