CWE-348 使用不可信的源

admin 2022年1月2日04:09:06CWE(弱点枚举)评论11 views2822字阅读9分24秒阅读模式

CWE-348 使用不可信的源

Use of Less Trusted Source

结构: Simple

Abstraction: Base

状态: Draft

被利用可能性: unkown


The software has two different sources of the same data or information, but it uses the source that has less support for verification, is less trusted, or is less resistant to attack.


  • cwe_Nature: ChildOf cwe_CWE_ID: 345 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 345 cwe_View_ID: 699 cwe_Ordinal: Primary


Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}


范围 影响 注释
Access Control ['Bypass Protection Mechanism', 'Gain Privileges or Assume Identity'] An attacker could utilize the untrusted data source to bypass protection mechanisms and gain access to sensitive data.


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.

bad PHP

$requestingIP = '';
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {



$requestingIP = $_SERVER['REMOTE_ADDR'];





echo "You are not authorized to view this page";


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.

This fixed code only trusts the 'REMOTE_ADDR' header and so avoids the issue:

good PHP

$requestingIP = '';
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {

echo "This application cannot be accessed through a proxy.";


$requestingIP = $_SERVER['REMOTE_ADDR'];


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.


标识 说明 链接
CVE-2001-0860 Product uses IP address provided by a client, instead of obtaining it from the packet headers, allowing easier spoofing.
CVE-2004-1950 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.
BID:15326 Similar to CVE-2004-1950
CVE-2001-0908 Product logs IP address specified by the client instead of obtaining it from the packet headers, allowing information hiding.
CVE-2006-1126 PHP application uses IP address from X-Forwarded-For HTTP header, instead of REMOTE_ADDR.


映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER Use of Less Trusted Source


  • CAPEC-141
  • CAPEC-142
  • CAPEC-73
  • CAPEC-76
  • CAPEC-85


特别标注: 本站(CN-SEC.COM)所有文章仅供技术研究,若将其信息做其他用途,由用户承担全部法律及连带责任,本站不承担任何法律及连带责任,请遵守中华人民共和国安全法.
  • 我的微信
  • 微信扫一扫
  • weinxin
  • 我的微信公众号
  • 微信扫一扫
  • weinxin
  • 本文由 发表于 2022年1月2日04:09:06
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                  CWE-348 使用不可信的源


匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: