Variant · Low-Medium

CWE-541: Inclusion of Sensitive Information in an Include File

If an include file source is accessible, the file can contain usernames and passwords, as well as sensitive information pertaining to the application and system.

CWE-541 · Variant Level ·2 Mitigations

Description

If an include file source is accessible, the file can contain usernames and passwords, as well as sensitive information pertaining to the application and system.

Potential Impact

Confidentiality

Read Application Data

Demonstrative Examples

The following code uses an include file to store database credentials:
database.inc
Bad
<?php$dbName = 'usersDB';$dbPassword = 'skjdh#67nkjd3$3$';?>
login.php
Bad
<?phpinclude('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.

Mitigations & Prevention

Architecture and Design

Do not store sensitive information in include files.

Architecture and DesignSystem Configuration

Protect include files from being exposed.

Frequently Asked Questions

What is CWE-541?

CWE-541 (Inclusion of Sensitive Information in an Include File) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. If an include file source is accessible, the file can contain usernames and passwords, as well as sensitive information pertaining to the application and system.

How can CWE-541 be exploited?

Attackers can exploit CWE-541 (Inclusion of Sensitive Information in an Include File) to read application data. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-541?

Key mitigations include: Do not store sensitive information in include files.

What is the severity of CWE-541?

CWE-541 is classified as a Variant-level weakness (Low-Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.