CWE-540: Inclusion of Sensitive Information in Source Code
View customized information:
For users who are interested in more notional aspects of a weakness. Example: educators, technical writers, and project/program managers.
For users who are concerned with the practical application and details about the nature of a weakness and how to prevent it from happening. Example: tool developers, security researchers, pen-testers, incident response analysts.
For users who are mapping an issue to CWE/CAPEC IDs, i.e., finding the most appropriate CWE for a specific issue (e.g., a CVE record). Example: tool developers, security researchers.
For users who wish to see all available information for the CWE/CAPEC entry.
For users who want to customize what details are displayed.
×
Edit Custom FilterSource code on a web server or repository often contains sensitive information and should generally not be accessible to users.
There are situations where it is critical to remove source code from an area or server. For example, obtaining Perl source code on a system allows an attacker to understand the logic of the script and extract extremely useful information such as code bugs or logins and passwords.
![]()
![]() ![]()
![]()
Example 1 The following code uses an include file to store database credentials: database.inc (bad code)
Example Language: PHP
<?php
$dbName = 'usersDB'; $dbPassword = 'skjdh#67nkjd3$3$'; ?> login.php (bad code)
Example Language: PHP
<?php
include('database.inc'); $db = connectToDB($dbName, $dbPassword); $db.authenticateUser($username, $password); ?> If the server does not have an explicit handler set for .inc files it may send the contents of database.inc to an attacker without pre-processing, if the attacker requests the file directly. This will expose the database name and password. Example 2 The following comment, embedded in a JSP, will be displayed in the resulting HTML output. (bad code)
Example Language: JSP
<!-- FIXME: calling this with more than 30 args kills the JDBC server -->
![]()
More information is available — Please edit the custom filter or select a different filter. |
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. |