SyntaxStudy
Sign Up
Web Security OWASP Top 10 2021: A05–A08 with Examples
Web Security Beginner 2 min read

OWASP Top 10 2021: A05–A08 with Examples

A05: Security Misconfiguration is consistently one of the most common findings in penetration tests. It includes default credentials left unchanged, unnecessary features enabled (debug mode, directory listing, example applications), overly permissive cloud IAM policies, verbose error messages exposing stack traces, and missing security headers. Mitigation requires a repeatable hardening checklist applied to every environment and automated configuration scanning in CI/CD. A06: Vulnerable and Outdated Components addresses the widespread use of libraries, frameworks, and operating system packages with known vulnerabilities. The Log4Shell vulnerability (CVE-2021-44228) in Apache Log4j2 allowed unauthenticated remote code execution in millions of Java applications through a single log statement. Mitigation: maintain a Software Bill of Materials (SBOM), run automated dependency scanning with tools like Dependabot, Snyk, or OWASP Dependency-Check, and have a process for emergency patching. A07: Identification and Authentication Failures covers weak passwords, missing MFA, insecure session management, and credential stuffing vulnerabilities. A08: Software and Data Integrity Failures is a new category covering insecure CI/CD pipelines, auto-update mechanisms without signature verification, and deserialisation of untrusted data. A08 gained prominence after the SolarWinds supply chain attack, where malicious code was injected into a software update and signed with the vendor's legitimate certificate. Defences include signing all build artefacts, pinning dependency hashes in lock files, using SLSA (Supply-chain Levels for Software Artefacts) framework controls, and reviewing third-party code before including it. PHP `unserialize()` with untrusted data is the classic A08 example — use JSON instead.
Example
<?php
// A05: Security Misconfiguration — disable debug mode and verbose errors in production

// config/app.php — driven by environment variable
return [
    'debug' => (bool) env('APP_DEBUG', false),  // NEVER true in production
    'env'   => env('APP_ENV', 'production'),
];

// .env.production — never commit this file
// APP_DEBUG=false
// APP_ENV=production

// Custom exception handler: safe error responses (no stack traces)
// app/Exceptions/Handler.php
public function render($request, Throwable $e): Response
{
    if ($request->expectsJson()) {
        $status  = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500;
        $message = app()->isProduction() ? 'An error occurred.' : $e->getMessage();
        return response()->json(['error' => $message], $status);
    }
    return parent::render($request, $e);
}

// A08: Unsafe deserialisation — never unserialize untrusted data
// DANGEROUS:
// $userData = unserialize($_COOKIE['user_data']);  // BAD — PHP Object Injection

// SAFE: use JSON
$userData = json_decode(base64_decode($_COOKIE['user_data'] ?? ''), true);
if (!is_array($userData)) {
    $userData = [];
}

// A06: Dependency scanning in composer.json scripts
// "scripts": {
//     "audit": "composer audit",
//     "security-check": "vendor/bin/security-checker security:check"
// }