Safeguard
Application Security•

CWE-537 Java Runtime Error Messages: Keep Exceptions Off the Screen

Unhandled Java exceptions can show internals to users. A short guide to CWE-537 and the one rule MITRE gives for fixing it.

Safeguard Security Team
2 min read

CWE-537, Java Runtime Error Message Containing Sensitive Information, is the plain Java version of a familiar mistake. MITRE says that in many cases an attacker can use the conditions that cause unhandled exception errors to gain unauthorized access to the system.

How it happens

Java code throws runtime exceptions when something unexpected arrives: a null value, a bad number, a missing file. If nothing catches the exception, it travels up to the container or framework, which may render it for the user. The message can carry details about the code and the environment.

What an attacker gains

MITRE lists reading application data as the confidentiality impact. The practical gain is knowledge. Each unhandled error teaches the attacker something about how the application is built, which makes the next probe better aimed.

How to find it

  • Feed bad input to every endpoint: nulls, empty strings, non-numeric values where numbers are expected.
  • Read the response bodies, not just the status codes.
  • Search for broad places where exceptions are thrown but never caught at a boundary.

How to fix it

MITRE's mitigation for this entry is one sentence: do not expose sensitive error information to the user, applied during implementation. In steps:

  1. Add a single handler at the application boundary that catches exceptions.
  2. Return a generic message with a status code.
  3. Write the real exception to a server log that users cannot read.
try {
    process(request);
} catch (RuntimeException e) {
    logger.error("Request failed", e);
    response.sendError(500, "Something went wrong");
}

Quick check

Where should the full exception go?

Into a server-side log that only your team can read, never into the response.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.