Threats, Vulnerabilities, and Attacks

A web application shows users a full stack trace, including file paths and database query text, when an unexpected error occurs. What is the BEST way to fix this?

Show the answer

Correct answerC. Log detailed errors server-side and show users a generic error message

AWhy not this: This addresses hardcoded secrets, but the stack trace would still leak paths and query text.

BWhy not this: Session timeout does not control what error content is displayed to users.

CWhy this is right: Detailed server-side logs keep diagnostics for staff, and a generic message gives attackers nothing to use.

DWhy not this: Encrypting for the browser is pointless; the user's client must display it, so details still leak.

Showing stack traces is unsafe exception handling because it discloses internals that help an attacker. Logging details on the server and returning a generic message keeps diagnostics available without leaking them. Moving the password addresses hardcoded secrets, not error output.