CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Description
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
Submission Date :
July 19, 2006, midnight
Modification Date :
2023-10-26 00:00:00+00:00
Organization :
MITRE
Extended Description
There are many different kinds of mistakes that introduce information exposures. The severity of the error can range widely, depending on the context in which the product operates, the type of sensitive information that is revealed, and the benefits it may provide to an attacker. Some kinds of sensitive information include:
- private, personal information, such as personal messages, financial data, health records, geographic location, or contact details
- system status and environment, such as the operating system and installed packages
- business secrets and intellectual property
- network status and configuration
- the product's own code or internal state
- metadata, e.g. logging of connections or message headers
- indirect information, such as a discrepancy between two internal operations that can be observed by an outsider
Information might be sensitive to different parties, each of which may have their own expectations for whether the information should be protected. These parties include:
- the product's own users
- people or organizations whose information is created or used by the product, even if they are not direct product users
- the product's administrators, including the admins of the system(s) and/or networks on which the product operates
- the developer
Information exposures can occur in different ways:
- explicitly inserts
- indirectly inserts
- unintentionally made accessible
It is common practice to describe any loss of confidentiality as an "information exposure," but this can lead to overuse of CWE-200 in CWE mapping. From the CWE perspective, loss of confidentiality is a technical impact that can arise from dozens of different weaknesses, such as insecure file permissions or out-of-bounds read. CWE-200 and its lower-level descendants are intended to cover the mistakes that occur in behaviors that explicitly manage, store, transfer, or cleanse sensitive information.
- indirectly inserts
- explicitly inserts
Example - 1
The following code checks validity of the supplied username and password and notifies the user of a successful or failed login. In the above code, there are different messages for when an incorrect username is supplied, versus when the username is correct but the password is wrong. This difference enables a potential attacker to understand the state of the login function, and could allow an attacker to discover a valid username by trying different values until the incorrect password message is returned. In essence, this makes it easier for an attacker to obtain half of the necessary authentication credentials. While this type of information may be helpful to a user, it is also useful to a potential attacker. In the above example, the message for both failed cases should be the same, such as:
print "Login Successful";
print "Login Failed - incorrect password";if (IsValidPassword($username, $password) == 1){}else{}
print "Login Failed - unknown username";my $username=param('username');my $password=param('password');if (IsValidUsername($username) == 1){}else{}
"Login Failed - incorrect username or password"
Example - 2
This code tries to open a database connection, and prints any exceptions that occur. If an exception occurs, the printed message exposes the location of the configuration file the script is using. An attacker can use this information to target the configuration file (perhaps exploiting a Path Traversal weakness). If the file can be read, the attacker could gain credentials for accessing the database. The attacker may also be able to replace the file with a malicious one, causing the application to use an arbitrary database.openDbConnection();
// //print exception message that includes exception message and configuration file location//
echo 'Caught exception: ', $e->getMessage(), '\n';echo 'Check credentials in config file at: ', $Mysql_config_location, '\n';try {}catch (Exception $e) {}
Example - 3
In the example below, the method getUserBankAccount retrieves a bank account object from a database using the supplied username and account number to query the database. If an SQLException is raised when querying the database, an error message is created and output to a log file. The error message that is created includes information about the database query that may contain sensitive information about the database or query logic. In this case, the error message will expose the table name and column names used in the database. This data could be used to simplify other attacks, such as SQL injection (CWE-89) to directly access the database.
query = "SELECT * FROM accounts WHERE owner = "+ username + " AND accountID = " + accountNumber;DatabaseManager dbManager = new DatabaseManager();Connection conn = dbManager.getConnection();Statement stmt = conn.createStatement();ResultSet queryResult = stmt.executeQuery(query);userAccount = (BankAccount)queryResult.getObject(accountNumber);if (isAuthorizedUser(username)) {}
String logMessage = "Unable to retrieve account information from database,\nquery: " + query;Logger.getLogger(BankManager.class.getName()).log(Level.SEVERE, logMessage, ex);
BankAccount userAccount = null;String query = null;try {} catch (SQLException ex) {}return userAccount;public BankAccount getUserBankAccount(String username, String accountNumber) {}
Example - 4
This code stores location information about the current user: When the application encounters an exception it will write the user object to the log. Because the user object contains location information, the user's location is also written to the log.
// ...//
AlertDialog.Builder builder = new AlertDialog.Builder(this);builder.setMessage("Sorry, this application has experienced an error.");AlertDialog alert = builder.create();alert.show();Log.e("ExampleActivity", "Caught exception: " + e + " While on User:" + User.toString());locationClient = new LocationClient(this, this, this);locationClient.connect();currentUser.setLocation(locationClient.getLastLocation());catch (Exception e) {}
Example - 5
The following is an actual MySQL error statement: The error clearly exposes the database credentials.Warning: mysql_pconnect(): Access denied for user: 'root@localhost' (Using password: N1nj4) in /usr/local/www/wi-data/includes/database.inc on line 4
Example - 6
This code displays some information on a web page. The code displays a user's credit card and social security numbers, even though they aren't absolutely necessary.Social Security Number: <%= ssn %></br>Credit Card Number: <%= ccn %>
Example - 7
The following program changes its behavior based on a debug flag. The code writes sensitive debug information to the client browser if the "debugEnabled" flag is set to true .
%>User account number: <%= acctNo %><%} %><% if (Boolean.getBoolean("debugEnabled")) {
Example - 8
This code uses location to determine the user's current US State location. First the application must declare that it requires the ACCESS_FINE_LOCATION permission in the application's manifest.xml: During execution, a call to getLastLocation() will return a location based on the application's location permissions. In this case the application has permission for the most accurate location possible: While the application needs this information, it does not need to use the ACCESS_FINE_LOCATION permission, as the ACCESS_COARSE_LOCATION permission will be sufficient to identify which US state the user is in.<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
locationClient = new LocationClient(this, this, this);locationClient.connect();Location userCurrLocation;userCurrLocation = locationClient.getLastLocation();deriveStateFromCoords(userCurrLocation);
Related Weaknesses
This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.
CWE-201: Insertion of Sensitive Information Into Sent Data
CWE-203: Observable Discrepancy
CWE-209: Generation of Error Message Containing Sensitive Information
CWE-213: Exposure of Sensitive Information Due to Incompatible Policies
CWE-215: Insertion of Sensitive Information Into Debugging Code
CWE-359: Exposure of Private Personal Information to an Unauthorized Actor
CWE-497: Exposure of Sensitive System Information to an Unauthorized Control Sphere
CWE-498: Cloneable Class Containing Sensitive Information
CWE-499: Serializable Class Containing Sensitive Data
CWE-532: Insertion of Sensitive Information into Log File
CWE-538: Insertion of Sensitive Information into Externally-Accessible File or Directory
CWE-668: Exposure of Resource to Wrong Sphere
CWE-1258: Exposure of Sensitive System Information Due to Uncleared Debug Information
CWE-1272: Sensitive Information Uncleared Before Debug/Power State Transition
CWE-1273: Device Unlock Credential Sharing
CWE-1295: Debug Messages Revealing Unnecessary Information
Visit http://cwe.mitre.org/ for more details.