SY0-301 · Question #428
Which of the following is a best practice for error and exception handling?
The correct answer is A. Log detailed exception but display generic error message. Logging detailed exception information internally while displaying only a generic error to users is the security best practice that prevents information disclosure without losing diagnostic capability.
Question
Which of the following is a best practice for error and exception handling?
Options
- ALog detailed exception but display generic error message
- BDisplay detailed exception but log generic error message
- CLog and display detailed error and exception messages
- DDo not log or display error or exception messages
How the community answered
(50 responses)- A86% (43)
- B8% (4)
- C4% (2)
- D2% (1)
Why each option
Logging detailed exception information internally while displaying only a generic error to users is the security best practice that prevents information disclosure without losing diagnostic capability.
Displaying detailed error messages to end users can expose internal system architecture, stack traces, database schemas, or file paths that attackers can leverage for further exploitation. Logging the full exception details on the server side preserves the ability for administrators and developers to diagnose and fix issues while preventing that sensitive information from reaching untrusted parties.
Displaying detailed exception messages to users violates the principle of least disclosure and can reveal implementation details, server-side logic, or infrastructure information useful to an attacker.
Logging and displaying detailed error and exception messages to users combines the risks of both approaches, creating an unnecessary information disclosure vulnerability.
Not logging errors at all eliminates the ability to detect, investigate, and respond to security incidents and application failures, which violates basic operational security and incident response requirements.
Concept tested: Secure error and exception handling practices
Source: https://owasp.org/www-project-proactive-controls/v3/en/c10-errors-exceptions
Topics
Community Discussion
No community discussion yet for this question.