nerdexam
CompTIA

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.

General security concepts

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)
  • A
    86% (43)
  • B
    8% (4)
  • C
    4% (2)
  • D
    2% (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.

ALog detailed exception but display generic error messageCorrect

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.

BDisplay detailed exception but log generic error message

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.

CLog and display detailed error and exception messages

Logging and displaying detailed error and exception messages to users combines the risks of both approaches, creating an unnecessary information disclosure vulnerability.

DDo not log or display error or exception messages

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

#error handling#secure coding#information disclosure#exception management

Community Discussion

No community discussion yet for this question.

Full SY0-301 Practice