Lab 05: OWASP A05 — Security Misconfiguration

Objective

Exploit security misconfiguration vulnerabilities on a live server from Kali Linux: discover sensitive files (.env, backup SQL) with gobuster, access the interactive debugger console, extract all environment variables via a debug info endpoint, exploit default credentials (admin:admin) to access the admin panel, trigger verbose error messages leaking database schema, and audit missing HTTP security headers.

Background

Security Misconfiguration is OWASP #5 (2021) — found in 90% of applications tested. Unlike coding vulnerabilities, these are deployment mistakes: debug mode left on, default passwords unchanged, .env files committed to web root, unnecessary endpoints exposed. In 2020, a misconfigured Elasticsearch instance exposed 5 billion records. The 2021 Verkada breach (150,000 security cameras) used default credentials. These are the easiest vulnerabilities to find and exploit.

Architecture

┌─────────────────────┐        Docker Network: lab-a05         ┌─────────────────────┐
│   KALI ATTACKER     │ ─────── HTTP attacks ─────────────▶   │   VICTIM SERVER     │
│  innozverse-kali    │                                         │  innozverse-cybersec│
│  gobuster, curl,    │ ◀────── responses ───────────────────  │  Flask :5000        │
│  nikto, whatweb     │                                         │  (debug on, .env,   │
└─────────────────────┘                                         │   default creds)    │
                                                                └─────────────────────┘

Time

35 minutes

Tools

  • Victim: zchencow/innozverse-cybersec:latest

  • Attacker: zchencow/innozverse-kali:latest (gobuster, nikto, curl, whatweb)


Lab Instructions

Step 1: Environment Setup


Step 2: Launch Kali + Initial Recon

Inside Kali:

📸 Verified Output:


Step 3: Directory Enumeration — Find Hidden Files

📸 Verified Output:

💡 .env files returning 200 are a critical finding. These files are designed to store secrets (database passwords, API keys, JWT secrets) for development. They should be blocked at the web server level (deny all in nginx for .env) and should never be in the web root. console returning 400 indicates Werkzeug's interactive debugger is present — normally requires a PIN but is dangerous.


Step 4: Read Sensitive Files Directly

📸 Verified Output:


Step 5: Debug Info Endpoint — Environment Variables Dump

📸 Verified Output:


Step 6: Verbose Error Messages — Schema Disclosure

📸 Verified Output:

💡 Verbose error messages are free reconnaissance for attackers. Stack traces reveal: file paths, framework versions, database table names, query structure, and developer email in some frameworks. In production, return {"error": "Internal server error", "id": "ERR-20260304-abc123"} — log the full detail server-side, only return an opaque correlation ID to the client.


Step 7: Default Credentials — Admin Panel

📸 Verified Output:


Step 8: Security Header Audit

📸 Verified Output:

Step 9: Cleanup


Remediation

Misconfiguration
Finding
Fix

debug=True

Werkzeug console exposed

debug=False; use env var FLASK_ENV=production

.env in web root

All secrets exposed

Block in nginx: location ~ /\.env { deny all; }

Debug info endpoint

All env vars returned

Remove /api/info entirely from production

Verbose errors

Stack trace + query in response

Generic error + correlation ID; full details in server logs only

Default credentials

admin:admin = full access

Mandatory password change on first login; fail deployment if default

No security headers

XSS, clickjacking, MITM risk

Add all 6 headers in nginx/Flask middleware

Summary

Attack
Tool
Result

File enumeration

gobuster

Found .env, backup.sql, config.php, phpinfo.php

Env file read

curl

DB password, AWS key, JWT secret

Debug info

curl

All server env vars + hardcoded secrets

Verbose errors

curl

DB schema, file paths, stack trace

Default creds

curl

admin:admin → admin panel + DB connection string

Header audit

curl + python3

6/6 security headers missing

Further Reading

Last updated