Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 38 ยท Insecure Design and Misconfiguration

Security Misconfiguration and Hardening (A05)

Learn common security misconfigurations such as default credentials, debug mode, verbose errors and open cloud storage, and harden systems with baselines, least functionality and configuration audits.

Security Misconfiguration (A05 in 2021, rising to second place in the 2025 update) covers insecure settings anywhere in the stack: operating system, web server, framework, database, cloud services, containers and the application itself. The software may be perfectly written and patched, and still be exposed by one wrong checkbox.

Modern applications have thousands of settings across many layers, and defaults are often chosen for convenience, not safety. That is why misconfiguration is so common: nobody sees all the knobs.

Typical misconfigurations

Area Example
Credentials Default admin passwords (admin/admin), sample accounts left in place
Debug and errors APP_DEBUG=true in production, stack traces shown to users, framework debug pages and consoles reachable
Unnecessary features Sample apps, test routes, open management ports, unused services and accounts
Directory and file exposure Directory listing, /.git, /.env, backup files, phpinfo() pages
Cloud Public storage buckets, overly broad IAM roles, open security groups (0.0.0.0/0 on database ports)
Network and TLS Old protocol versions, weak ciphers, certificates not validated
Headers Missing Strict-Transport-Security, CSP, X-Content-Type-Options
Containers Running as root, privileged mode, Docker socket mounted, secrets baked into images
XML External entities enabled in parsers
Permissions World-writable files, database user with administrator rights

Stack traces are valuable to attackers: they reveal framework versions, file paths, table names and sometimes secrets.

Hardening principles

  1. Least functionality. Remove or disable what you do not use: features, modules, ports, sample content, default accounts.
  2. Secure by default. Start from a hardened baseline (CIS Benchmarks, vendor hardening guides), not factory defaults.
  3. Repeatable, automated builds. Infrastructure as code and container images make every environment identical and reviewable. Hand-configured "snowflake" servers drift.
  4. Separate environments. Development, staging and production have their own credentials; debug tooling exists only outside production.
  5. Different secrets per environment, stored in a secrets manager, never in the repository.
  6. Patch regularly (see the components lessons in the next chapter).
  7. Review configuration continuously, not once.

Debug mode and error handling

Showing detailed errors is a development convenience. In production, show a generic message to users and log the details privately with a correlation id the user can quote to support.

Python Generic errors for users, details in logs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Framework switches to check: APP_DEBUG=false (Laravel), DEBUG = False (Django), NODE_ENV=production (Express and many libraries), disabling Spring Boot actuator endpoints or restricting them, display_errors=Off in PHP.

Auditing a configuration

Automation beats memory. A configuration audit script, run in CI or on a schedule, checks every environment against a baseline.

Python A configuration baseline auditor

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real tools do the same at scale: CIS benchmark scanners, cloud security posture management, Terraform and Kubernetes policy checks, container image linters.

Cloud and container configuration

  • Storage: block public access at the account level; use pre-signed URLs for sharing; enable encryption and versioning.
  • IAM: follow least privilege; avoid wildcard permissions ("Action": "*"); use roles instead of long-lived keys; require MFA for humans.
  • Network: security groups open only the ports required, databases not reachable from the internet, internal services in private subnets.
  • Containers: minimal base images, run as a non-root user, read-only file system where possible, no privileged mode, no secrets in images or environment dumps, scan images.
  • Secrets: use a secrets manager, rotate regularly, alert on leaked credentials in repositories.

XML and parser configuration

Many XML parsers resolve external entities by default, letting a crafted document read local files or make requests (XXE). Disable DTD processing and external entities, or use a parser configured that way. The same principle holds for YAML loaders (use safe loading) and deserializers.

Change management

Misconfiguration often appears during changes: a quick fix opened a port "temporarily" and nobody closed it. Keep configuration in version control, review changes like code, and record exceptions with an owner and an expiry date.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is showing stack traces to users in production a problem?

    Log the details privately and show a generic message with a reference id.
  2. 2. What does least functionality mean?

    Each unnecessary feature is attack surface, so remove what you do not use.
  3. 3. Which is a misconfiguration?

    Public buckets are a leading cause of data exposure. The other options are good practices.
  4. 4. How do you keep many environments consistently secure?

    Repeatable builds and automated checks catch drift and mistakes.

Summary

  • Misconfiguration is any insecure setting in OS, server, framework, database, cloud or container.
  • Remove defaults, sample content and unused features, and keep debug output out of production.
  • Build from hardened baselines using code, separate environments and per-environment secrets.
  • Audit continuously with automated checks, and manage configuration changes like code.
  • Disable XML external entities and use safe parsers and loaders.

Next: Security Headers and CORS Configuration