CWE-541 Variant Incomplete

Inclusion of Sensitive Information in an Include File

This vulnerability occurs when sensitive data like passwords or system details is placed inside a publicly accessible include file. Attackers can directly request these files to steal credentials…

Definition

What is CWE-541?

This vulnerability occurs when sensitive data like passwords or system details is placed inside a publicly accessible include file. Attackers can directly request these files to steal credentials and compromise the application.
Include files (like .inc, .config, or library files) are often used to store common code or configuration settings. When these files contain hard-coded secrets such as database passwords, API keys, or administrative credentials, and are left in a web-accessible directory, they become a prime target. Attackers can simply browse to the file's URL to download its full source code, bypassing the main application's security controls entirely. To prevent this, never store sensitive information within web-accessible include files. Instead, move configuration containing secrets outside the web root or into environment variables and protected configuration files. Additionally, configure your web server to deny requests to files with common include extensions, and ensure your deployment process cleans directories of development or backup files that might inadvertently expose data.
Auswirkungen in der Praxis

Real-world CVEs caused by CWE-541

Bisher sind in MITREs Katalog keine öffentlichen CVE-Referenzen mit dieser CWE verknüpft.

Wie Angreifer es ausnutzen

Angreiferpfad Schritt für Schritt

  1. 1

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

  2. 2

    database.inc

  3. 3

    login.php

  4. 4

    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.

Verwundbares Codebeispiel

Vulnerable PHP

database.inc

Verwundbar PHP
<?php
  $dbName = 'usersDB';
  $dbPassword = 'skjdh#67nkjd3$3$';
  ?>
Sicheres Codebeispiel

Secure pseudo

Sicher pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Präventions-Checkliste

How to prevent CWE-541

  • Architecture and Design Do not store sensitive information in include files.
  • Architecture and Design / System Configuration Protect include files from being exposed.
Erkennungssignale

How to detect CWE-541

SAST High

Führe statische Analyse (SAST) auf der Codebasis aus und suche im Datenfluss nach dem unsicheren Muster.

DAST Moderate

Führe dynamische Application-Security-Tests gegen den Live-Endpoint aus.

Runtime Moderate

Beobachte Runtime-Logs auf ungewöhnliche Exception-Traces, fehlerhafte Eingaben oder Versuche, Autorisierung zu umgehen.

Code review Moderate

Code Review: Markiere jeden neuen Code, der Eingaben von dieser Oberfläche ohne validierte Framework-Helper verarbeitet.

Plexicus Auto-Fix

Plexicus erkennt CWE-541 automatisch und öffnet in unter 60 Sekunden einen Fix-PR.

Codex Remedium scannt jeden Commit, identifiziert genau diese Schwachstelle und liefert einen reviewer-ready Pull Request mit dem Patch. Keine Tickets. Keine Hand-offs.

Häufig gestellte Fragen

Frequently asked questions

Was ist CWE-541?

This vulnerability occurs when sensitive data like passwords or system details is placed inside a publicly accessible include file. Attackers can directly request these files to steal credentials and compromise the application.

Wie gravierend ist CWE-541?

MITRE hat für diese Schwachstelle keine Exploit-Wahrscheinlichkeit veröffentlicht. Behandle sie als mittlere Auswirkung, bis dein Threat Model anderes belegt.

Welche Sprachen oder Plattformen sind von CWE-541 betroffen?

MITRE hat für diese CWE keine betroffenen Plattformen spezifiziert — sie kann in den meisten Anwendungs-Stacks auftreten.

Wie kann ich CWE-541 verhindern?

Do not store sensitive information in include files. Protect include files from being exposed.

Wie erkennt und behebt Plexicus CWE-541?

Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-541 bei jedem Commit. Bei einem Treffer öffnet unser Codex-Remedium-Agent einen Fix-PR mit korrigiertem Code, Tests und einer einzeiligen Zusammenfassung für den Reviewer.

Wo erfahre ich mehr über CWE-541?

MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/541.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.

Bereit, wenn du es bist

Schluss mit dem Bezahlen pro Entwickler.
Schließ den Kreislauf.

Plexicus ist die KI-native ASPM, die scannt, filtert, fixt, pentestet und erklärt — autonom. Unbegrenzte Entwickler, unbegrenzte Repos, Fair-Use-KI-Aktionen. Echter kostenloser Tarif, €269/mo jährlich, wenn du bereit bist.