← PHP / Laravel · Contents

PHP-036 / Beginner

Exposing exceptions or stack traces in user responses

A05:2021 Security Misconfiguration · CWE-209 Error Message Information Exposure

Why is this a problem?

Internal paths, SQL and library versions provide clues for attackers.

How to fix it

php
} catch (\Throwable $e) {
    report($e);   // Server log
    return response()->json(['message' => 'An error occurred during processing.'], 500);
}

Further reading