The software generates an error message that includes sensitive information about its environment, users, or associated data.
The sensitive information may be valuable information on its own (such as a password), or it may be useful for launching other, more deadly attacks. If an attack fails, an attacker may use error information provided by the server to launch another more focused attack. For example, an attempt to exploit a path traversal weakness might yield the full pathname of the installed application. In turn, this could be used to select the proper number of “..” sequences to navigate to the targeted file. An attack using SQL injection might not initially succeed, but an error message could reveal the malformed query, which would expose query logic and possibly even passwords or other sensitive information used within the query.
Suppress these error messages by ensuring that a customised error handler is called in the event of an error. This can produce a generic message which does not hint at the underlying cause of the exception.
OWASP – Error Handling
How to: Display Safe Error Messages
When your application displays error messages, it should not give away information that a malicious user might find helpful in attacking your system. For example, if your application unsuccessfully tries to log in to a database, it should not display an error message that includes the user name it is using.
There are a number of ways to control error messages, including the following:
Configure the application not to show verbose error messages to remote users. (Remote users are those who request pages while not working on the Web server computer.) You can optionally redirect errors to an application page.
Include error handling whenever practical and construct your own error messages. In your error handler, you can test to see whether the user is local and react accordingly.
Create a global error handler at the page or application level that catches all unhandled exceptions and routes them to a generic error page. That way, even if you did not anticipate a problem, at least users will not see an exception page.
To configure the application to turn off errors for remote users
In the Web.config file for your application, make the following changes to the customErrors element:
- Set the mode attribute to RemoteOnly (case-sensitive). This configures the application to show detailed errors only to local users (that is, to you, the developer).
- Optionally include a defaultRedirect attribute that points to an application error page.
- Optionally include <error> elements that redirect specific errors to specific pages. For example, you can redirect standard 404 errors (page not found) to your own application page.
The following code example shows a typical customErrors block in the Web.config file.
<customErrors mode="RemoteOnly" defaultRedirect="AppErrors/"> <error statusCode="404" redirect="NoSuchPage/"/> <error statusCode="403" redirect="NoAccessAllowed/"/> </customErrors>