---
title: "CWE-540: Inclusion of Sensitive Information in Source Code"
url: https://radicalnotion.ai/cwe/cwe-540
type: cwe
description: "The product (such as a web server or repository) provides access to source code is not intended to be accessible to users but contains sensitive information."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-540: Inclusion of Sensitive Information in Source Code

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 35
- **Of those, in CISA KEV:** 0
- **New in 2026:** 11
- **CWE catalog version:** 4.21

## Description

The product (such as a web server or repository) provides access to source code is not intended to be accessible to users but contains sensitive information.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Technologies:** Web Based (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality | Read Application Data, Varies by Context | Obtaining 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. |

## Potential mitigations

### Architecture and Design, System Configuration

Recommendations include removing the script from the web server and moving it to a location not accessible from the Internet.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

## Demonstrative examples

### Example 1

The following code uses an include file to store database credentials:

Bad code:

```php
<?php
$dbName = 'usersDB';
$dbPassword = 'skjdh#67nkjd3$3$';
?>
```

Bad code:

```php
<?php
include('database.inc');
$db = connectToDB($dbName, $dbPassword);
$db.authenticateUser($username, $password);
?>
```

### Example 2

The following comment, embedded in a JSP, will be displayed in the resulting HTML output.

Bad code:

```jsp
<!-- FIXME: calling this with more than 30 args kills the JDBC server -->
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2022-25512 | Server for Team Awareness Kit (TAK) application includes sensitive tokens in the JavaScript source code. |
| CVE-2022-24867 | The LDAP password might be visible in the html code of a rendered page in an IT Asset Management tool. |
| CVE-2007-6197 | Version numbers and internal hostnames leaked in HTML comments. |

## Real CVEs with this weakness (sample of 12 of 35)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-38327 | IBM Analytics Content Hub information disclosure | critical | 9.8 | - | No | 2025-07-10 |
| CVE-2025-49182 | Credential disclosure | critical | 9.8 | - | No | 2025-06-12 |
| CVE-2026-84390 | - | critical | 9.6 | - | No | 2026-09-11 |
| CVE-2025-26013 | - | high | 8.2 | - | No | 2025-02-21 |
| CVE-2024-38647 | QNAP AI Core | high | 7.9 | - | No | 2024-11-22 |
| CVE-2023-39250 | - | high | 7.8 | - | No | 2023-08-16 |
| CVE-2021-28805 | Inclusion of Sensitive Information in QSS | high | 7.8 | - | No | 2021-06-11 |
| CVE-2026-78192 | WebDyne versions from 2.022 before 3.022 for Perl disclose application source to unauthenticated clients via the viewer in the default index page | high | 7.5 | - | No | 2026-10-31 |
| CVE-2026-73591 | - | high | 7.5 | - | No | 2026-09-23 |
| CVE-2026-4155 | ChargePoint Home Flex Inclusion of Sensitive Information in Source Code Information Disclosure Vulnerability | high | 7.5 | - | No | 2026-04-11 |
| CVE-2024-1272 | Information Disclosure to Source Code in TNB Mobile Solutions' Cockpit Software | high | 7.5 | - | No | 2024-06-05 |
| CVE-2024-2265 | keerti1924 PHP-MYSQL-User-Login-System login.sql inclusion of sensitive information in source code | high | 7.5 | - | No | 2024-03-07 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-538](https://radicalnotion.ai/cwe/cwe-538) | Insertion of Sensitive Information into Externally-Accessible File or Directory |
| Child | [CWE-531](https://radicalnotion.ai/cwe/cwe-531) | Inclusion of Sensitive Information in Test Code |
| Child | [CWE-541](https://radicalnotion.ai/cwe/cwe-541) | Inclusion of Sensitive Information in an Include File |
| Child | [CWE-615](https://radicalnotion.ai/cwe/cwe-615) | Inclusion of Sensitive Information in Source Code Comments |

## Frequently asked questions

### What is CWE-540?

The product (such as a web server or repository) provides access to source code is not intended to be accessible to users but contains sensitive information.

### What CVEs are caused by CWE-540?

35 recorded CVEs are attributed to CWE-540, including CVE-2024-38327, CVE-2025-49182 and CVE-2026-84390.

### How do you prevent CWE-540?

Recommendations include removing the script from the web server and moving it to a location not accessible from the Internet.

### How is CWE-540 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-540?

Exploiting CWE-540 can lead to: Read Application Data, Varies by Context.

### Is CWE-540 actively exploited?

35 recorded CVEs are caused by CWE-540; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/540.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-540). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
