Führe statische Analyse (SAST) auf der Codebasis aus und suche im Datenfluss nach dem unsicheren Muster.
Use of Less Trusted Source
This vulnerability occurs when a system has access to multiple sources for the same critical data, but it chooses to rely on the less secure or less trustworthy one. This creates a security gap…
What is CWE-348?
Real-world CVEs caused by CWE-348
-
Product uses IP address provided by a client, instead of obtaining it from the packet headers, allowing easier spoofing.
-
Web product uses the IP address in the X-Forwarded-For HTTP header instead of a server variable that uses the connecting IP address, allowing filter bypass.
-
Product logs IP address specified by the client instead of obtaining it from the packet headers, allowing information hiding.
-
PHP application uses IP address from X-Forwarded-For HTTP header, instead of REMOTE_ADDR.
Angreiferpfad Schritt für Schritt
- 1
This code attempts to limit the access of a page to certain IP Addresses. It checks the 'HTTP_X_FORWARDED_FOR' header in case an authorized user is sending the request through a proxy.
- 2
The 'HTTP_X_FORWARDED_FOR' header can be user controlled and so should never be trusted. An attacker can falsify the header to gain access to the page.
- 3
This fixed code only trusts the 'REMOTE_ADDR' header and so avoids the issue:
- 4
Be aware that 'REMOTE_ADDR' can still be spoofed. This may seem useless because the server will send the response to the fake address and not the attacker, but this may still be enough to conduct an attack. For example, if the generatePage() function in this code is resource intensive, an attacker could flood the server with fake requests using an authorized IP and consume significant resources. This could be a serious DoS attack even though the attacker would never see the page's sensitive content.
Vulnerable PHP
This code attempts to limit the access of a page to certain IP Addresses. It checks the 'HTTP_X_FORWARDED_FOR' header in case an authorized user is sending the request through a proxy.
$requestingIP = '0.0.0.0';
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
$requestingIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
else{
$requestingIP = $_SERVER['REMOTE_ADDR'];
}
if(in_array($requestingIP,$ipAllowlist)){
generatePage();
return;
}
else{
echo "You are not authorized to view this page";
return;
} Secure PHP
This fixed code only trusts the 'REMOTE_ADDR' header and so avoids the issue:
$requestingIP = '0.0.0.0';
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
echo "This application cannot be accessed through a proxy.";
return;
else{
$requestingIP = $_SERVER['REMOTE_ADDR'];
}
```
...* How to prevent CWE-348
- Architecture Use safe-by-default frameworks and APIs that prevent the unsafe pattern from being expressible.
- Implementation Validate input at trust boundaries; use allowlists, not denylists.
- Implementation Apply the principle of least privilege to credentials, file paths, and runtime permissions.
- Testing Cover this weakness in CI: SAST rules + targeted unit tests for the data flow.
- Operation Monitor logs for the runtime signals listed in the next section.
How to detect CWE-348
Führe dynamische Application-Security-Tests gegen den Live-Endpoint aus.
Beobachte Runtime-Logs auf ungewöhnliche Exception-Traces, fehlerhafte Eingaben oder Versuche, Autorisierung zu umgehen.
Code Review: Markiere jeden neuen Code, der Eingaben von dieser Oberfläche ohne validierte Framework-Helper verarbeitet.
Plexicus erkennt CWE-348 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.
Frequently asked questions
Was ist CWE-348?
This vulnerability occurs when a system has access to multiple sources for the same critical data, but it chooses to rely on the less secure or less trustworthy one. This creates a security gap because the system ignores better-protected alternatives that offer stronger verification or are harder for attackers to compromise.
Wie gravierend ist CWE-348?
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-348 betroffen?
MITRE hat für diese CWE keine betroffenen Plattformen spezifiziert — sie kann in den meisten Anwendungs-Stacks auftreten.
Wie kann ich CWE-348 verhindern?
Use safe-by-default frameworks, validate untrusted input at trust boundaries, and apply the principle of least privilege. Cover the data-flow signature in CI with SAST.
Wie erkennt und behebt Plexicus CWE-348?
Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-348 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-348?
MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/348.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.
Weaknesses related to CWE-348
Insufficient Verification of Data Authenticity
This vulnerability occurs when an application fails to properly check where data comes from or confirm its legitimacy, allowing untrusted…
Missing Source Correlation of Multiple Independent Data
This vulnerability occurs when a system trusts a single source of data without verification, making it impossible to detect if that source…
Origin Validation Error
This vulnerability occurs when an application fails to properly confirm the true origin of incoming data or communication, allowing…
Improper Verification of Cryptographic Signature
This vulnerability occurs when an application fails to properly check the digital signature on data, or skips the verification step…
Acceptance of Extraneous Untrusted Data With Trusted Data
This vulnerability occurs when a system processes both trusted and untrusted data together, but fails to separate them. The application…
Insufficient Type Distinction
This vulnerability occurs when an application fails to properly differentiate between different types of data or objects, leading to…
Cross-Site Request Forgery (CSRF)
Cross-Site Request Forgery (CSRF) happens when a web application cannot reliably tell if a user actually intended to submit a request,…
Missing Support for Integrity Check
This vulnerability occurs when a system uses a communication protocol that lacks built-in integrity verification, such as a checksum or…
Improper Validation of Integrity Check Value
This vulnerability occurs when software fails to properly check the integrity of data by validating its checksum or hash value. Without…
Further reading
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.